Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.maryanovsky.gwtutils.client.geom
Class Rectangle

    java.lang.Object
      com.maryanovsky.gwtutils.client.geom.Rectangle

All Implemented Interfaces:
  RectangleView

    public final class Rectangle

extends Object
implements RectangleView

A rectangle, in integer coordinates.

Author:
  Maryanovsky Alexander

Constructor Summary
`Rectangle()` Creates a new `Rectangle` of `0x0` size at `0,0` coordinates.
`Rectangle(int x, int y, int width, int height)` Creates a new `Rectangle` with the specified arguments.
`Rectangle(PointView point, SizeView size)` Creates a new rectangle at the specified coordinates and with the specified size.
`Rectangle(RectangleView rectangle)` Creates a new rectangle with the same values as the specified one.

Method Summary
`boolean` | `contains(PointView point)` Returns whether this rectangle contains the specified point.
`boolean` | `contains(RectangleView rectangle)` Returns whether this rectangle contains the specified one.
`boolean` | `equals(int x, int y, int width, int height)` Returns whether the coordinates and size of this rectangle are the specified ones.
`boolean` | `equals(Object o)` Returns whether this `Rectangle` object has the same coordinates and size as this one.
`boolean` | `equals(RectangleView rect)` Returns whether the specified rectangle is the same as this one.
`Rectangle` | `expandToGrid(int cellWidth, int cellHeight)` Expands this rectangle so that it lies on the grid with cells of the specified size.
`Rectangle` | `expandToGrid(SizeView cellSize)` Expands this rectangle so that it lies on the grid with cells of the specified size.
`PointView` | `getBottomLeft()` Returns the location of the bottom-left point.
`Point` | `getBottomLeft(Point reusable)` Returns the location of the bottom-left point of the rectangle.
`PointView` | `getBottomRight()` Returns the location of the bottom-right point.
`Point` | `getBottomRight(Point reusable)` Returns the location of the bottom-right point of the rectangle.
`PointView` | `getCenter()` Returns the location of the center of the rectangle.
`Point` | `getCenter(Point reusable)` Returns the location of the center of the rectangle, in the same manner as the getCenter() method.
`int` | `getHeight()` Returns the height of the rectangle.
`SizeView` | `getSize()` Returns the size of the rectangle.
`Size` | `getSize(Size reusable)` Returns the size of the rectangle.
`PointView` | `getTopLeft()` Returns the location of the top-left point.
`Point` | `getTopLeft(Point reusable)` Returns the location of the top-left point of the rectangle.
`PointView` | `getTopRight()` Returns the location of the top-right point.
`Point` | `getTopRight(Point reusable)` Returns the location of the top-right point of the rectangle.
`int` | `getWidth()` Returns the width of the rectangle.
`int` | `getX()` Returns the X coordinate of the top-left point.
`int` | `getY()` Returns the Y coordinate of the top-left point.
`Rectangle` | `growBy(int dx, int dy)` Grows the dimensions of the rectangle by the specified values.
`Rectangle` | `growBy(PointView point)` Grows the dimensions of the rectangle by the values of the specified point.
`Rectangle` | `growBy(SizeView size)` Grows the dimensions of the rectangle by the specified size.
`int` | `hashCode()` Returns the hashcode of this object.
`boolean` | `intersects(RectangleView rectangle)` Returns whether this rectangle intersects with the specified one.
`static Rectangle` | `make(int x, int y, int width, int height, Rectangle reusable)` Returns a `Rectangle` with the specified values.
`static Rectangle` | `makeCover(PointView point1, PointView point2)` Returns the smallest rectangle which contains both specified points.
`Rectangle` | `moveBy(int dx, int dy)` Moves the rectangle by the specified offsets.
`Rectangle` | `moveBy(PointView point)` Moves the rectangle by the offsets specified by the given point.
`Rectangle` | `moveBy(SizeView size)` Moves the rectangle by the offsets specified by the given size.
`Rectangle` | `multiplyBy(double coefficient)` Multiplies the coordinates and dimensions of this rectangle by the specified coefficient.
`Rectangle` | `set(int x, int y, int width, int height)` Sets the values of this rectangle.
`Rectangle` | `set(PointView point, SizeView size)` Sets the values of this rectangle.
`Rectangle` | `set(RectangleView rect)` Sets the values of this rectangle to those of the specified one.
`Rectangle` | `setCover(PointView point1, PointView point2)` Sets this rectangle to the smallest rectangle which contains both specified points.
`Rectangle` | `setHeight(int height)` Sets the height of the rectangle.
`Rectangle` | `setSize(int width, int height)` Sets the size of the rectangle.
`Rectangle` | `setSize(SizeView size)` Sets the size of the rectangle.
`Rectangle` | `setTopLeft(int x, int y)` Sets the location of the top-left point.
`Rectangle` | `setTopLeft(PointView point)` Sets the location of the top-left point.
`Rectangle` | `setWidth(int width)` Sets the width of the rectangle.
`Rectangle` | `setX(int x)` Sets the X coordinate of the top-left point.
`Rectangle` | `setY(int y)` Sets the Y coordinate of the top-left point.
`String` | `toString()` Returns a textual representation of this rectangle.

