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

## org.lwjgl.util
Class Rectangle

    java.lang.Object
      org.lwjgl.util.Rectangle

All Implemented Interfaces:
  java.io.Serializable, ReadableDimension, ReadablePoint, ReadableRectangle, WritableDimension, WritablePoint, WritableRectangle

    public final class Rectangle

extends java.lang.Object
implements ReadableRectangle, WritableRectangle, java.io.Serializable

A 2D integer Rectangle class which looks remarkably like an AWT one.

Version:
  $Revision: 2286 $ $Id: Rectangle.java 2286 2006-03-23 19:32:21Z matzon $
Author:
  $Author: matzon $
See Also:
  Serialized Form

Constructor Summary
`Rectangle()` Constructor for Rectangle.
`Rectangle(int x, int y, int w, int h)` Constructor for Rectangle.
`Rectangle(ReadablePoint p, ReadableDimension d)` Constructor for Rectangle.
`Rectangle(ReadableRectangle r)` Constructor for Rectangle.

Method Summary
`void` | `add(int newx, int newy)` Adds a point, specified by the integer arguments `newx` and `newy`, to this `Rectangle`.
`void` | `add(ReadablePoint pt)` Adds the specified `Point` to this `Rectangle`.
`void` | `add(ReadableRectangle r)` Adds a `Rectangle` to this `Rectangle`.
`boolean` | `contains(int X, int Y)` Checks whether or not this `Rectangle` contains the point at the specified location (x, y).
`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` | `contains(ReadablePoint p)` Checks whether or not this `Rectangle` contains the specified `Point`.
`boolean` | `contains(ReadableRectangle r)` Checks whether or not this `Rectangle` entirely contains the specified `Rectangle`.
`boolean` | `equals(java.lang.Object obj)` Checks whether two rectangles are equal.
`void` | `getBounds(WritableRectangle dest)` Copy this readable rectangle's bounds into a destination Rectangle
`int` | `getHeight()` Gets the height.
`void` | `getLocation(WritablePoint dest)` Copy this ReadablePoint into a destination Point
`void` | `getSize(WritableDimension dest)` Copy this ReadableDimension into a destination Dimension
`int` | `getWidth()` Gets the width.
`int` | `getX()` Gets the x.
`int` | `getY()` Gets the y.
`void` | `grow(int h, int v)` Resizes the `Rectangle` both horizontally and vertically.
`Rectangle` | `intersection(ReadableRectangle r, Rectangle dest)` Computes the intersection of this `Rectangle` with the specified `Rectangle`.
`boolean` | `intersects(ReadableRectangle r)` Determines whether or not this `Rectangle` and the specified `Rectangle` intersect.
`boolean` | `isEmpty()` Determines whether or not this `Rectangle` is empty.
`void` | `setBounds(int x, int y, int w, int h)` Sets the bounds of the rectangle
`void` | `setBounds(ReadablePoint p, ReadableDimension d)` Sets the bounds of the rectangle
`void` | `setBounds(ReadableRectangle r)` Sets the bounds of the rectangle
`void` | `setHeight(int height)` Sets the height.
`void` | `setLocation(int x, int y)`
`void` | `setLocation(ReadablePoint p)`
`void` | `setSize(int w, int h)`
`void` | `setSize(ReadableDimension d)`
`void` | `setWidth(int width)` Sets the width.
`void` | `setX(int x)` Sets the x.
`void` | `setY(int y)` Sets the y.
`java.lang.String` | `toString()` Debugging
`void` | `translate(int x, int y)` Translate the rectangle by an amount.
`void` | `translate(ReadablePoint point)` Translate the rectangle by an amount.
`WritableRectangle` | `union(ReadableRectangle r, WritableRectangle dest)` Computes the union of this `Rectangle` with the specified `Rectangle`.
`void` | `untranslate(ReadablePoint point)` Un-translate the rectangle by an amount.

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

Constructor Detail

