Skip to content

Commit 7716e11

Browse files
committed
Only use double-precision translation when HighDPI scaling is enabled
When the "draw2d.enableAutoscale" system property is enabled, additional (scalable) layers are injected into the IFigure hierarchy to take the monitor zoom into consideration. As a result of this, translating geometric shapes may cause additional rounding errors, which are the result of translating integer-values with an additional, fractional zoom level. To work around this problem, the "useDoublePrecision()" method was added with 5cfe5b7, which converts the geometric shapes to their precise variants. This conversion is generally not backwards compatible. To make sure clients can fully opt-out of this new behavior, this conversion should only be done when the "draw2d.enableAutoscale" is set to true, meaning only when these new layers are added, that require this extended translation logic.
1 parent 88b83cf commit 7716e11

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

org.eclipse.draw2d/src/org/eclipse/draw2d/ScalableFreeformLayeredPane.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
import org.eclipse.draw2d.geometry.Rectangle;
1616
import org.eclipse.draw2d.geometry.Translatable;
17+
import org.eclipse.draw2d.internal.InternalDraw2dUtils;
1718

1819
/**
1920
* @author hudsonr
@@ -120,6 +121,6 @@ public void translateFromParent(Translatable t) {
120121
*/
121122
@Override
122123
protected boolean useDoublePrecision() {
123-
return true;
124+
return InternalDraw2dUtils.isAutoScaleEnabled();
124125
}
125126
}

org.eclipse.draw2d/src/org/eclipse/draw2d/ScalableLayeredPane.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import org.eclipse.draw2d.geometry.Dimension;
1616
import org.eclipse.draw2d.geometry.Rectangle;
1717
import org.eclipse.draw2d.geometry.Translatable;
18+
import org.eclipse.draw2d.internal.InternalDraw2dUtils;
1819

1920
/**
2021
* A non-freeform, scalable layered pane.
@@ -133,7 +134,7 @@ public boolean isCoordinateSystem() {
133134
*/
134135
@Override
135136
protected boolean useDoublePrecision() {
136-
return true;
137+
return InternalDraw2dUtils.isAutoScaleEnabled();
137138
}
138139

139140
}

0 commit comments

Comments
 (0)