diff --git a/bundles/org.eclipse.swt/Eclipse SWT Tests/win32/org/eclipse/swt/widgets/ControlWin32Tests.java b/bundles/org.eclipse.swt/Eclipse SWT Tests/win32/org/eclipse/swt/widgets/ControlWin32Tests.java
index 759580dc17b..7926fb9e16c 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT Tests/win32/org/eclipse/swt/widgets/ControlWin32Tests.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT Tests/win32/org/eclipse/swt/widgets/ControlWin32Tests.java
@@ -100,11 +100,11 @@ public void testCorrectScaleUpUsingDifferentSetBoundsMethod() {
button.setBounds(new Rectangle(0, 47, 200, 47));
assertEquals("Control::setBounds(Rectangle) doesn't scale up correctly",
- new Rectangle(0, 82, 350, 82), button.getBoundsInPixels());
+ new Rectangle(0, 82, 350, 83), button.getBoundsInPixels());
button.setBounds(0, 47, 200, 47);
assertEquals("Control::setBounds(int, int, int, int) doesn't scale up correctly",
- new Rectangle(0, 82, 350, 82), button.getBoundsInPixels());
+ new Rectangle(0, 82, 350, 83), button.getBoundsInPixels());
}
record FontComparison(int originalFontHeight, int currentFontHeight) {
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Tests/win32/org/eclipse/swt/widgets/CoordinateSystemMapperTests.java b/bundles/org.eclipse.swt/Eclipse SWT Tests/win32/org/eclipse/swt/widgets/CoordinateSystemMapperTests.java
index a4852735005..d2c8068877a 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT Tests/win32/org/eclipse/swt/widgets/CoordinateSystemMapperTests.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT Tests/win32/org/eclipse/swt/widgets/CoordinateSystemMapperTests.java
@@ -137,7 +137,7 @@ void translateRectangleInGapPartiallyInRightBackAndForthInSingleZoomShouldBeTheS
void translateRectangleInGapPartiallyInRightBackAndForthInMultiZoomShouldBeInside() {
MultiZoomCoordinateSystemMapper mapper = getMultiZoomCoordinateSystemMapper();
setupMonitors(mapper);
- Rectangle rectInPts = new Rectangle.WithMonitor(1950, 400, 150, 100, monitors[1]);
+ Rectangle rectInPts = new MonitorAwareRectangle(1950, 400, 150, 100, monitors[1]);
Rectangle rectInPxs = mapper.translateToDisplayCoordinates(rectInPts, monitors[0].getZoom());
assertEquals(rectInPts, mapper.translateFromDisplayCoordinates(rectInPxs, monitors[0].getZoom()));
}
@@ -223,7 +223,7 @@ private Point createExpectedPoint(CoordinateSystemMapper mapper, int x, int y, M
if (mapper instanceof SingleZoomCoordinateSystemMapper) {
return new Point(x, y);
} else {
- return new Point.WithMonitor(x, y, monitor);
+ return new MonitorAwarePoint(x, y, monitor);
}
}
@@ -231,7 +231,7 @@ private Rectangle createExpectedRectangle(CoordinateSystemMapper mapper, int x,
if (mapper instanceof SingleZoomCoordinateSystemMapper) {
return new Rectangle(x, y, width, height);
} else {
- return new Rectangle.WithMonitor(x, y, width, height, monitor);
+ return new MonitorAwareRectangle(x, y, width, height, monitor);
}
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/graphics/MonitorAwarePoint.java b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/graphics/MonitorAwarePoint.java
new file mode 100644
index 00000000000..5e73e051e69
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/graphics/MonitorAwarePoint.java
@@ -0,0 +1,62 @@
+/*******************************************************************************
+ * Copyright (c) 2025 Yatta Solutions and others.
+ *
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ * Yatta Solutions - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.graphics;
+
+import org.eclipse.swt.widgets.*;
+
+/**
+ * Instances of this class represent {@link org.eclipse.swt.graphics.Point}
+ * objects along with the context of the monitor in relation to which they are
+ * placed on the display. The monitor awareness makes it easy to scale and
+ * translate the points between pixels and points.
+ *
+ * @since 3.129
+ * @noreference This class is not intended to be referenced by clients
+ */
+public final class MonitorAwarePoint extends Point {
+
+ private static final long serialVersionUID = 6077427420686999194L;
+
+ private final Monitor monitor;
+
+ /**
+ * Constructs a new MonitorAwarePoint
+ *
+ * @param x the x coordinate of the point
+ * @param y the y coordinate of the point
+ * @param monitor the monitor with whose context the point is created
+ */
+ public MonitorAwarePoint(int x, int y, Monitor monitor) {
+ super(x, y);
+ this.monitor = monitor;
+ }
+
+ /**
+ * {@return the monitor with whose context the instance is created}
+ */
+ public Monitor getMonitor() {
+ return monitor;
+ }
+
+ @Override
+ public boolean equals(Object object) {
+ return super.equals(object);
+ }
+
+ @Override
+ public int hashCode() {
+ return super.hashCode();
+ }
+
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/graphics/MonitorAwareRectangle.java b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/graphics/MonitorAwareRectangle.java
new file mode 100644
index 00000000000..ea0597621c3
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/graphics/MonitorAwareRectangle.java
@@ -0,0 +1,69 @@
+/*******************************************************************************
+ * Copyright (c) 2025 Yatta Solutions and others.
+ *
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ * Yatta Solutions - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.graphics;
+
+import org.eclipse.swt.widgets.*;
+
+/**
+ * Instances of this class represent {@link org.eclipse.swt.graphics.Rectangle}
+ * objects along with the context of the monitor in relation to which they are
+ * placed on the display. The monitor awareness makes it easy to scale and
+ * translate the rectangles between pixels and points.
+ *
+ * @since 3.129
+ * @noreference This class is not intended to be referenced by clients
+ */
+public final class MonitorAwareRectangle extends Rectangle {
+
+ private static final long serialVersionUID = 5041911840525116925L;
+
+ private final Monitor monitor;
+
+ /**
+ * Constructs a new MonitorAwareRectangle
+ *
+ * @param x the x coordinate of the top left corner of the rectangle
+ * @param y the y coordinate of the top left corner of the rectangle
+ * @param width the width of the rectangle
+ * @param height the height of the rectangle
+ * @param monitor the monitor with whose context the rectangle is created
+ */
+ public MonitorAwareRectangle(int x, int y, int width, int height, Monitor monitor) {
+ super(x, y, width, height);
+ this.monitor = monitor;
+ }
+
+ /**
+ * {@return the monitor with whose context the instance is created}
+ */
+ public Monitor getMonitor() {
+ return monitor;
+ }
+
+ @Override
+ public boolean equals(Object object) {
+ return super.equals(object);
+ }
+
+ @Override
+ public int hashCode() {
+ return super.hashCode();
+ }
+
+ @Override
+ public MonitorAwareRectangle clone() {
+ return new MonitorAwareRectangle(x, y, width, height, monitor);
+ }
+
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/graphics/Point.java b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/graphics/Point.java
index b1a026ca92c..2aef2d06820 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/graphics/Point.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/graphics/Point.java
@@ -16,8 +16,6 @@
import java.io.*;
-import org.eclipse.swt.widgets.*;
-
/**
* Instances of this class represent places on the (x, y)
* coordinate plane.
@@ -43,7 +41,7 @@
* @see Sample code and further information
*/
-public sealed class Point implements Serializable permits Point.OfFloat {
+public sealed class Point implements Serializable permits MonitorAwarePoint {
/**
* the x coordinate of the point
@@ -118,82 +116,5 @@ public String toString () {
return "Point {" + x + ", " + y + "}"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
}
-/**
- * Instances of this class represent {@link org.eclipse.swt.graphics.Point}
- * objects with the fields capable of storing more precise value in float.
- *
- * @since 3.131
- * @noreference This class is not intended to be referenced by clients
- */
-public static sealed class OfFloat extends Point permits Point.WithMonitor {
-
- private static final long serialVersionUID = -1862062276431597053L;
-
- public float residualX, residualY;
-
- public OfFloat(int x, int y) {
- super(x, y);
- }
-
- public OfFloat(float x, float y) {
- super(Math.round(x), Math.round(y));
- this.residualX = x - this.x;
- this.residualY = y - this.y;
- }
-
- public float getX() {
- return x + residualX;
- }
-
- public float getY() {
- return y + residualY;
- }
-
- public void setX(float x) {
- this.x = Math.round(x);
- this.residualX = x - this.x;
- }
-
- public void setY(float y) {
- this.y = Math.round(y);
- this.residualY = y - this.y;
- }
}
-/**
- * Instances of this class represent {@link org.eclipse.swt.graphics.Point.OfFloat}
- * objects along with the context of the monitor in relation to which they are
- * placed on the display. The monitor awareness makes it easy to scale and
- * translate the points between pixels and points.
- *
- * @since 3.131
- * @noreference This class is not intended to be referenced by clients
- */
-public static final class WithMonitor extends Point.OfFloat {
-
- private static final long serialVersionUID = 6077427420686999194L;
-
- private final Monitor monitor;
-
- /**
- * Constructs a new Point.WithMonitor
- *
- * @param x the x coordinate of the point
- * @param y the y coordinate of the point
- * @param monitor the monitor with whose context the point is created
- */
- public WithMonitor(int x, int y, Monitor monitor) {
- super(x, y);
- this.monitor = monitor;
- }
-
- /**
- * {@return the monitor with whose context the instance is created}
- */
- public Monitor getMonitor() {
- return monitor;
- }
-
-}
-
-}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/graphics/Rectangle.java b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/graphics/Rectangle.java
index 935f61e9e6e..b50cb13e6ac 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/graphics/Rectangle.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/graphics/Rectangle.java
@@ -17,7 +17,6 @@
import java.io.*;
import org.eclipse.swt.*;
-import org.eclipse.swt.widgets.*;
/**
* Instances of this class represent rectangular areas in an
@@ -46,7 +45,7 @@
* @see Sample code and further information
*/
-public sealed class Rectangle implements Serializable, Cloneable permits Rectangle.OfFloat {
+public sealed class Rectangle implements Serializable, Cloneable permits MonitorAwareRectangle {
/**
* the x coordinate of the rectangle
@@ -374,8 +373,8 @@ public Rectangle union (Rectangle rect) {
* @since 3.131
*/
public static Rectangle of(Point topLeft, int width, int height) {
- if (topLeft instanceof Point.WithMonitor monitorAwareTopLeft) {
- return new Rectangle.WithMonitor(monitorAwareTopLeft.getX(), monitorAwareTopLeft.getY(), width, height, monitorAwareTopLeft.getMonitor());
+ if (topLeft instanceof MonitorAwarePoint monitorAwareTopLeft) {
+ return new MonitorAwareRectangle(topLeft.x, topLeft.y, width, height, monitorAwareTopLeft.getMonitor());
}
return new Rectangle(topLeft.x, topLeft.y, width, height);
}
@@ -397,115 +396,4 @@ public static Rectangle of(Point topLeft, int width, int height) {
public Rectangle clone() {
return new Rectangle(x, y, width, height);
}
-
-/**
- * Instances of this class represent {@link org.eclipse.swt.graphics.Rectangle}
- * objects which supports values of Float type for it's fields
- *
- * @since 3.131
- * @noreference This class is not intended to be referenced by clients
- */
-public static sealed class OfFloat extends Rectangle permits Rectangle.WithMonitor {
-
- private static final long serialVersionUID = -3006999002677468391L;
-
- private float residualX, residualY, residualWidth, residualHeight;
-
- public OfFloat(int x, int y, int width, int height) {
- super(x, y, width, height);
- }
-
- public OfFloat(float x, float y, float width, float height) {
- super(Math.round(x), Math.round(y), Math.round(width), Math.round(height));
- this.residualX = x - this.x;
- this.residualY = y - this.y;
- this.residualWidth = width - this.width;
- this.residualHeight = height - this.height;
- }
-
- public float getX() {
- return x + residualX;
- }
-
- public float getY() {
- return y + residualY;
- }
-
- public float getWidth() {
- return width + residualWidth;
- }
-
- public float getHeight() {
- return height + residualHeight;
- }
-
- public void setX(float x) {
- this.x = Math.round(x);
- this.residualX = x - this.x;
- }
-
- public void setY(float y) {
- this.y = Math.round(y);
- this.residualY = y - this.y;
- }
-
- public void setWidth(float width) {
- this.width = Math.round(width);
- this.residualWidth = width - this.width;
- }
-
- public void setHeight(float height) {
- this.height = Math.round(height);
- this.residualHeight = height - this.height;
- }
-
-}
-
-/**
- * Instances of this class represent {@link org.eclipse.swt.graphics.Rectangle.OfFloat}
- * objects along with the context of the monitor in relation to which they are
- * placed on the display. The monitor awareness makes it easy to scale and
- * translate the rectangles between pixels and points.
- *
- * @since 3.131
- * @noreference This class is not intended to be referenced by clients
- */
-public static final class WithMonitor extends Rectangle.OfFloat {
-
- private static final long serialVersionUID = 5041911840525116925L;
-
- private final Monitor monitor;
-
- /**
- * Constructs a new Rectangle.WithMonitor
- *
- * @param x the x coordinate of the top left corner of the rectangle
- * @param y the y coordinate of the top left corner of the rectangle
- * @param width the width of the rectangle
- * @param height the height of the rectangle
- * @param monitor the monitor with whose context the rectangle is created
- */
- public WithMonitor(int x, int y, int width, int height, Monitor monitor) {
- super(x, y, width, height);
- this.monitor = monitor;
- }
-
- private WithMonitor(float x, float y, float width, float height, Monitor monitor) {
- super(x, y, width, height);
- this.monitor = monitor;
- }
-
- /**
- * {@return the monitor with whose context the instance is created}
- */
- public Monitor getMonitor() {
- return monitor;
- }
-
- @Override
- public Rectangle.WithMonitor clone() {
- return new Rectangle.WithMonitor(getX(), getY(), getWidth(), getHeight(), monitor);
- }
-
}
-}
\ No newline at end of file
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/DPIUtil.java b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/DPIUtil.java
index 0f7e475ebe5..a15f4683ae3 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/DPIUtil.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/DPIUtil.java
@@ -228,11 +228,11 @@ public static Point autoScaleDown(Point point) {
public static Point scaleDown(Point point, int zoom) {
if (zoom == 100 || point == null) return point;
- Point.OfFloat fPoint = FloatAwareGeometryFactory.createFrom(point);
float scaleFactor = getScalingFactor(zoom);
- float scaledX = fPoint.getX() / scaleFactor;
- float scaledY = fPoint.getY() / scaleFactor;
- return new Point.OfFloat(scaledX, scaledY);
+ Point scaledPoint = new Point (0,0);
+ scaledPoint.x = Math.round (point.x / scaleFactor);
+ scaledPoint.y = Math.round (point.y / scaleFactor);
+ return scaledPoint;
}
/**
@@ -255,7 +255,16 @@ public static Rectangle autoScaleDown(Rectangle rect) {
}
public static Rectangle scaleDown(Rectangle rect, int zoom) {
- return scaleBounds(rect, 100, zoom);
+ if (zoom == 100 || rect == null) return rect;
+ Rectangle scaledRect = new Rectangle (0,0,0,0);
+ Point scaledTopLeft = scaleDown(new Point (rect.x, rect.y), zoom);
+ Point scaledBottomRight = scaleDown(new Point (rect.x + rect.width, rect.y + rect.height), zoom);
+
+ scaledRect.x = scaledTopLeft.x;
+ scaledRect.y = scaledTopLeft.y;
+ scaledRect.width = scaledBottomRight.x - scaledTopLeft.x;
+ scaledRect.height = scaledBottomRight.y - scaledTopLeft.y;
+ return scaledRect;
}
/**
* Returns a new scaled down Rectangle if enabled for Drawable class.
@@ -324,13 +333,13 @@ public static boolean isSmoothScalingEnabled() {
*/
public static Rectangle scaleBounds (Rectangle rect, int targetZoom, int currentZoom) {
if (rect == null || targetZoom == currentZoom) return rect;
- Rectangle.OfFloat fRect = FloatAwareGeometryFactory.createFrom(rect);
float scaleFactor = ((float)targetZoom) / (float)currentZoom;
- float scaledX = fRect.getX() * scaleFactor;
- float scaledY = fRect.getY() * scaleFactor;
- float scaledWidth = fRect.getWidth() * scaleFactor;
- float scaledHeight = fRect.getHeight() * scaleFactor;
- return new Rectangle.OfFloat(scaledX, scaledY, scaledWidth, scaledHeight);
+ Rectangle returnRect = new Rectangle (0,0,0,0);
+ returnRect.x = Math.round (rect.x * scaleFactor);
+ returnRect.y = Math.round (rect.y * scaleFactor);
+ returnRect.width = Math.round (rect.width * scaleFactor);
+ returnRect.height = Math.round (rect.height * scaleFactor);
+ return returnRect;
}
/**
@@ -427,11 +436,11 @@ public static Point autoScaleUp(Point point) {
public static Point scaleUp(Point point, int zoom) {
if (zoom == 100 || point == null) return point;
- Point.OfFloat fPoint = FloatAwareGeometryFactory.createFrom(point);
float scaleFactor = getScalingFactor(zoom);
- float scaledX = fPoint.getX() * scaleFactor;
- float scaledY = fPoint.getY() * scaleFactor;
- return new Point.OfFloat(scaledX, scaledY);
+ Point scaledPoint = new Point(0,0);
+ scaledPoint.x = Math.round (point.x * scaleFactor);
+ scaledPoint.y = Math.round (point.y * scaleFactor);
+ return scaledPoint;
}
/**
@@ -454,7 +463,16 @@ public static Rectangle autoScaleUp(Rectangle rect) {
}
public static Rectangle scaleUp(Rectangle rect, int zoom) {
- return scaleBounds(rect, zoom, 100);
+ if (zoom == 100 || rect == null) return rect;
+ Rectangle scaledRect = new Rectangle(0,0,0,0);
+ Point scaledTopLeft = scaleUp (new Point(rect.x, rect.y), zoom);
+ Point scaledBottomRight = scaleUp (new Point(rect.x + rect.width, rect.y + rect.height), zoom);
+
+ scaledRect.x = scaledTopLeft.x;
+ scaledRect.y = scaledTopLeft.y;
+ scaledRect.width = scaledBottomRight.x - scaledTopLeft.x;
+ scaledRect.height = scaledBottomRight.y - scaledTopLeft.y;
+ return scaledRect;
}
/**
@@ -733,20 +751,4 @@ public ImageData getImageData(int zoom) {
return DPIUtil.scaleImageData(device, imageData, zoom, currentZoom);
}
}
-
-private class FloatAwareGeometryFactory {
- static Rectangle.OfFloat createFrom(Rectangle rectangle) {
- if (rectangle instanceof Rectangle.OfFloat) {
- return (Rectangle.OfFloat) rectangle;
- }
- return new Rectangle.OfFloat(rectangle.x, rectangle.y, rectangle.width, rectangle.height);
- }
-
- static Point.OfFloat createFrom(Point point) {
- if (point instanceof Point.OfFloat) {
- return (Point.OfFloat) point;
- }
- return new Point.OfFloat(point.x, point.y);
- }
-}
}
\ No newline at end of file
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/MultiZoomCoordinateSystemMapper.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/MultiZoomCoordinateSystemMapper.java
index 80347e36e19..886a47701e3 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/MultiZoomCoordinateSystemMapper.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/MultiZoomCoordinateSystemMapper.java
@@ -98,19 +98,19 @@ public Point translateFromDisplayCoordinates(Point point, int zoom) {
@Override
public Point translateToDisplayCoordinates(Point point, int zoom) {
- Monitor monitor = point instanceof Point.WithMonitor pointWithMonitor ? pointWithMonitor.getMonitor() : null;
+ Monitor monitor = point instanceof MonitorAwarePoint monitorAwarePoint ? monitorAwarePoint.getMonitor() : null;
return translateLocationInPointsToPixels(point.x, point.y, monitor);
}
@Override
public Rectangle translateFromDisplayCoordinates(Rectangle rect, int zoom) {
- Monitor monitor = rect instanceof Rectangle.WithMonitor rectWithMonitor ? rectWithMonitor.getMonitor() : null;
+ Monitor monitor = rect instanceof MonitorAwareRectangle monitorAwareRect ? monitorAwareRect.getMonitor() : null;
return translateRectangleInPixelsToPoints(rect.x, rect.y, rect.width, rect.height, monitor);
}
@Override
public Rectangle translateToDisplayCoordinates(Rectangle rect, int zoom) {
- Monitor monitor = rect instanceof Rectangle.WithMonitor rectWithMonitor ? rectWithMonitor.getMonitor() : null;
+ Monitor monitor = rect instanceof MonitorAwareRectangle monitorAwareRect ? monitorAwareRect.getMonitor() : null;
return translateRectangleInPointsToPixels(rect.x, rect.y, rect.width, rect.height, monitor);
}
@@ -152,7 +152,7 @@ private Rectangle translateRectangleInPixelsToPoints(int x, int y, int widthInPi
Point topLeft = getPointFromPixels(monitor, x, y);
int width = DPIUtil.scaleDown(widthInPixels, zoom);
int height = DPIUtil.scaleDown(heightInPixels, zoom);
- Rectangle.WithMonitor rect = new Rectangle.WithMonitor(topLeft.x, topLeft.y, width, height, monitor);
+ MonitorAwareRectangle rect = new MonitorAwareRectangle(topLeft.x, topLeft.y, width, height, monitor);
return rect;
}
@@ -264,7 +264,7 @@ private Point getPointFromPixels(Monitor monitor, int x, int y) {
int zoom = getApplicableMonitorZoom(monitor);
int mappedX = DPIUtil.scaleDown(x - monitor.clientX, zoom) + monitor.clientX;
int mappedY = DPIUtil.scaleDown(y - monitor.clientY, zoom) + monitor.clientY;
- return new Point.WithMonitor(mappedX, mappedY, monitor);
+ return new MonitorAwarePoint(mappedX, mappedY, monitor);
}
private int getApplicableMonitorZoom(Monitor monitor) {
@@ -273,7 +273,7 @@ private int getApplicableMonitorZoom(Monitor monitor) {
@Override
public Rectangle getContainingMonitorBoundsInPixels(Point point) {
- Monitor monitor = point instanceof Point.WithMonitor monitorAwarePoint ? monitorAwarePoint.getMonitor()
+ Monitor monitor = point instanceof MonitorAwarePoint monitorAwarePoint ? monitorAwarePoint.getMonitor()
: getContainingMonitorForPoints(point.x, point.y);
return getMonitorClientAreaInPixels(monitor);
}
diff --git a/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/DPIUtilTests.java b/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/DPIUtilTests.java
index 316e8f9da17..d501c4d0a67 100644
--- a/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/DPIUtilTests.java
+++ b/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/DPIUtilTests.java
@@ -319,40 +319,4 @@ public void scaleUpRectangle() {
scaledValue = DPIUtil.scaleUp((Device) null, valueAt100, 100);
assertSame(valueAt100, scaledValue, "Scaling up Rectangle without zoom change with device failed");
}
-
- @Test
- public void scaleDownscaleUpRectangleInvertible() {
- int[] zooms = new int[] {25, 50, 75, 100, 125, 150, 175, 200, 225, 250, 275, 300, 325, 350, 375, 400};
- for (int zoom1 : zooms) {
- for (int zoom2 : zooms) {
- for (int i = 1; i <= 10000; i++) {
- Rectangle rect = new Rectangle(0, 0, i, i);
- Rectangle scaleDown = DPIUtil.scaleDown(rect, zoom1);
- Rectangle scaleUp = DPIUtil.scaleUp(scaleDown, zoom2);
- scaleDown = DPIUtil.scaleDown(scaleUp, zoom2);
- scaleUp = DPIUtil.scaleUp(scaleDown, zoom1);
- assertEquals(rect.width, scaleUp.width);
- assertEquals(rect.height, scaleUp.height);
- }
- }
- }
- }
-
- @Test
- public void scaleDownscaleUpPointInvertible() {
- int[] zooms = new int[] {25, 50, 75, 100, 125, 150, 175, 200, 225, 250, 275, 300, 325, 350, 375, 400};
- for (int zoom1 : zooms) {
- for (int zoom2 : zooms) {
- for (int i = 1; i <= 10000; i++) {
- Point pt = new Point(i, i);
- Point scaleDown = DPIUtil.scaleDown(pt, zoom1);
- Point scaleUp = DPIUtil.scaleUp(scaleDown, zoom2);
- scaleDown = DPIUtil.scaleDown(scaleUp, zoom2);
- scaleUp = DPIUtil.scaleUp(scaleDown, zoom1);
- assertEquals(pt.x, scaleUp.x);
- assertEquals(pt.y, scaleUp.y);
- }
- }
- }
- }
}