Class Rectangle


  • public class Rectangle
    extends java.lang.Object
    Object contained data for a rectangle.
    • Constructor Detail

      • Rectangle

        public Rectangle​(Rectangle rectangle)
        Create clone object based on the provided Rectangle.
        Parameters:
        rectangle - provided Rectangle object.
      • Rectangle

        public Rectangle​(int minX,
                         int minY,
                         int maxX,
                         int maxY)
        Create instance of the Rectangle based on the provided coordinates.
        Parameters:
        minX - minimal X-coordinate.
        minY - minimal Y-coordinate.
        maxX - maximal X-coordinate.
        maxY - maximal Y-coordinate.
    • Method Detail

      • createZero

        public static Rectangle createZero()
        Create instance with zero points.
        Returns:
        created Rectangle instance.
      • isOverlapping

        public boolean isOverlapping​(Rectangle that)
        Check is that rectangle overlapp this.
        Parameters:
        that - Rectangle which checks with this.
        Returns:
        true if this over lapp that, false otherwise.
      • setDefaultValues

        public void setDefaultValues()
        Set default values for rectangle.
      • makeZeroRectangle

        public void makeZeroRectangle()
        Make zero rectagle.
      • size

        public java.lang.Integer size()
        Size of the Rectangle, counted as width x height.
        Returns:
        the size of the Rectangle.
      • getWidth

        public int getWidth()
        Count the width of the Rectangle. Min and max point are included, so real width is +1px
        Returns:
        rectangle width.
      • getHeight

        public int getHeight()
        Count the height of the Rectangle. Min and max point are included, so real width is +1px.
        Returns:
        rectangle height.
      • getMinPoint

        public java.awt.Point getMinPoint()
      • setMinPoint

        public void setMinPoint​(java.awt.Point minPoint)
      • getMaxPoint

        public java.awt.Point getMaxPoint()
      • setMaxPoint

        public void setMaxPoint​(java.awt.Point maxPoint)
      • equals

        public boolean equals​(java.lang.Object o)
        Overrides:
        equals in class java.lang.Object
      • hashCode

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