Skip to content
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 @@ -3,7 +3,7 @@ Fragment-Host: org.eclipse.swt;bundle-version="[3.128.0,4.0.0)"
Bundle-Name: %fragmentName
Bundle-Vendor: %providerName
Bundle-SymbolicName: org.eclipse.swt.cocoa.macosx.aarch64; singleton:=true
Bundle-Version: 3.131.100.qualifier
Bundle-Version: 3.132.0.qualifier
Bundle-ManifestVersion: 2
Bundle-Localization: fragment
Export-Package:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Fragment-Host: org.eclipse.swt;bundle-version="[3.128.0,4.0.0)"
Bundle-Name: %fragmentName
Bundle-Vendor: %providerName
Bundle-SymbolicName: org.eclipse.swt.cocoa.macosx.x86_64; singleton:=true
Bundle-Version: 3.131.100.qualifier
Bundle-Version: 3.132.0.qualifier
Bundle-ManifestVersion: 2
Bundle-Localization: fragment
Export-Package:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Fragment-Host: org.eclipse.swt;bundle-version="[3.128.0,4.0.0)"
Bundle-Name: %fragmentName
Bundle-Vendor: %providerName
Bundle-SymbolicName: org.eclipse.swt.gtk.linux.aarch64; singleton:=true
Bundle-Version: 3.131.100.qualifier
Bundle-Version: 3.132.0.qualifier
Bundle-ManifestVersion: 2
Bundle-Localization: fragment
Export-Package:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Fragment-Host: org.eclipse.swt;bundle-version="[3.128.0,4.0.0)"
Bundle-Name: %fragmentName
Bundle-Vendor: %providerName
Bundle-SymbolicName: org.eclipse.swt.gtk.linux.loongarch64; singleton:=true
Bundle-Version: 3.131.0.qualifier
Bundle-Version: 3.132.0.qualifier
Bundle-ManifestVersion: 2
Bundle-Localization: fragment
Export-Package:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Fragment-Host: org.eclipse.swt;bundle-version="[3.128.0,4.0.0)"
Bundle-Name: %fragmentName
Bundle-Vendor: %providerName
Bundle-SymbolicName: org.eclipse.swt.gtk.linux.ppc64le;singleton:=true
Bundle-Version: 3.131.100.qualifier
Bundle-Version: 3.132.0.qualifier
Bundle-ManifestVersion: 2
Bundle-Localization: fragment
Export-Package:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Fragment-Host: org.eclipse.swt;bundle-version="[3.128.0,4.0.0)"
Bundle-Name: %fragmentName
Bundle-Vendor: %providerName
Bundle-SymbolicName: org.eclipse.swt.gtk.linux.riscv64; singleton:=true
Bundle-Version: 3.131.100.qualifier
Bundle-Version: 3.132.0.qualifier
Bundle-ManifestVersion: 2
Bundle-Localization: fragment
Export-Package:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Fragment-Host: org.eclipse.swt;bundle-version="[3.128.0,4.0.0)"
Bundle-Name: %fragmentName
Bundle-Vendor: %providerName
Bundle-SymbolicName: org.eclipse.swt.gtk.linux.x86_64; singleton:=true
Bundle-Version: 3.131.100.qualifier
Bundle-Version: 3.132.0.qualifier
Bundle-ManifestVersion: 2
Bundle-Localization: fragment
Export-Package:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Fragment-Host: org.eclipse.swt;bundle-version="[3.128.0,4.0.0)"
Bundle-Name: %fragmentName
Bundle-Vendor: %providerName
Bundle-SymbolicName: org.eclipse.swt.win32.win32.aarch64; singleton:=true
Bundle-Version: 3.131.100.qualifier
Bundle-Version: 3.132.0.qualifier
Bundle-ManifestVersion: 2
Bundle-Localization: fragment
Export-Package:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Fragment-Host: org.eclipse.swt;bundle-version="[3.128.0,4.0.0)"
Bundle-Name: %fragmentName
Bundle-Vendor: %providerName
Bundle-SymbolicName: org.eclipse.swt.win32.win32.x86_64; singleton:=true
Bundle-Version: 3.131.100.qualifier
Bundle-Version: 3.132.0.qualifier
Bundle-ManifestVersion: 2
Bundle-Localization: fragment
Export-Package:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,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, Cloneable permits Point.OfFloat {

/**
* the x coordinate of the point
Expand Down Expand Up @@ -118,6 +118,15 @@ public String toString () {
return "Point {" + x + ", " + y + "}"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
}

/**
* Creates and returns a shallow copy of this {@code Point}.
* @since 3.132
*/
@Override
public Point clone() {
return new Point(x, y);
}

/**
* Instances of this class represent {@link org.eclipse.swt.graphics.Point}
* objects with the fields capable of storing more precise value in float.
Expand Down Expand Up @@ -158,6 +167,21 @@ public void setY(float y) {
this.y = Math.round(y);
this.residualY = y - this.y;
}

@Override
public Point.OfFloat clone() {
return new Point.OfFloat(getX(), getY());
}

/**
* Creates a shallow copy of the provided point as a Point.OfFloat instance.
*/
public static Point.OfFloat from(Point point) {
if (point instanceof Point.OfFloat pointOfFloat) {
return pointOfFloat.clone();
}
return new Point.OfFloat(point.x, point.y);
}
}

