-
Notifications
You must be signed in to change notification settings - Fork 52
Description
Due to the limited implementation of the PrecisionPointList, the calculations on a wrapped PointList inside the Figure#translate...() calls may lead to wrong results. While this can effectively happen when using any non-overriden method of PrecisionPointList, it particularly happens for performTranslate(), which is called by Figure#translateToParent(), which calls that method:
gef-classic/org.eclipse.draw2d/src/org/eclipse/draw2d/Figure.java
Lines 2065 to 2069 in 5bfc6ee
| public void translateToParent(Translatable t) { | |
| if (useLocalCoordinates()) { | |
| t.performTranslate(getBounds().x + getInsets().left, getBounds().y + getInsets().top); | |
| } | |
| } |
The unexpected behavior can also be easily demonstrated with this test:
PointList list = new PointList();
list.addPoint(1, 1);
PrecisionPointList precisionList = new PrecisionPointList(list);
precisionList.performTranslate(1, 1);
precisionList.performScale(10);
assertEquals(20, precisionList.getFirstPoint().x);Would it maybe make sense to update the precise values from the integer values at the beginning of every overridden method in case both became inconsistent? The only alternative to avoid broken behavior seems to be to override every single method with either a proper precision implementation or at least one that updates the precise values after being executed. So as long as all those overrides do not exist, maybe it would be reasonable to just update the precision values at the beginning of those methods that are overriden, if necessary?