|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectwyvern.lib.Rectangle
Represents a rectangle in a map.
| Field Summary | |
int |
height
|
int |
width
|
int |
x
|
int |
y
|
| Constructor Summary | |
Rectangle()
Constructs a new Rectangle |
|
Rectangle(int width,
int height)
Constructs a new Rectangle |
|
Rectangle(int x,
int y,
int width,
int height)
Constructs a new Rectangle |
|
Rectangle(Point p,
int width,
int height)
Constructs a new Rectangle |
|
Rectangle(Rectangle r)
Constructs a new Rectangle |
|
Rectangle(java.awt.Rectangle r)
Constructs a new Rectangle from an AWT 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(Point pt)
Adds the specified Point to this
Rectangle. |
void |
add(Rectangle r)
Adds a Rectangle to this Rectangle.
|
boolean |
contains(int x,
int y)
Returns true if the rectangle contains the specified point. |
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(Point p)
Returns true if the rectangle contains the specified point. |
boolean |
contains(Rectangle r)
Checks whether this Rectangle entirely contains
the Rectangle
at the specified location (X, Y) with the
specified dimensions (W, H). |
java.awt.Rectangle |
createAWTRectangle()
Returns an AWT version of this rectangle. |
boolean |
equals(java.lang.Object obj)
Checks whether two rectangles are equal. |
int |
getHeight()
Returns height |
Point |
getLocation()
Returns the upper-left corner of the rectangle. |
int |
getWidth()
Returns width. |
int |
getX()
Returns X coordinate. |
int |
getY()
Returns Y coordinate. |
int |
hashCode()
Returns the hashcode for this rectangle |
Rectangle |
intersection(Rectangle r)
Computes the intersection of this Rect with the
specified Rect. |
boolean |
intersects(Rectangle r)
Determines whether or not this Rectangle and the specified
Rectangle intersect. |
void |
setBounds(int x,
int y,
int width,
int height)
Reshapes the rectangle. |
java.lang.String |
toString()
Prints a formatted version of the rectangle. |
void |
translate(int dx,
int dy)
Translates this rectangle the indicated distance to the right (x) and down (y). |
Rectangle |
union(Rectangle r)
Computes the union of this Rectangle with the
specified Rectangle. |
| Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Field Detail |
public int x
public int y
public int width
public int height
| Constructor Detail |
public Rectangle()
public Rectangle(Rectangle r)
public Rectangle(int x,
int y,
int width,
int height)
x - x coordinatey - y coordinatewidth - the width of the Rectangleheight - the height of the Rectangle
public Rectangle(Point p,
int width,
int height)
p - the (x, y) coordinateswidth - the width of the Rectangleheight - the height of the Rectangle
public Rectangle(int width,
int height)
public Rectangle(java.awt.Rectangle r)
| Method Detail |
public int getY()
public int getX()
public int getWidth()
public int getHeight()
public Point getLocation()
public void setBounds(int x,
int y,
int width,
int height)
public void translate(int dx,
int dy)
dx - the distance to move this Rectangle
along the x axisdy - the distance to move this Rectangle
along the y axispublic boolean contains(Point p)
public boolean contains(int x,
int y)
public boolean contains(int X,
int Y,
int W,
int H)
Rectangle entirely contains
the Rectangle
at the specified location (X, Y) with the
specified dimensions (W, H).
X - x coordinateY - y coordinateW - the width of the RectangleH - the height of the Rectangle
true if the Rectangle specified by
(X, Y, W, H)
is entirely enclosed inside this Rectangle;
false otherwise.
(taken from JDK 1.3)public boolean contains(Rectangle r)
Rectangle entirely contains
the Rectangle
at the specified location (X, Y) with the
specified dimensions (W, H).
r - the rectangle to check
true if the Rectangle specified by
(X, Y, W, H)
is entirely enclosed inside this Rectangle;
false otherwise.public boolean intersects(Rectangle r)
Rectangle and the specified
Rectangle intersect. Two rectangles intersect if
their intersection is nonempty.
r - the specified Rectangle
true if the specified Rectangle
and this Rectangle insersect;
false otherwise.public Rectangle intersection(Rectangle r)
Rect with the
specified Rect. Returns a new Rect
that represents the intersection of the two rectangles.
r - the specified Rect
Rect contained in both the
specified Rect and in
thisRect.public Rectangle union(Rectangle r)
Rectangle with the
specified Rectangle. Returns a new
Rectangle that
represents the union of the two rectangles
r - the specified Rectangle
Rectangle containing both
the specified Rectangle and this
Rectangle.public boolean equals(java.lang.Object obj)
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.
obj - the Object to compare with
this Rectangle
true if the objects are equal;
false otherwise.public java.lang.String toString()
public int hashCode()
public java.awt.Rectangle createAWTRectangle()
public void add(int newx,
int newy)
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.
newx - new Point's x coordinatenewy - new Point's y coordinatepublic void add(Point pt)
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.
pt - the new Point to add to this
Rectanglepublic void add(Rectangle r)
Rectangle to this Rectangle.
The resulting Rectangle is the union of the two
rectangles.
r - the specified Rectangle
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||