Class Rectangle

java.lang.Object
com.pdftools.geometry.units.Rectangle

public class Rectangle extends Object
A class that is based on a position (origin) of type Point and a size of type Size that spans the rectangle.
  • Constructor Details

    • Rectangle

      public Rectangle(Length x, Length y, Length width, Length height)
      Construct Rectangle object from individual values
      Parameters:
      x - as Length type
      y - as Length type
      width - as Length type
      height - as Length type
    • Rectangle

      public Rectangle(double x, double y, double width, double height, Length.Units unit)
      Construct Rectangle object from values and a common unit.
      Parameters:
      x - as numerical value
      y - as numerical value
      width - as numerical value
      height - as numerical value
      unit - the unit
  • Method Details

    • fromEdges

      public static Rectangle fromEdges(Length left, Length bottom, Length right, Length top)
      Create a Rectangle object from the four edges left, bottom, right and top as Length objects.
      Parameters:
      left - as Length object
      bottom - as Length object
      right - as Length object
      top - as Length object
      Returns:
    • parse

      public static Rectangle parse(String value)
      Create a Rectangle object from a string representation.
      Parameters:
      value - Allowed are value-unit pairs of the form "<x_value><x_unit> <y_value><y_unit> <right_value><right_unit> <height_value><height_unit>". Example: "12.3cm 23.4mm 34.5mm 45.6mm"
      Returns:
    • toString

      public String toString()
      Creates a string representation as x-y-width-height-tuple with associated suitable metric units, "m", "cm" or "mm".
      Overrides:
      toString in class Object
    • toString

      public String toString(Length.Units unit)
      Creates a string representation as x-y-width-height-tuple with the specified unit.
    • contains

      public boolean contains(Rectangle other)
      Determines whether another rectangle is non-strictly inscribed into the present rectangle.
      Parameters:
      other - as Rectangle object
      Returns:
    • getPosition

      public Point getPosition()
      Get the position (origin) of the rectangle as Point object.
    • getSize

      public Size getSize()
      Get the size of the rectangle as Size object.
    • getLeft

      public Length getLeft()
      Gets the left coordinate of the rectangle as Length object.
    • getTop

      public Length getTop()
      Gets the top coordinate of the rectangle as Length object.
    • getRight

      public Length getRight()
      Gets the right coordinate of the rectangle as Length object.
    • getBottom

      public Length getBottom()
      Gets the bottom coordinate of the rectangle as Length object.
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object