Class Rectangle

java.lang.Object
ro.sync.exml.view.graphics.Rectangle
All Implemented Interfaces:
Shape
Direct Known Subclasses:
ImageLayoutInformation

@API(type=EXTENDABLE, src=PRIVATE) public class Rectangle extends Object implements Shape
Rectangle.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    int
    The height.
    int
    The width.
    int
    The x.
    int
    The y.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Rectangle(int x, int y, int width, int height)
    Constructor.
    Copy constructor.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
     
     
    boolean
    contains(int x, int y)
    Checks whether or not this Rectangle contains the point at the specified location (xy).
    boolean
    contains(int X, int Y, int W, int H)
    Checks whether this Rectangle entirely contains the Rectangle at the specified location ( X Y ) with the specified dimensions ( W H ).
    boolean
    Checks whether or not this Rectangle entirely contains the specified Rectangle.
    boolean
    Checks whether two rectangles are equal.
     
    int
     
    int
     
    int
     
    int
     
    int
     
    Computes the intersection of this Rectangle with the specified Rectangle.
    final boolean
    intersects(int rX, int rY, int rW, int rH)
    Determines whether or not this Rectangle and the specified Rectangle intersect.
    final boolean
    Determines whether or not this Rectangle and the specified Rectangle intersect.
    static void
    main(String[] args)
    TC main.
    Returns a String representing this Rectangle and its values.
    translate(int tx, int ty)
    Translate the shape into another one.
    Computes the union of this Rectangle with the specified Rectangle.

    Methods inherited from class java.lang.Object

    finalize, getClass, notify, notifyAll, wait, wait, wait
  • Field Details

    • width

      public int width
      The width.
    • height

      public int height
      The height.
    • x

      public int x
      The x.
    • y

      public int y
      The y.
  • Constructor Details

    • Rectangle

      public Rectangle(int x, int y, int width, int height)
      Constructor.
      Parameters:
      x - The x coordinate.
      y - The y coordinate.
      width - The width.
      height - The height.
    • Rectangle

      public Rectangle(Rectangle r)
      Copy constructor.
      Parameters:
      r - The other rectangle to be used.
  • Method Details

    • intersects

      public final boolean intersects(Rectangle r)
      Determines whether or not this Rectangle and the specified Rectangle intersect. Two rectangles intersect if their intersection is nonempty.
      Parameters:
      r - the specified Rectangle
      Returns:
      true if the specified Rectangle and this Rectangle intersect; false otherwise.
    • intersects

      public final boolean intersects(int rX, int rY, int rW, int rH)
      Determines whether or not this Rectangle and the specified Rectangle intersect. Two rectangles intersect if their intersection is nonempty.
      Parameters:
      rX - X of rect
      rY - Y of rect
      rW - Width of rect
      rH - Height of rect
      Returns:
      true if the specified Rectangle and this Rectangle intersect; false otherwise.
    • contains

      public boolean contains(Rectangle r)
      Checks whether or not this Rectangle entirely contains the specified Rectangle.
      Parameters:
      r - the specified Rectangle
      Returns:
      true if the Rectangle is contained entirely inside this Rectangle;false otherwise.
    • contains

      public boolean contains(int X, int Y, int W, int H)
      Checks whether this Rectangle entirely contains the Rectangle at the specified location ( X Y ) with the specified dimensions ( W H ).
      Specified by:
      contains in interface Shape
      Parameters:
      X - the specified x coordinate
      Y - the specified y coordinate
      W - the width of the Rectangle
      H - the height of the Rectangle
      Returns:
      true if the Rectangle specified by ( X Y W H ) is entirely enclosed inside this Rectangle;false otherwise.
    • contains

      public boolean contains(int x, int y)
      Checks whether or not this Rectangle contains the point at the specified location (xy).
      Specified by:
      contains in interface Shape
      Parameters:
      x - the specified x coordinate
      y - the specified y coordinate
      Returns:
      true if the point (xy) is inside this Rectangle; false otherwise.
    • toString

      public String toString()
      Returns a String representing this Rectangle and its values.
      Overrides:
      toString in class Object
      Returns:
      a String representing this Rectangle object's coordinate and size values.
    • equals

      public boolean equals(Object obj)
      Checks whether two rectangles are equal.

      The result is true if and only if the argument is not null and is a Rectangle object that has the same top-left corner, width, and height as this Rectangle.

      Overrides:
      equals in class Object
      Parameters:
      obj - the Object to compare with this Rectangle
      Returns:
      true if the objects are equal; false otherwise.
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
      See Also:
    • union

      public Rectangle union(Rectangle r)
      Computes the union of this Rectangle with the specified Rectangle. Returns a new Rectangle that represents the union of the two rectangles
      Parameters:
      r - the specified Rectangle
      Returns:
      the smallest Rectangle containing both the specified Rectangle and this Rectangle.
    • getHeight

      public int getHeight()
      Returns:
      The rectangle height.
    • getWidth

      public int getWidth()
      Returns:
      The rectangle width.
    • getX

      public int getX()
      Returns:
      The rectangle x coordinate.
    • getY

      public int getY()
      Returns:
      The rectangle y coordinate.
    • adjacent

      public boolean adjacent(Rectangle r)
      Parameters:
      r - The rectangle to check for adjacency.
      Returns:
      True if the rectangles are neighbours around one margin and they do not intersect each other.
    • intersection

      public Rectangle intersection(Rectangle r)
      Computes the intersection of this Rectangle with the specified Rectangle. Returns a new Rectangle that represents the intersection of the two rectangles. If the two rectangles do not intersect, the result will be an empty rectangle.
      Parameters:
      r - the specified Rectangle
      Returns:
      the largest Rectangle contained in both the specified Rectangle and in this Rectangle; or if the rectangles do not intersect, an empty rectangle.
    • main

      public static void main(String[] args)
      TC main.
      Parameters:
      args - Main args
    • getBounds

      public Rectangle getBounds()
      Specified by:
      getBounds in interface Shape
      Returns:
      The bounds of this shape.
      See Also:
    • translate

      public Shape translate(int tx, int ty)
      Description copied from interface: Shape
      Translate the shape into another one.
      Specified by:
      translate in interface Shape
      Parameters:
      tx - the distance by which coordinates are translated in the X axis direction
      ty - the distance by which coordinates are translated in the Y axis direction
      Returns:
      The newly translated shape
      See Also:
    • clone

      public Object clone()
      Overrides:
      clone in class Object
      See Also: