com.corticon.eclipse.core.util

## Class Rectangle

- java.lang.Object
- - com.corticon.eclipse.core.util.Rectangle

-     public class Rectangle
      extends java.lang.Object

  This class represents a rectangle. It contains x/y coordinates and width/height specifications and contains various methods for analyzing the relationships between rectangles, such as determining whether a given rectangle is fully contained within another.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `int` | `height`
    `int` | `width`
    `int` | `x`
    `int` | `y`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `Rectangle(int x, int y, int width, int height)`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `boolean` | `borders(Rectangle aRectangle)` Return `true` if this Rectangle borders the specified rectangle along either its horizontal or vertical axis.
    `boolean` | `bordersHorizontal(Rectangle aRectangle)` Return `true` if this Rectangle borders the specified rectangle along its horizontal axis.
    `boolean` | `bordersHorizontalStrict(Rectangle aRectangle)` Return `true` if this Rectangle borders the specified rectangle along its horizontal axis.
    `boolean` | `bordersStrict(Rectangle aRectangle)` Return `true` if this Rectangle borders the specified rectangle along either its horizontal or vertical axis.
    `boolean` | `bordersVertical(Rectangle aRectangle)` Return `true` if this Rectangle borders the specified rectangle along its vertical axis.
    `boolean` | `bordersVerticalStrict(Rectangle aRectangle)` Return `true` if this Rectangle borders the specified rectangle along its vertical axis.
    `java.lang.Object` | `clone()` Create a copy of this Rectangle.
    `boolean` | `contains(int aiX, int aiY)` Checks whether or not this `Rectangle` contains the point at the specified location.
    `boolean` | `contains(int aiX, int aiY, int aiWidth, int aiHeight)` Checks whether or not this rectangle entirely contains the specified rectangle.
    `boolean` | `contains(Rectangle aRectangle)` Checks whether or not this rectangle entirely contains the specified rectangle.
    `boolean` | `equals(java.lang.Object aObject)` Checks whether two rectangles are equal.
    `int` | `getBottom()` Return the index of the bottom of the rectangle.
    `int` | `getRight()` Return the index of the right side of the rectangle.
    `Rectangle` | `intersection(Rectangle aRectangle)` Computes the intersection of this `Rectangle` with the specified `Rectangle`.
    `boolean` | `intersects(Rectangle aRectangle)` Determines whether or not this `Rectangle` and the specified `Rectangle` intersect.
    `boolean` | `isColumnSpecification()` Return an indication of whether this is column-only specification.
    `boolean` | `isRowSpecification()` Return an indication of whether this is row-only specification.
    `Rectangle[]` | `removeHorizontal(Rectangle aRectangle)` Return the result of the removal of a specified rectangle from this rectangle.
    `Rectangle[]` | `removeVertical(Rectangle aRectangle)` Return the result of the removal of a specified rectangle from this rectangle.
    `void` | `setLocation(int aiX, int aiY)` Sets the location of this rectangle to the specified X/Y coordinates.
    `void` | `setSize(int aiWidth, int aiHeight)` Sets the size of this rectangle to the specified width and height.
    `java.lang.String` | `toString()` Returns a `String` representing this `Rectangle` and its values.
    `Rectangle` | `union(Rectangle aRectangle)` Computes the union of this `Rectangle` with the specified `Rectangle`.

    - ### Methods inherited from class java.lang.Object

      `finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Field Detail

    - #### x

          public int x

    - #### y

          public int y

    - #### width

          public int width

    - #### height

          public int height

  - ### Constructor Detail

    - #### Rectangle

          public Rectangle(int x,
                   int y,
                   int width,
                   int height)

  - ### Method Detail

    - #### borders

          public boolean borders(Rectangle aRectangle)

      Return `true` if this Rectangle borders the specified rectangle along either its horizontal or vertical axis.
      Parameters:
        `aRectangle` - Rectangle to compare to this one.
      Returns:
        `true` if this Rectangle borders the specified rectangle along either axis.

    - #### bordersVertical

          public boolean bordersVertical(Rectangle aRectangle)

      Return `true` if this Rectangle borders the specified rectangle along its vertical axis.
      Parameters:
        `aRectangle` - Rectangle to compare to this one.
      Returns:
        `true` if this Rectangle borders the specified rectangle along vertical axis.

    - #### bordersHorizontal

          public boolean bordersHorizontal(Rectangle aRectangle)

      Return `true` if this Rectangle borders the specified rectangle along its horizontal axis.
      Parameters:
        `aRectangle` - Rectangle to compare to this one.
      Returns:
        `true` if this Rectangle borders the specified rectangle along horizontal axis.

    - #### bordersStrict

          public boolean bordersStrict(Rectangle aRectangle)

      Return `true` if this Rectangle borders the specified rectangle along either its horizontal or vertical axis. The rectangles must also be of the same width or height such that combining the two would form a perfect rectangle.
      Parameters:
        `aRectangle` - Rectangle to compare to this one.
      Returns:
        `true` if this Rectangle borders the specified rectangle along either axis.

    - #### bordersVerticalStrict

          public boolean bordersVerticalStrict(Rectangle aRectangle)

      Return `true` if this Rectangle borders the specified rectangle along its vertical axis. Note that both rectangles must also be of the same y position and width.
      Parameters:
        `aRectangle` - Rectangle to compare to this one.
      Returns:
        `true` if this Rectangle borders the specified rectangle along vertical axis.

    - #### bordersHorizontalStrict

          public boolean bordersHorizontalStrict(Rectangle aRectangle)

      Return `true` if this Rectangle borders the specified rectangle along its horizontal axis. Note that both rectangles must also be of the same x position and width.
      Parameters:
        `aRectangle` - Rectangle to compare to this one.
      Returns:
        `true` if this Rectangle borders the specified rectangle along horizontal axis.

    - #### clone

          public java.lang.Object clone()

      Create a copy of this Rectangle.
      Overrides:
        `clone` in class `java.lang.Object`
      Returns:
        Clone of this Rectangle.

    - #### contains

          public boolean contains(int aiX,
                         int aiY)

      Checks whether or not this `Rectangle` contains the point at the specified location.
      Parameters:
        `aiX` - The specified x coordinate.
        `aiY` - The specified y coordinate.
      Returns:
        `true` if this rectangle contains the specified point.

    - #### contains

          public boolean contains(int aiX,
                         int aiY,
                         int aiWidth,
                         int aiHeight)

      Checks whether or not this rectangle entirely contains the specified rectangle.
      Parameters:
        `aiX` - The X coordinate.
        `aiY` - The Y coordinate.
        `aiWidth` - The width of the rectangle.
        `aiHeight` - The height of the rectangle.
      Returns:
        `true` if this Rectangle entirely contains the specified rectangle.

    - #### contains

          public boolean contains(Rectangle aRectangle)

      Checks whether or not this rectangle entirely contains the specified rectangle.
      Parameters:
        `aRectangle` - The specified rectangle to test.
      Returns:
        `true` if this Rectangle entirely contains the specified rectangle.

    - #### getBottom

          public int getBottom()

      Return the index of the bottom of the rectangle.
      Returns:
        Index of bottom of the rectangle.

    - #### getRight

          public int getRight()

      Return the index of the right side of the rectangle.
      Returns:
        Index of rightmost side of the rectangle.

    - #### intersection

          public Rectangle intersection(Rectangle aRectangle)

      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:
        `aRectangle` - 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.

    - #### intersects

          public boolean intersects(Rectangle aRectangle)

      Determines whether or not this `Rectangle` and the specified `Rectangle` intersect. Two rectangles intersect if their intersection is non-empty.
      Parameters:
        `aRectangle` - the specified `Rectangle`
      Returns:
        `true` if the specified `Rectangle` and this `Rectangle` intersect; `false` otherwise.

    - #### isColumnSpecification

          public boolean isColumnSpecification()

      Return an indication of whether this is column-only specification.
      Returns:
        `true` if this rectangle is a column-only specification.

    - #### isRowSpecification

          public boolean isRowSpecification()

      Return an indication of whether this is row-only specification.
      Returns:
        `true` if this rectangle is a row-only specification.

    - #### setLocation

          public void setLocation(int aiX,
                         int aiY)

      Sets the location of this rectangle to the specified X/Y coordinates.
      Parameters:
        `aiX` - X coordinate for rectangle.
        `aiY` - Y coordinate for rectangle.

    - #### removeVertical

          public Rectangle[] removeVertical(Rectangle aRectangle)

      Return the result of the removal of a specified rectangle from this rectangle. The result can be: 1. This rectangle (unchanged) if the rectangles do not intersect. 2. A pair of independent rectangles if the specified rectangle is removed from the middle. 3. A single rectangle if the specified rectangle is removed from either side. 4. `null` if the specified rectangle completely engulfs this rectangle.
      Parameters:
        `aRectangle` - Rectangle to be removed.
      Returns:
        Array of Rectangle instances or `null`.

    - #### removeHorizontal

          public Rectangle[] removeHorizontal(Rectangle aRectangle)

      Return the result of the removal of a specified rectangle from this rectangle. The result can be: 1. This rectangle (unchanged) if the rectangles do not intersect. 2. A pair of independent rectangles if the specified rectangle is removed from the middle. 3. A single rectangle if the specified rectangle is removed from top or bottom. 4. `null` if the specified rectangle completely engulfs this rectangle.
      Parameters:
        `aRectangle` - Rectangle to be removed.
      Returns:
        Array of Rectangle instances or `null`.

    - #### setSize

          public void setSize(int aiWidth,
                     int aiHeight)

      Sets the size of this rectangle to the specified width and height.
      Parameters:
        `aiWidth` - the new width for this rectangle.
        `aiHeight` - the new height for this rectangle.

    - #### union

          public Rectangle union(Rectangle aRectangle)

      Computes the union of this `Rectangle` with the specified `Rectangle`. Returns a new `Rectangle` that represents the union of the two rectangles
      Parameters:
        `aRectangle` - the specified `Rectangle`
      Returns:
        the smallest `Rectangle` containing both the specified `Rectangle` and this `Rectangle`.

    - #### equals

          public boolean equals(java.lang.Object aObject)

      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 `java.lang.Object`
      Parameters:
        `aObject` - the `Object` to compare with this `Rectangle`
      Returns:
        `true` if the objects are equal; `false` otherwise.

    - #### toString

          public java.lang.String toString()

      Returns a `String` representing this `Rectangle` and its values.
      Overrides:
        `toString` in class `java.lang.Object`
      Returns:
        a `String` representing this `Rectangle` object's coordinate and size values.

Copyright © 2005-2013 Progress Software Corporation and/or its subsidiaries and affiliates. All rights reserved.