Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Graphiti » How to limit the movement of shapes(MoveFeature)
How to limit the movement of shapes [message #1775204] Thu, 26 October 2017 09:06 Go to next message
xi yahui is currently offline xi yahuiFriend
Messages: 32
Registered: October 2017
Member
I hope the shapes can only move up or down. That is, the shapes can't move left or right. What should I do?
Re: How to limit the movement of shapes [message #1775273 is a reply to message #1775204] Fri, 27 October 2017 06:34 Go to previous messageGo to next message
Michael Wenz is currently offline Michael WenzFriend
Messages: 1899
Registered: July 2009
Location: Walldorf, Germany
Senior Member
Sorry, but I cannot really help based on that scarce information. Shapes can move in all directions, but you may restrict their movement options by providing your own move feature.

Michael
Re: How to limit the movement of shapes [message #1775292 is a reply to message #1775273] Fri, 27 October 2017 09:41 Go to previous messageGo to next message
xi yahui is currently offline xi yahuiFriend
Messages: 32
Registered: October 2017
Member
When I move the shape, there is a float shape. When I release the mouse, the real shape will move to the location. I hope the shape and float shape only move up or down. That is to say, only the Y coordinates of the shape can be changed. But the moveShape method of DefaultMoveShapeFeature is invoked after releasing the mouse.
I write the code in the moveShape method:
int x=context.getX();
int deltax=context.getDeltaX();
((MoveShapeContext)context).setX(x-deltax);
((MoveShapeContext)context).setDeltaX(0);
super.moveShape(context);

So, the shape is limited. But how to limit the float shape?

index.php/fa/31157/0/
  • Attachment: pic.png
    (Size: 12.13KB, Downloaded 107 times)

[Updated on: Fri, 27 October 2017 09:57]

Report message to a moderator

Re: How to limit the movement of shapes [message #1775302 is a reply to message #1775292] Fri, 27 October 2017 11:53 Go to previous messageGo to next message
Michael Wenz is currently offline Michael WenzFriend
Messages: 1899
Registered: July 2009
Location: Walldorf, Germany
Senior Member
The position of the float shape will simply follow the mouse pointer, there is no way to influence that. What you could do is override canMoveShape and return false in case the user tries to drag the shape to an invalid place; you could for example allow a corridor of +/- 10 pixels wher you allow the drop. Or you simply change the x coordinate back to the original value in moveShape.

HTH,
Michael
Re: How to limit the movement of shapes [message #1775316 is a reply to message #1775302] Fri, 27 October 2017 14:23 Go to previous message
xi yahui is currently offline xi yahuiFriend
Messages: 32
Registered: October 2017
Member
Thanks Michael
Previous Topic:Problems saving diagram to image
Next Topic:Direct Editing
Goto Forum:
  


Current Time: Mon Nov 19 01:51:18 GMT 2018

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

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

Back to the top