From 2576c31dc2d0dc69f72e8123d121c9e23e5e6f69 Mon Sep 17 00:00:00 2001 From: nlisker <37422899+nlisker@users.noreply.github.com> Date: Fri, 29 Nov 2024 18:53:16 +0200 Subject: [PATCH 1/2] Initial commit --- .../glass/ui/gtk/screencast/TokenItem.java | 13 ++--- .../glass/ui/gtk/screencast/TokenStorage.java | 19 +++---- .../main/java/com/sun/javafx/geom/Arc2D.java | 2 +- .../java/com/sun/javafx/geom/Dimension.java | 52 ------------------- .../java/com/sun/javafx/geom/Dimension2D.java | 16 +----- .../com/sun/javafx/geom/RectangularShape.java | 2 +- .../java/javafx/geometry/Dimension2D.java | 4 +- 7 files changed, 20 insertions(+), 88 deletions(-) delete mode 100644 modules/javafx.graphics/src/main/java/com/sun/javafx/geom/Dimension.java diff --git a/modules/javafx.graphics/src/main/java/com/sun/glass/ui/gtk/screencast/TokenItem.java b/modules/javafx.graphics/src/main/java/com/sun/glass/ui/gtk/screencast/TokenItem.java index 89fe11fd001..30e19b1a53b 100644 --- a/modules/javafx.graphics/src/main/java/com/sun/glass/ui/gtk/screencast/TokenItem.java +++ b/modules/javafx.graphics/src/main/java/com/sun/glass/ui/gtk/screencast/TokenItem.java @@ -25,15 +25,16 @@ package com.sun.glass.ui.gtk.screencast; -import com.sun.javafx.geom.Dimension; -import com.sun.javafx.geom.Rectangle; +import static com.sun.glass.ui.gtk.screencast.ScreencastHelper.SCREENCAST_DEBUG; + import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.stream.Collectors; import java.util.stream.IntStream; -import static com.sun.glass.ui.gtk.screencast.ScreencastHelper.SCREENCAST_DEBUG; +import com.sun.javafx.geom.Dimension2D; +import com.sun.javafx.geom.Rectangle; /** @@ -76,15 +77,15 @@ public boolean hasAllScreensWithExactMatch(List bounds) { return allowedScreensBounds.containsAll(bounds); } - public boolean hasAllScreensOfSameSize(List screenSizes) { + public boolean hasAllScreensOfSameSize(List screenSizes) { // We also need to consider duplicates, since there may be // multiple screens of the same size. // The token item must also have at least the same number // of screens with that size. - List tokenSizes = allowedScreensBounds + List tokenSizes = allowedScreensBounds .stream() - .map(bounds -> new Dimension(bounds.width, bounds.height)) + .map(bounds -> new Dimension2D(bounds.width, bounds.height)) .collect(Collectors.toCollection(ArrayList::new)); return screenSizes.size() == screenSizes diff --git a/modules/javafx.graphics/src/main/java/com/sun/glass/ui/gtk/screencast/TokenStorage.java b/modules/javafx.graphics/src/main/java/com/sun/glass/ui/gtk/screencast/TokenStorage.java index 84a2ce3aae1..f1881704b08 100644 --- a/modules/javafx.graphics/src/main/java/com/sun/glass/ui/gtk/screencast/TokenStorage.java +++ b/modules/javafx.graphics/src/main/java/com/sun/glass/ui/gtk/screencast/TokenStorage.java @@ -25,8 +25,9 @@ package com.sun.glass.ui.gtk.screencast; -import com.sun.javafx.geom.Dimension; -import com.sun.javafx.geom.Rectangle; +import static com.sun.glass.ui.gtk.screencast.ScreencastHelper.SCREENCAST_DEBUG; +import static java.nio.file.StandardWatchEventKinds.*; + import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.IOException; @@ -45,11 +46,8 @@ import java.util.Properties; import java.util.Set; -import static java.nio.file.StandardWatchEventKinds.ENTRY_CREATE; -import static java.nio.file.StandardWatchEventKinds.ENTRY_DELETE; -import static java.nio.file.StandardWatchEventKinds.ENTRY_MODIFY; -import static java.nio.file.StandardWatchEventKinds.OVERFLOW; -import static com.sun.glass.ui.gtk.screencast.ScreencastHelper.SCREENCAST_DEBUG; +import com.sun.javafx.geom.Dimension2D; +import com.sun.javafx.geom.Rectangle; /** * Helper class for persistent storage of ScreenCast restore tokens @@ -365,13 +363,10 @@ static Set getTokens(List affectedScreenBounds) { // 2. Try screens of the same size but in different locations, // screens may have been moved while the token is still valid - List dimensions = + List dimensions = affectedScreenBounds .stream() - .map(rectangle -> new Dimension( - rectangle.width, - rectangle.height - )) + .map(rectangle -> new Dimension2D(rectangle.width, rectangle.height)) .toList(); for (TokenItem tokenItem : allTokenItems) { diff --git a/modules/javafx.graphics/src/main/java/com/sun/javafx/geom/Arc2D.java b/modules/javafx.graphics/src/main/java/com/sun/javafx/geom/Arc2D.java index 1c550abbf31..1e64f3b2b50 100644 --- a/modules/javafx.graphics/src/main/java/com/sun/javafx/geom/Arc2D.java +++ b/modules/javafx.graphics/src/main/java/com/sun/javafx/geom/Arc2D.java @@ -270,7 +270,7 @@ public Point2D getEndPoint() { */ public void setArc(Point2D loc, Dimension2D size, float angSt, float angExt, int closure) { - setArc(loc.x, loc.y, size.width, size.height, angSt, angExt, closure); + setArc(loc.x, loc.y, size.width(), size.height(), angSt, angExt, closure); } /** diff --git a/modules/javafx.graphics/src/main/java/com/sun/javafx/geom/Dimension.java b/modules/javafx.graphics/src/main/java/com/sun/javafx/geom/Dimension.java deleted file mode 100644 index 29d9f6baca0..00000000000 --- a/modules/javafx.graphics/src/main/java/com/sun/javafx/geom/Dimension.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.javafx.geom; - -import java.util.Objects; - -public class Dimension { - public int width; - public int height; - - public Dimension(int width, int height) { - this.width = width; - this.height = height; - } - - @Override - public boolean equals(Object obj) { - if (obj instanceof Dimension) { - Dimension d = (Dimension) obj; - return (width == d.width) && (height == d.height); - } - return false; - } - - @Override - public int hashCode() { - return Objects.hash(width, height); - } -} diff --git a/modules/javafx.graphics/src/main/java/com/sun/javafx/geom/Dimension2D.java b/modules/javafx.graphics/src/main/java/com/sun/javafx/geom/Dimension2D.java index 0bf0ea1e2ec..f73cdc208e2 100644 --- a/modules/javafx.graphics/src/main/java/com/sun/javafx/geom/Dimension2D.java +++ b/modules/javafx.graphics/src/main/java/com/sun/javafx/geom/Dimension2D.java @@ -26,18 +26,6 @@ package com.sun.javafx.geom; /** - * The Dimension2D class is to encapsulate a width - * and a height dimension. - *

+ * A 2D dimension object that contains a width and a height. */ -public class Dimension2D { - public float width; - public float height; - - public Dimension2D() { } - - public Dimension2D(float w, float h) { - width = w; - height = h; - } -} +public record Dimension2D(float width, float height) {} diff --git a/modules/javafx.graphics/src/main/java/com/sun/javafx/geom/RectangularShape.java b/modules/javafx.graphics/src/main/java/com/sun/javafx/geom/RectangularShape.java index 4d12156c9c2..14145c5b87f 100644 --- a/modules/javafx.graphics/src/main/java/com/sun/javafx/geom/RectangularShape.java +++ b/modules/javafx.graphics/src/main/java/com/sun/javafx/geom/RectangularShape.java @@ -181,7 +181,7 @@ public float getCenterY() { * @see #getFrame */ public void setFrame(Point2D loc, Dimension2D size) { - setFrame(loc.x, loc.y, size.width, size.height); + setFrame(loc.x, loc.y, size.width(), size.height()); } /** diff --git a/modules/javafx.graphics/src/main/java/javafx/geometry/Dimension2D.java b/modules/javafx.graphics/src/main/java/javafx/geometry/Dimension2D.java index 94969d664e4..6fd7239a27e 100644 --- a/modules/javafx.graphics/src/main/java/javafx/geometry/Dimension2D.java +++ b/modules/javafx.graphics/src/main/java/javafx/geometry/Dimension2D.java @@ -51,7 +51,7 @@ public Dimension2D(@NamedArg("width") double width, @NamedArg("height") double h * * @defaultValue 0.0 */ - private double width; + private final double width; /** * The width of the dimension. @@ -66,7 +66,7 @@ public final double getWidth() { * * @defaultValue 0.0 */ - private double height; + private final double height; /** * The height of the dimension. From e1ce604ae88c002de0a3bd39963c3a692c36510a Mon Sep 17 00:00:00 2001 From: nlisker <37422899+nlisker@users.noreply.github.com> Date: Fri, 29 Nov 2024 19:05:12 +0200 Subject: [PATCH 2/2] Revert static import wildcard use --- .../java/com/sun/glass/ui/gtk/screencast/TokenStorage.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/modules/javafx.graphics/src/main/java/com/sun/glass/ui/gtk/screencast/TokenStorage.java b/modules/javafx.graphics/src/main/java/com/sun/glass/ui/gtk/screencast/TokenStorage.java index f1881704b08..7d85e683381 100644 --- a/modules/javafx.graphics/src/main/java/com/sun/glass/ui/gtk/screencast/TokenStorage.java +++ b/modules/javafx.graphics/src/main/java/com/sun/glass/ui/gtk/screencast/TokenStorage.java @@ -26,7 +26,10 @@ package com.sun.glass.ui.gtk.screencast; import static com.sun.glass.ui.gtk.screencast.ScreencastHelper.SCREENCAST_DEBUG; -import static java.nio.file.StandardWatchEventKinds.*; +import static java.nio.file.StandardWatchEventKinds.ENTRY_CREATE; +import static java.nio.file.StandardWatchEventKinds.ENTRY_DELETE; +import static java.nio.file.StandardWatchEventKinds.ENTRY_MODIFY; +import static java.nio.file.StandardWatchEventKinds.OVERFLOW; import java.io.BufferedReader; import java.io.BufferedWriter;