Class Rectangle


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

      • 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 Detail

      • parse

        public static Rectangle parse​(java.lang.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 java.lang.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 java.lang.Object
      • toString

        public java.lang.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​(java.lang.Object obj)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object