Compute absolute coordinates to store in the model [message #239747] |
Mon, 12 November 2007 08:10 |
Eclipse User |
|
|
|
Hallo,
I want to store only absolute coordinates in my model. Therefore I overrided
the translateToModelConstraint in my XYLayoutPolicy as follows:
@Override
protected Object translateToModelConstraint(Object figureConstraint) {
Rectangle constraint = ((Rectangle) figureConstraint).getCopy();
logger.info("called with constraint " + constraint);
// compute an absolute position
constraint = constraint.getTranslated(getLayoutOrigin());
logger.info("... translated by getLayoutOrigin: " + constraint);
getLayoutContainer().translateToAbsolute(constraint);
logger.info("... translated to absolute " + constraint);
return constraint;
}
Everything works fine, as long as the viewport of the GraphicalViewer does
not show scrolling bars. If it does, when I handle a Create or ChangeBounds
request, the translateToAbsolute on the layout container actually subtracts
the viewer's client area location instead of adding it (as I would expect
it). Is that a problem in Viewports translateToParent() method or am I using
it wrong? What could I do to always obtain the correct absolute position?
Regards,
Alexander
|
|
|
Powered by
FUDForum. Page generated in 0.04732 seconds