Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » Avoid shapes dragging into -ve X&Y axes
Avoid shapes dragging into -ve X&Y axes [message #226366] Fri, 10 November 2006 06:20
Eclipse UserFriend
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
Previous Topic:why cannot i find Draw2D package in eclipse 3.2?
Next Topic:Scrollpane is not scrolling when polygon is added
Goto Forum:
  


Current Time: Thu Oct 28 14:43:00 GMT 2021

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

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

Back to the top