### Rectangle

    public Rectangle()

  Constructor for Rectangle.

### Rectangle

    public Rectangle(int x,
                     int y,
                     int w,
                     int h)

  Constructor for Rectangle.

### Rectangle

    public Rectangle(ReadablePoint p,
                     ReadableDimension d)

  Constructor for Rectangle.

### Rectangle

    public Rectangle(ReadableRectangle r)

  Constructor for Rectangle.

Method Detail

### setLocation

    public void setLocation(int x,
                            int y)

  Specified by:
    `setLocation` in interface `WritablePoint`

### setLocation

    public void setLocation(ReadablePoint p)

  Specified by:
    `setLocation` in interface `WritablePoint`

### setSize

    public void setSize(int w,
                        int h)

  Specified by:
    `setSize` in interface `WritableDimension`

### setSize

    public void setSize(ReadableDimension d)

  Specified by:
    `setSize` in interface `WritableDimension`

### setBounds

    public void setBounds(int x,
                          int y,
                          int w,
                          int h)

  Description copied from interface: `WritableRectangle`
  Sets the bounds of the rectangle

  Specified by:
    `setBounds` in interface `WritableRectangle`
  Parameters:
    `x` - Position of rectangle on x axis
    `y` - Position of rectangle on y axis
    `w` - Width of rectangle
    `h` - Height of rectangle

### setBounds

    public void setBounds(ReadablePoint p,
                          ReadableDimension d)

  Description copied from interface: `WritableRectangle`
  Sets the bounds of the rectangle

  Specified by:
    `setBounds` in interface `WritableRectangle`

### setBounds

    public void setBounds(ReadableRectangle r)

  Description copied from interface: `WritableRectangle`
  Sets the bounds of the rectangle

  Specified by:
    `setBounds` in interface `WritableRectangle`

### getBounds

    public void getBounds(WritableRectangle dest)

  Description copied from interface: `ReadableRectangle`
  Copy this readable rectangle's bounds into a destination Rectangle

  Specified by:
    `getBounds` in interface `ReadableRectangle`
  Parameters:
    `dest` - The destination Rectangle, or null, to create a new Rectangle

### getLocation

    public void getLocation(WritablePoint dest)

  Description copied from interface: `ReadablePoint`
  Copy this ReadablePoint into a destination Point

  Specified by:
    `getLocation` in interface `ReadablePoint`
  Parameters:
    `dest` - The destination Point, or null, to create a new Point

### getSize

    public void getSize(WritableDimension dest)

  Description copied from interface: `ReadableDimension`
  Copy this ReadableDimension into a destination Dimension

  Specified by:
    `getSize` in interface `ReadableDimension`
  Parameters:
    `dest` - The destination

### translate

    public void translate(int x,
                          int y)

  Translate the rectangle by an amount.

  Parameters:
    `x` - The translation amount on the x axis
    `y` - The translation amount on the y axis

### translate

    public void translate(ReadablePoint point)

  Translate the rectangle by an amount.

  Parameters:
    `point` - The translation amount

### untranslate

    public void untranslate(ReadablePoint point)

  Un-translate the rectangle by an amount.

  Parameters:
    `point` - The translation amount

### contains

    public boolean contains(ReadablePoint p)

  Checks whether or not this `Rectangle` contains the specified `Point`.

  Parameters:
    `p` - the `Point` to test
  Returns:
    `true` if the `Point` (x, y) is 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 (x, y).

  Parameters:
    `X` - the specified x coordinate
    `Y` - the specified y coordinate
  Returns:
    `true` if the point (x, y) is inside this `Rectangle`; `false` otherwise.

### contains

    public boolean contains(ReadableRectangle 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).

  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.

