Skip to content

Commit 324e82e

Browse files
akoch-yattaptziegler
authored andcommitted
Fix PrecisionRectangle#getBottom inconsistency
The y value of PrecisionRectangle#getBottom can return a different y value to PrecisionRectangle#getBottomLeft and PrecisionRectangle#getBottomRight because the first uses the int values the later two use precision values. This commit adapt getBottom to use the precision values as well.
1 parent 06dda7d commit 324e82e

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

org.eclipse.draw2d.tests/src/org/eclipse/draw2d/test/PrecisionRectangleTest.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,4 +174,19 @@ public void testGetBottomRight() {
174174
assertEquals(rect.getBottomRight().y - rect.getTopLeft().y, rect.height);
175175
}
176176

177+
@SuppressWarnings("static-method")
178+
@Test
179+
public void testConsistencyGetBottom() {
180+
Rectangle rect = new PrecisionRectangle(100.5, 100.5, 250.5, 250.5);
181+
assertEquals(rect.getBottomRight().y, rect.getBottom().y);
182+
assertEquals(rect.getBottomLeft().y, rect.getBottom().y);
183+
}
184+
185+
@SuppressWarnings("static-method")
186+
@Test
187+
public void testConsistencyGetTop() {
188+
Rectangle rect = new PrecisionRectangle(100.5, 100.5, 250.5, 250.5);
189+
assertEquals(rect.getTopRight().y, rect.getTop().y);
190+
assertEquals(rect.getTopLeft().y, rect.getTop().y);
191+
}
177192
}

org.eclipse.draw2d/src/org/eclipse/draw2d/geometry/PrecisionRectangle.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ private PrecisionRectangle expandPrecise(double h, double v) {
225225
*/
226226
@Override
227227
public Point getBottom() {
228-
return new PrecisionPoint(preciseX() + preciseWidth() / 2, bottom());
228+
return new PrecisionPoint(preciseX() + preciseWidth() / 2, preciseY() + preciseHeight());
229229
}
230230

231231
/**

0 commit comments

Comments
 (0)