Skip to main content



      Home
Home » Modeling » GMF (Graphical Modeling Framework) » Figure position
Figure position [message #177130] Thu, 13 March 2008 10:37 Go to next message
Eclipse UserFriend
Originally posted by: rump.informatik-emden.de

Hi all,

I am searching for a while but can't find an answer. When I create a new
figure on a diagram the mouse position is always the left upper corner
of the figure. But in my application the mouse position should be the
center of the figure. What do I have to do to change this behaviour?

Regards,
Frank
Re: Figure position [message #177222 is a reply to message #177130] Thu, 13 March 2008 15:17 Go to previous messageGo to next message
Eclipse UserFriend
Frank,

When a new figure is created a SetBoundsCommand is executed to set the
location of the figure. If you put a breakpoint in the SetBoundsCommand
constructor and attempt to create your figure using the palette tool,
you will see where this command is created, most likely from the
XYLayoutEditPolicy.

The method getConstraintFor(CreateRequest request) in the
XYLayoutEditPolicy is where the mouse location set in the request gets
translated to a location and size that will be passed to the
SetBoundsCommand. You should be able to override this method in a
custom editpolicy to use the mouse location as the center of the shpae
instead.

Regards,
Cherie

Frank Rump wrote:
> Hi all,
>
> I am searching for a while but can't find an answer. When I create a new
> figure on a diagram the mouse position is always the left upper corner
> of the figure. But in my application the mouse position should be the
> center of the figure. What do I have to do to change this behaviour?
>
> Regards,
> Frank
Re: Figure position [message #177302 is a reply to message #177222] Fri, 14 March 2008 06:27 Go to previous message
Eclipse UserFriend
Originally posted by: rump.informatik-emden.de

Hi,

thanks for your answer. Your solution works fine, but I have different
shapes with different sizes. How can I find out in the getContraintFor
method which shape should be created by the command to calculate the
center position?

Regards,
Frank

Cherie Revells schrieb:
> Frank,
>
> When a new figure is created a SetBoundsCommand is executed to set the
> location of the figure. If you put a breakpoint in the SetBoundsCommand
> constructor and attempt to create your figure using the palette tool,
> you will see where this command is created, most likely from the
> XYLayoutEditPolicy.
>
> The method getConstraintFor(CreateRequest request) in the
> XYLayoutEditPolicy is where the mouse location set in the request gets
> translated to a location and size that will be passed to the
> SetBoundsCommand. You should be able to override this method in a
> custom editpolicy to use the mouse location as the center of the shpae
> instead.
>
> Regards,
> Cherie
>
> Frank Rump wrote:
>> Hi all,
>>
>> I am searching for a while but can't find an answer. When I create a
>> new figure on a diagram the mouse position is always the left upper
>> corner of the figure. But in my application the mouse position should
>> be the center of the figure. What do I have to do to change this
>> behaviour?
>>
>> Regards,
>> Frank
Previous Topic:Figure fills compartment
Next Topic:how can i catch double-clicks on nodes
Goto Forum:
  


Current Time: Mon Jun 09 04:13:44 EDT 2025

Powered by FUDForum. Page generated in 0.11140 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top