### intersects

    public boolean intersects(ReadableRectangle 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.

### intersection

    public Rectangle intersection(ReadableRectangle r,
                                  Rectangle dest)

  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.

### union

    public WritableRectangle union(ReadableRectangle r,
                                   WritableRectangle dest)

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

### add

    public void add(int newx,
                    int newy)

  Adds a point, specified by the integer arguments `newx` and `newy`, to this `Rectangle`. The resulting `Rectangle` is the smallest `Rectangle` that contains both the original `Rectangle` and the specified point.

  After adding a point, a call to `contains` with the added point as an argument does not necessarily return `true`. The `contains` method does not return `true` for points on the right or bottom edges of a `Rectangle`. Therefore, if the added point falls on the right or bottom edge of the enlarged `Rectangle`, `contains` returns `false` for that point.

  Parameters:
    `newx` - the x coordinates of the new point
    `newy` - the y coordinates of the new point

### add

    public void add(ReadablePoint pt)

  Adds the specified `Point` to this `Rectangle`. The resulting `Rectangle` is the smallest `Rectangle` that contains both the original `Rectangle` and the specified `Point`.

  After adding a `Point`, a call to `contains` with the added `Point` as an argument does not necessarily return `true`. The `contains` method does not return `true` for points on the right or bottom edges of a `Rectangle`. Therefore if the added `Point` falls on the right or bottom edge of the enlarged `Rectangle`, `contains` returns `false` for that `Point`.

  Parameters:
    `pt` - the new `Point` to add to this `Rectangle`

### add

    public void add(ReadableRectangle r)

  Adds a `Rectangle` to this `Rectangle`. The resulting `Rectangle` is the union of the two rectangles.

  Parameters:
    `r` - the specified `Rectangle`

### grow

    public void grow(int h,
                     int v)

  Resizes the `Rectangle` both horizontally and vertically.

  This method modifies the `Rectangle` so that it is `h` units larger on both the left and right side, and `v` units larger at both the top and bottom.

  The new `Rectangle` has (`x - h`, `y - v`) as its top-left corner, a width of `width` `+` `2h`, and a height of `height` `+` `2v`.

  If negative values are supplied for `h` and `v`, the size of the `Rectangle` decreases accordingly. The `grow` method does not check whether the resulting values of `width` and `height` are non-negative.

  Parameters:
    `h` - the horizontal expansion
    `v` - the vertical expansion

### isEmpty

    public boolean isEmpty()

  Determines whether or not this `Rectangle` is empty. A `Rectangle` is empty if its width or its height is less than or equal to zero.

  Returns:
    `true` if this `Rectangle` is empty; `false` otherwise.

### equals

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

### toString

    public java.lang.String toString()

  Debugging

  Overrides:
    `toString` in class `java.lang.Object`
  Returns:
    a String

### getHeight

    public int getHeight()

  Gets the height.

  Specified by:
    `getHeight` in interface `ReadableDimension`
  Returns:
    Returns a int

### setHeight

    public void setHeight(int height)

  Sets the height.

  Specified by:
    `setHeight` in interface `WritableDimension`
  Parameters:
    `height` - The height to set

### getWidth

    public int getWidth()

  Gets the width.

  Specified by:
    `getWidth` in interface `ReadableDimension`
  Returns:
    Returns a int

### setWidth

    public void setWidth(int width)

  Sets the width.

  Specified by:
    `setWidth` in interface `WritableDimension`
  Parameters:
    `width` - The width to set

### getX

    public int getX()

  Gets the x.

  Specified by:
    `getX` in interface `ReadablePoint`
  Returns:
    Returns a int

### setX

    public void setX(int x)

  Sets the x.

  Specified by:
    `setX` in interface `WritablePoint`
  Parameters:
    `x` - The x to set

### getY

    public int getY()

  Gets the y.

  Specified by:
    `getY` in interface `ReadablePoint`
  Returns:
    Returns a int

### setY

    public void setY(int y)

  Sets the y.

  Specified by:
    `setY` in interface `WritablePoint`
  Parameters:
    `y` - The y to set

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

Copyright © 2002-2006 lwjgl.org. All Rights Reserved.