Eclipse GEF/draw2d Coordinate System Transformation

951 Views Asked by At

Can someone please explain to me how coordinate transformations work in draw2d? I have a hierarchical diagram where a figure can contain figures which also contain figures. At first I added internal figures by using the request's getLocation, fetching the host figure of the EditPolicy and appliying hostFigure.translateToRelative(location) but does not work! neither combinations of translateToParent and other things.

At the end I copied the implementation from the Logic example, which uses getConstraintFor, a method provided by the policy which does the translation itself. I checked this could but also could not understand how it works.

I read in a number of threads in the eclipse forums on this subject, but still don't understand why a simple method like translateToAbsolute does not behave as expected. Could anyone please explan? Thanks

1

There are 1 best solutions below

0
On BEST ANSWER

Two pieces of information that might shed some light on your problem:

  1. Depending on the request type I would expect the location to already be in absolute coordinates.
  2. Unless explicitly implemented otherwise, Figures don't have a local coordinate system for their children. So converting a location up and down the Figure hierarchy does not necessarily change the coordinates.