How to set the center of a newly created Figure at the Mouse Location? [message #243997] |
Wed, 02 July 2008 17:42 |
Eclipse User |
|
|
|
Originally posted by: rolfes.daniel.web.de
Hi,
I create a figure from the palette onto the diagram. The mouse location
and the upper-left point of the newly created element will be the same
after the creation.
But I would like the mouse location to be the center of the newly
created element.
How can I achieve this?
Thanks,
Daniel
|
|
|
|
Re: How to set the center of a newly created Figure at the Mouse Location? [message #244034 is a reply to message #244005] |
Thu, 03 July 2008 13:21 |
Eclipse User |
|
|
|
Originally posted by: rolfes.daniel.web.de
Hi,
thanks for your answer.
I've searched the newsgroup for solutions and there were suggestions to
set a breakpoint to SetBoundsCommand. I did the following in the
LayoutPolicy in the "protected Command getCreateCommand(CreateRequest
request)" method:
req.setLocation(//a fixed position));
This works fine.
My problem is that the location depends on the size of the Figures I
want to create. So I figured I have to somehow get to the corresponding
EditPart or Figure to get the size. The SetBoundsCommand is afaiu
invoked while the Mouse is moved (mouse_move). At this point the
EditPart and the Figure are not even created. I think they will be
created during the "Mouse Click" (mouse_up).
My problem is quite similiar to this one:
http://dev.eclipse.org/newslists/news.eclipse.modeling.gmf/m sg11496.html
So as i understand, what I need is a place where the mouse location is
known and I am able to get to the created EditPart or Figure.
After that I can use setLocation() on the created Figure, or is this the
wrong idea?
Could you please point me in the right direction?
Thanks,
Daniel
sharad schrieb:
> in your create command (where you actually set the location of your edit part) change the value of x and y of your bounds and then set the edit part's location.
|
|
|
Re: How to set the center of a newly created Figure at the Mouse [message #244080 is a reply to message #244034] |
Fri, 04 July 2008 14:07 |
Eclipse User |
|
|
|
Originally posted by: shady_86.sify.com
as you have request.setLocation(), you also have request.getSize
in your "protected Command getCreateCommand(CreateRequest
request)" method you return a command, just go in that command class.
there also you are setting the location and size of your object in the model.
so you can use any of the method...
i suggest doing it in the command is a better practice..,
|
|
|
Powered by
FUDForum. Page generated in 0.03298 seconds