Class Rect


  • public class Rect
    extends Object
    The rectangle.
    • Constructor Summary

      Constructors 
      Constructor Description
      Rect()
      Creates instance.
      Rect​(int left, int top, int right, int bottom)
      Creates instance.
      Rect​(int x, int y, Size size)
      Creates instance by coordinates and rectangle size.
      Rect​(Rect rect)
      Creates instance by hippo rectangle.
      Rect​(Point point, Size size)
      Creates instance by point and size.
      Rect​(org.eclipse.swt.graphics.Point point, Size size)
      Creates instance by SWT point and size.
      Rect​(org.eclipse.swt.graphics.Rectangle rect)
      Creates instance by SWT rectangle.
    • Constructor Detail

      • Rect

        public Rect()
        Creates instance.
      • Rect

        public Rect​(org.eclipse.swt.graphics.Rectangle rect)
        Creates instance by SWT rectangle.
        Parameters:
        rect - the rectangle, cannot be null
      • Rect

        public Rect​(int left,
                    int top,
                    int right,
                    int bottom)
        Creates instance.
        Parameters:
        left -
        top -
        right -
        bottom -
      • Rect

        public Rect​(Rect rect)
        Creates instance by hippo rectangle.
        Parameters:
        rect - the hippo rectangle, cannot be null
      • Rect

        public Rect​(int x,
                    int y,
                    Size size)
        Creates instance by coordinates and rectangle size.
        Parameters:
        x - the X-coordinate
        y - the Y-coordinate
        size - the rectangle size, cannot be null
      • Rect

        public Rect​(Point point,
                    Size size)
        Creates instance by point and size.
        Parameters:
        point - the rectangle init point, cannot be null
        size - the rectangle size, cannot be null
      • Rect

        public Rect​(org.eclipse.swt.graphics.Point point,
                    Size size)
        Creates instance by SWT point and size.
        Parameters:
        point - the rectangle init point, cannot be null
        size - the rectangle size, cannot be null
    • Method Detail

      • toRectangle

        public org.eclipse.swt.graphics.Rectangle toRectangle()
        Converts to SWT rectangle.
        Returns:
        rectangle, cannot be null
      • contains

        public boolean contains​(Point point)
        Check if the rectangle containsthe given point.
        Parameters:
        point - the point, cannot be null
        Returns:
        true if the rectangle containsthe given point.
      • contains

        public boolean contains​(org.eclipse.swt.graphics.Point point)
        Check if the rectangle containsthe given SWT point.
        Parameters:
        point - the SWT point, cannot be null
        Returns:
        true if the rectangle containsthe given point.
      • inflate

        public void inflate​(long x,
                            long y)
        Inflates the rectangle.
        Parameters:
        x -
        y -
      • offset

        public void offset​(int x,
                           int y)
        Adds offset to the rectangle.
        Parameters:
        x - the x offset
        y - the y offset
      • isEquals

        public boolean isEquals​(Rect rect)
        Check if rectangles are equals.
        Parameters:
        rect - the rectangle, cannot be null
        Returns:
        true if rectangles are equals
      • isEmpty

        public boolean isEmpty()
        Checks if the rectangle has default value.
        Returns:
        true if the rectangle has default value
      • width

        public int width()
        Calculates width.
        Returns:
        width
      • height

        public int height()
        Calculates height.
        Returns:
        height
      • size

        public Size size()
        Calculates rectangle's size.
        Returns:
        size, cannot be null
      • empty

        public boolean empty()
        Checks if the rectangle has zero size.
        Returns:
        true if the rectangle has zero size
      • topLeft

        public Point topLeft()
        Returns a top left point of the rectangle.
        Returns:
        top left point, cannot be null
      • topRight

        public Point topRight()
        Returns a top right point of the rectangle.
        Returns:
        top right point, cannot be null
      • bottomRight

        public Point bottomRight()
        Returns a bottom right point of the rectangle.
        Returns:
        bottom right point, cannot be null
      • bottomLeft

        public Point bottomLeft()
        Returns a bottom left point of the rectangle.
        Returns:
        bottom left point, cannot be null
      • center

        public Point center()
        Returns a center point of the rectangle.
        Returns:
        center point, cannot be null
      • intersect

        public Rect intersect​(Rect rect)
        Modifies current rectangle as intersect the the given one.
        Parameters:
        rect - , cannot be null
        Returns:
        rectangle, cannot be null
      • intersect

        public static Rect intersect​(Rect rect1,
                                     Rect rect2)
      • getTop

        public int getTop()
        Returns top.
        Returns:
        top
      • setTop

        public void setTop​(int top)
        Sets top.
        Parameters:
        top -
      • getLeft

        public int getLeft()
        Returns left.
        Returns:
        left
      • setLeft

        public void setLeft​(int left)
        Sets left.
        Parameters:
        left -
      • getBottom

        public int getBottom()
        Returns bottom.
        Returns:
        bottom
      • setBottom

        public void setBottom​(int bottom)
        Sets bottom.
        Parameters:
        bottom -
      • getRight

        public int getRight()
        Returns right.
        Returns:
        right
      • setRight

        public void setRight​(int right)
        Sets right.
        Parameters:
        right -