Skip to content
Open
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 @@ -383,6 +383,33 @@ public static Rectangle of(Point topLeft, int width, int height) {
return new Rectangle(topLeft.x, topLeft.y, width, height);
}

/**
* Creates a new {@code Rectangle} using the specified Point instances for the
* dimensions.
* <p>
* If the provided {@code Point} instance carries additional OfFloat
* information, an extended {@code Rectangle} type may be returned to preserve
* that context. Otherwise, a standard {@code Rectangle} is returned.
* </p>
*
* @param topLeft the top-left corner of the rectangle
* @param dimension the Point(width, height) of the rectangle
* @return a new {@code Rectangle} instance appropriate for the given point and
* dimensions
* @since 3.133
*/
public static Rectangle of(Point topLeft, Point dimension) {
if (topLeft instanceof Point.OfFloat ofFloatTopLeft && dimension instanceof Point.OfFloat ofFloatDimension) {
return new Rectangle.OfFloat(ofFloatTopLeft.getX(), ofFloatTopLeft.getY(), ofFloatDimension.getX(),
ofFloatDimension.getY());
} else if (topLeft instanceof Point.OfFloat ofFloatTopLeft) {
return new Rectangle.OfFloat(ofFloatTopLeft.getX(), ofFloatTopLeft.getY(), dimension.x, dimension.y);
} else if (dimension instanceof Point.OfFloat ofFloatDimension) {
return new Rectangle.OfFloat(topLeft.x, topLeft.y, ofFloatDimension.getX(), ofFloatDimension.getY());
}
return new Rectangle(topLeft.x, topLeft.y, dimension.x, dimension.y);
}

/**
* Creates and returns a copy of this {@code Rectangle}.
* <p>
Expand Down
Loading