/**
Expand Down Expand Up @@ -187,13 +211,22 @@ public WithMonitor(int x, int y, Monitor monitor) {
this.monitor = monitor;
}

private WithMonitor(float x, float 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 Point.WithMonitor clone() {
return new WithMonitor(getX(), getY(), monitor);
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -459,6 +459,21 @@ public void setHeight(float height) {
this.residualHeight = height - this.height;
}

@Override
public Rectangle.OfFloat clone() {
return new Rectangle.OfFloat(getX(), getY(), getWidth(), getHeight());
}

/**
* Creates a shallow copy of the provided Rectangle as a Rectangle.OfFloat instance.
*/
public static Rectangle.OfFloat from(Rectangle rectangle) {
if (rectangle instanceof Rectangle.OfFloat rectangleOfFloat) {
return rectangleOfFloat.clone();
}
return new Rectangle.OfFloat(rectangle.x, rectangle.y, rectangle.width, rectangle.height);
}

}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ public static float pixelToPoint(Drawable drawable, float size, int zoom) {

public static Point pixelToPoint(Point point, int zoom) {
if (zoom == 100 || point == null) return point;
Point.OfFloat fPoint = FloatAwareGeometryFactory.createFrom(point);
Point.OfFloat fPoint = Point.OfFloat.from(point);
float scaleFactor = DPIUtil.getScalingFactor(zoom);
float scaledX = fPoint.getX() / scaleFactor;
float scaledY = fPoint.getY() / scaleFactor;
Expand Down Expand Up @@ -170,7 +170,7 @@ public static Rectangle scaleBounds (Rectangle rect, int targetZoom, int current
*/
private static Rectangle scaleBounds (Rectangle.OfFloat rect, int targetZoom, int currentZoom) {
if (rect == null || targetZoom == currentZoom) return rect;
Rectangle.OfFloat fRect = FloatAwareGeometryFactory.createFrom(rect);
Rectangle.OfFloat fRect = Rectangle.OfFloat.from(rect);
float scaleFactor = DPIUtil.getScalingFactor(targetZoom, currentZoom);
float scaledX = fRect.getX() * scaleFactor;
float scaledY = fRect.getY() * scaleFactor;
Expand Down Expand Up @@ -221,7 +221,7 @@ public static float pointToPixel(Drawable drawable, float size, int zoom) {

public static Point pointToPixel(Point point, int zoom) {
if (zoom == 100 || point == null) return point;
Point.OfFloat fPoint = FloatAwareGeometryFactory.createFrom(point);
Point.OfFloat fPoint = Point.OfFloat.from(point);
float scaleFactor = DPIUtil.getScalingFactor(zoom);
float scaledX = fPoint.getX() * scaleFactor;
float scaledY = fPoint.getY() * scaleFactor;
Expand Down Expand Up @@ -330,20 +330,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);
}
}
}
Loading