Avoid shapes dragging into -ve X&Y axes [message #226366] |
Fri, 10 November 2006 06:20 |
Eclipse User |
|
|
|
Originally posted by: siddharth.star.gmail.com
I have a graphical editor on which a lot many shapes can be dragged and
dropped.
I wish to somehow ensure that these shapes cannot be dragged into negative
x and y co-ordinates.
The parent of the root edit part is ScalableRootEditPart
The figure associated with the edit part of may parent model is
Figure figure = new Layer();
figure.setBorder(new MarginBorder(3));
figure.setLayoutManager(new XYLayout());
The patchy way I have done it right now is to put a hack in the
refreshVisuals() of my shape edit part where in i have done this
Rectangle bounds = new Rectangle(getCastedModel().getLocation(),
getCastedModel().getSize());
if(bounds.x < 0) {
bounds.x = 0;
getCastedModel().setLocation(new Point(0, bounds.y));
}
if(bounds.y < 0) {
bounds.y = 0;
getCastedModel().setLocation(new Point(bounds.x, 0));
}
((GraphicalEditPart) getParent()).setLayoutConstraint(this,
getFigure(), bounds);
I do not like this way to do it and am sure there would be a better GEF
way to address this. Please let me know the proper way to do it
Thanks in Advance,
Siddharth
|
|
|
Powered by
FUDForum. Page generated in 0.03096 seconds