Skip to content

Revert broken api #2264

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 25, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()));
}
Expand Down Expand Up @@ -223,15 +223,15 @@ 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);
}
}

private Rectangle createExpectedRectangle(CoordinateSystemMapper mapper, int x, int y, int width, int height, Monitor monitor) {
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);
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -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();
}

}
Original file line number Diff line number Diff line change
@@ -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);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@

import java.io.*;

import org.eclipse.swt.widgets.*;

/**
* Instances of this class represent places on the (x, y)
* coordinate plane.
Expand All @@ -43,7 +41,7 @@
* @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
*/

public sealed class Point implements Serializable permits Point.OfFloat {
public sealed class Point implements Serializable permits MonitorAwarePoint {

/**
* the x coordinate of the point
Expand Down Expand Up @@ -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;
}

}

}
Loading
Loading