Skip to main content



      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 05:06 Go to next message
Eclipse UserFriend
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 02:34 Go to previous messageGo to next message
Eclipse UserFriend
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 05:41 Go to previous messageGo to next message
Eclipse UserFriend
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 414 times)

[Updated on: Fri, 27 October 2017 05:57] by Moderator

Re: How to limit the movement of shapes [message #1775302 is a reply to message #1775292] Fri, 27 October 2017 07:53 Go to previous messageGo to next message
Eclipse UserFriend
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 10:23 Go to previous message
Eclipse UserFriend
Thanks Michael
Previous Topic:Problems saving diagram to image
Next Topic:Direct Editing
Goto Forum:
  


Current Time: Wed Mar 19 03:35:27 EDT 2025

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

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

Back to the top