Methods inherited from class java.lang.Object
`clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

Constructor Detail

### Rectangle

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

  Creates a new `Rectangle` with the specified arguments. Note that if `width` and/or `height` are negative, the rectangle is normalized (the top-left point is moved accordingly, and and the width and/or height are set to the absolute values of the specified ones).

  Parameters:
    `x` - The X coordinate of the top-left point.
    `y` - The Y coordinate of the top-left point.
    `width` - The width of the rectangle.
    `height` - The height of the rectangle.

### Rectangle

    public Rectangle()

  Creates a new `Rectangle` of `0x0` size at `0,0` coordinates.

### Rectangle

    public Rectangle(RectangleView rectangle)

  Creates a new rectangle with the same values as the specified one.

### Rectangle

    public Rectangle(PointView point,
                     SizeView size)

  Creates a new rectangle at the specified coordinates and with the specified size.

Method Detail

### make

    public static Rectangle make(int x,
                                 int y,
                                 int width,
                                 int height,
                                 Rectangle reusable)

  Returns a `Rectangle` with the specified values. If the given `Rectangle` is not `null`, it is reused and returned.

### makeCover

    public static Rectangle makeCover(PointView point1,
                                      PointView point2)

  Returns the smallest rectangle which contains both specified points.

### set

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

  Sets the values of this rectangle.

  Returns:
    `this`.

### set

    public Rectangle set(PointView point,
                         SizeView size)

  Sets the values of this rectangle.

### set

    public Rectangle set(RectangleView rect)

  Sets the values of this rectangle to those of the specified one.

### getSize

    public SizeView getSize()

  Returns the size of the rectangle.

  Specified by:
    `getSize` in interface `RectangleView`

### getSize

    public Size getSize(Size reusable)

  Returns the size of the rectangle. If the specified `Size` object is not `null`, it is reused and returned.

  Specified by:
    `getSize` in interface `RectangleView`

### setSize

    public Rectangle setSize(int width,
                             int height)

  Sets the size of the rectangle. If the specified width and/or height are negative, the rectangle is normalized.

  Returns:
    `this`.

### setSize

    public Rectangle setSize(SizeView size)

  Sets the size of the rectangle.

  Returns:
    `this`.

### getTopLeft

    public PointView getTopLeft()

  Returns the location of the top-left point.

  Specified by:
    `getTopLeft` in interface `RectangleView`

### getTopLeft

    public Point getTopLeft(Point reusable)

  Returns the location of the top-left point of the rectangle. If the specified `Point` object is not `null`, it is reused and returned.

  Specified by:
    `getTopLeft` in interface `RectangleView`

### getTopRight

    public PointView getTopRight()

  Returns the location of the top-right point.

  Specified by:
    `getTopRight` in interface `RectangleView`

### getTopRight

    public Point getTopRight(Point reusable)

  Returns the location of the top-right point of the rectangle. If the specified `Point` object is not `null`, it is reused and returned.

  Specified by:
    `getTopRight` in interface `RectangleView`

### getBottomLeft

    public PointView getBottomLeft()

  Returns the location of the bottom-left point.

  Specified by:
    `getBottomLeft` in interface `RectangleView`

### getBottomLeft

    public Point getBottomLeft(Point reusable)

  Returns the location of the bottom-left point of the rectangle. If the specified `Point` object is not `null`, it is reused and returned.

  Specified by:
    `getBottomLeft` in interface `RectangleView`

### getBottomRight

    public PointView getBottomRight()

  Returns the location of the bottom-right point.

  Specified by:
    `getBottomRight` in interface `RectangleView`

### getBottomRight

    public Point getBottomRight(Point reusable)

  Returns the location of the bottom-right point of the rectangle. If the specified `Point` object is not `null`, it is reused and returned.

  Specified by:
    `getBottomRight` in interface `RectangleView`

### getCenter

    public PointView getCenter()

  Returns the location of the center of the rectangle. If the rectangle's width and/or height are even (so that the center point's coordinates are not integers), one of the closest integer points is returned, but which is unspecified.

  Specified by:
    `getCenter` in interface `RectangleView`

### getCenter

    public Point getCenter(Point reusable)

  Returns the location of the center of the rectangle, in the same manner as the getCenter() method. If the specified `Point` object is not `null`, it is reused and returned.

  Specified by:
    `getCenter` in interface `RectangleView`

### setTopLeft

    public Rectangle setTopLeft(int x,
                                int y)

  Sets the location of the top-left point.

  Returns:
    `this`.

### setTopLeft

    public Rectangle setTopLeft(PointView point)

  Sets the location of the top-left point.

  Returns:
    `this`.

### moveBy

    public Rectangle moveBy(int dx,
                            int dy)

  Moves the rectangle by the specified offsets.

  Returns:
    `this`.

### moveBy

    public Rectangle moveBy(SizeView size)

  Moves the rectangle by the offsets specified by the given size.

  Returns:
    `this`.

### moveBy

    public Rectangle moveBy(PointView point)

  Moves the rectangle by the offsets specified by the given point.

  Returns:
    `this`.

### growBy

    public Rectangle growBy(int dx,
                            int dy)

  Grows the dimensions of the rectangle by the specified values.

  Returns:
    `this`.

### growBy

    public Rectangle growBy(SizeView size)

  Grows the dimensions of the rectangle by the specified size.

  Returns:
    `this`.

### growBy

    public Rectangle growBy(PointView point)

  Grows the dimensions of the rectangle by the values of the specified point.

### multiplyBy

    public Rectangle multiplyBy(double coefficient)

  Multiplies the coordinates and dimensions of this rectangle by the specified coefficient.

  Returns:
    `this`.

### setCover

    public Rectangle setCover(PointView point1,
                              PointView point2)

  Sets this rectangle to the smallest rectangle which contains both specified points.

  Returns:
    `this`.

### contains

    public boolean contains(PointView point)

  Returns whether this rectangle contains the specified point.

  Specified by:
    `contains` in interface `RectangleView`

### contains

    public boolean contains(RectangleView rectangle)

  Returns whether this rectangle contains the specified one.

  Specified by:
    `contains` in interface `RectangleView`

### intersects

    public boolean intersects(RectangleView rectangle)

  Returns whether this rectangle intersects with the specified one.

  Specified by:
    `intersects` in interface `RectangleView`

### expandToGrid

    public Rectangle expandToGrid(int cellWidth,
                                  int cellHeight)

  Expands this rectangle so that it lies on the grid with cells of the specified size.

  Returns:
    `this`.

### expandToGrid

    public Rectangle expandToGrid(SizeView cellSize)

  Expands this rectangle so that it lies on the grid with cells of the specified size.

  Returns:
    `this`.

### getX

    public int getX()

  Returns the X coordinate of the top-left point.

  Specified by:
    `getX` in interface `RectangleView`

### setX

    public Rectangle setX(int x)

  Sets the X coordinate of the top-left point.

  Returns:
    `this`.

### getY

    public int getY()

  Returns the Y coordinate of the top-left point.

  Specified by:
    `getY` in interface `RectangleView`

### setY

    public Rectangle setY(int y)

  Sets the Y coordinate of the top-left point.

  Returns:
    `this`.

### getWidth

    public int getWidth()

  Returns the width of the rectangle.

  Specified by:
    `getWidth` in interface `RectangleView`

### setWidth

    public Rectangle setWidth(int width)

  Sets the width of the rectangle. If the specified value is negative, the rectangle is normalized (the X coordinate is moved accordingly and the width is set to the absolute value of the specified one).

  Returns:
    `this`.

### getHeight

    public int getHeight()

  Returns the height of the rectangle.

  Specified by:
    `getHeight` in interface `RectangleView`

### setHeight

    public Rectangle setHeight(int height)

  Sets the height of the rectangle. If the specified value is negative, the rectangle is normalized (the Y coordinate is moved accordingly and the height is set to the absolute value of the specified one).

  Returns:
    `this`.

### equals

    public boolean equals(int x,
                          int y,
                          int width,
                          int height)

  Returns whether the coordinates and size of this rectangle are the specified ones.

### equals

    public boolean equals(RectangleView rect)

  Returns whether the specified rectangle is the same as this one.

### equals

    public boolean equals(Object o)

  Returns whether this `Rectangle` object has the same coordinates and size as this one.

  Overrides:
    `equals` in class `Object`

### hashCode

    public int hashCode()

  Returns the hashcode of this object.

  Overrides:
    `hashCode` in class `Object`

### toString

    public String toString()

  Returns a textual representation of this rectangle.

  Overrides:
    `toString` in class `Object`

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD