Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
nlisker committed Nov 29, 2024
1 parent bdfc338 commit 2576c31
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 88 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;


/**
Expand Down Expand Up @@ -76,15 +77,15 @@ public boolean hasAllScreensWithExactMatch(List<Rectangle> bounds) {
return allowedScreensBounds.containsAll(bounds);
}

public boolean hasAllScreensOfSameSize(List<Dimension> screenSizes) {
public boolean hasAllScreensOfSameSize(List<Dimension2D> 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<Dimension> tokenSizes = allowedScreensBounds
List<Dimension2D> 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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
Expand Down Expand Up @@ -365,13 +363,10 @@ static Set<TokenItem> getTokens(List<Rectangle> affectedScreenBounds) {

// 2. Try screens of the same size but in different locations,
// screens may have been moved while the token is still valid
List<Dimension> dimensions =
List<Dimension2D> dimensions =
affectedScreenBounds
.stream()
.map(rectangle -> new Dimension(
rectangle.width,
rectangle.height
))
.map(rectangle -> new Dimension2D(rectangle.width, rectangle.height))
.toList();

for (TokenItem tokenItem : allTokenItems) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

/**
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,6 @@
package com.sun.javafx.geom;

/**
* The <code>Dimension2D</code> class is to encapsulate a width
* and a height dimension.
* <p>
* 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) {}
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -66,7 +66,7 @@ public final double getWidth() {
*
* @defaultValue 0.0
*/
private double height;
private final double height;

/**
* The height of the dimension.
Expand Down

0 comments on commit 2576c31

Please sign in to comment.