java.lang.Object
org.htmlunit.util.geometry.Rectangle2D
- All Implemented Interfaces:
Shape2D
Simple 2D rectangle shape.
- Author:
- Ronald Brill
-
Field Summary
-
Constructor Summary
ConstructorsConstructorDescriptionRectangle2D(double x1, double y1, double x2, double y2) Creates a new rectangle defined by two corner points. -
Method Summary
Modifier and TypeMethodDescriptionbooleancontains(double x, double y) Returns whether the specified point lies inside this shape.voidextend(double x, double y) Expands this rectangle to ensure that the given point is included, moving the left, right, top, or bottom edge as necessary.doubleReturns the y coordinate of the bottom edge.doublegetLeft()Returns the x coordinate of the left edge.booleanisEmpty()Returns whether this shape is empty.toString()
-
Constructor Details
-
Rectangle2D
public Rectangle2D(double x1, double y1, double x2, double y2) Creates a new rectangle defined by two corner points.- Parameters:
x1- the x coordinate of the first cornery1- the y coordinate of the first cornerx2- the x coordinate of the second cornery2- the y coordinate of the second corner
-
-
Method Details
-
getLeft
public double getLeft()Returns the x coordinate of the left edge.- Returns:
- the x coordinate of the left edge
-
getBottom
public double getBottom()Returns the y coordinate of the bottom edge.- Returns:
- the y coordinate of the bottom edge
-
contains
public boolean contains(double x, double y) Returns whether the specified point lies inside this shape. -
extend
public void extend(double x, double y) Expands this rectangle to ensure that the given point is included, moving the left, right, top, or bottom edge as necessary.- Parameters:
x- the x coordinate to includey- the y coordinate to include
-
isEmpty
public boolean isEmpty()Returns whether this shape is empty. -
toString
-