Module org.htmlunit

Class Rectangle2D

java.lang.Object
org.htmlunit.util.geometry.Rectangle2D
All Implemented Interfaces:
Shape2D

public class Rectangle2D extends Object implements Shape2D
Simple 2D rectangle shape.
Author:
Ronald Brill
  • Field Summary

    Fields inherited from interface org.htmlunit.util.geometry.Shape2D

    EPSILON
  • Constructor Summary

    Constructors
    Constructor
    Description
    Rectangle2D(double x1, double y1, double x2, double y2)
    Creates a new rectangle defined by two corner points.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    contains(double x, double y)
    Returns whether the specified point lies inside this shape.
    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.
    double
    Returns the y coordinate of the bottom edge.
    double
    Returns the x coordinate of the left edge.
    boolean
    Returns whether this shape is empty.
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • 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 corner
      y1 - the y coordinate of the first corner
      x2 - the x coordinate of the second corner
      y2 - 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.
      Specified by:
      contains in interface Shape2D
      Parameters:
      x - the x coordinate of the point to test
      y - the y coordinate of the point to test
      Returns:
      true if the point is inside this shape; false otherwise
    • 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 include
      y - the y coordinate to include
    • isEmpty

      public boolean isEmpty()
      Returns whether this shape is empty.
      Specified by:
      isEmpty in interface Shape2D
      Returns:
      true if this shape is empty; false otherwise
    • toString

      public String toString()
      Overrides:
      toString in class Object