|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
java.lang.Object | +--element.Rect
An implementation of a simple graphics rectangle.
| Field Summary | |
protected int |
height
The height of the rectangle. |
protected int |
left
The left side of the rectangle. |
protected int |
top
The top side of the rectangle. |
protected int |
width
The width of the rectangle. |
| Constructor Summary | |
Rect()
Constructs a trivial rectangle, about the origin. |
|
Rect(Drawable o)
Construct a rectangle from the bounding box of another drawable object. |
|
Rect(int cx,
int cy,
int r)
Construct a square centered about (cx,cy), with radius r. |
|
Rect(int x,
int y,
int w,
int h)
Construct a rectangle with upper left (x,y) and dimensions (w,h). |
|
Rect(Pt p,
int r)
Construct a square with radius r, centered about a point p. |
|
Rect(Pt p1,
Pt p2)
Constructs the rectangle determined by two points, p1 and p2. |
|
| Method Summary | |
int |
bottom()
Returns the bottom coordinate of the rectangle |
void |
bottom(int y)
Sets the bottom side of rectangle. |
Pt |
center()
Returns the center point of the rectangle. |
void |
center(Pt p)
Sets the center point of the rectangle. |
void |
clearOn(DrawingWindow d)
Erase rectangle from the drawing window d. |
java.lang.Object |
clone()
return a distinct copy of this rectangle |
boolean |
contains(Pt p)
Returns true if p is contained within rectangle |
void |
drawOn(DrawingWindow d)
Draw (in the current mode) the rectangle on the drawing window |
boolean |
equals(java.lang.Object other)
Return true iff this rectangle equals the other |
void |
extend(int dx,
int dy)
Moves the sides of the rectangle outward by dx and dy. |
void |
fillOn(DrawingWindow d)
Draw a filled rectangle (in the current mode) on drawing window d. |
int |
hashCode()
Return an integer for use as a hash code |
int |
height()
Returns the height of the rectangle. |
void |
height(int h)
Sets the height of the rectangle. |
int |
left()
Return the left coordinate of the rectangle. |
void |
left(int x)
Sets the left side of the rectangle. |
void |
move(int dx,
int dy)
Moves the rectangle in the direction (dx,dy). |
void |
moveTo(int left,
int top)
Moves the top-left coordinate of the rectangle to (left,top). |
void |
moveTo(Pt p)
Moves the top-left coordinate to point p |
java.awt.Rectangle |
Rectangle()
Construct an AWT rectangle from this rect. |
int |
right()
Returns right coordinate of the rectangle |
void |
right(int x)
Sets the right coordinate of rectangle. |
int |
top()
Returns the top coordinate of the rectangle |
void |
top(int y)
Sets the top side of the rectangle. |
java.lang.String |
toString()
Construct a string representation of this rectangle |
int |
width()
Returns the width of the rectangle. |
void |
width(int w)
Sets the width of the rectangle. |
| Methods inherited from class java.lang.Object |
finalize,
getClass,
notify,
notifyAll,
wait,
wait,
wait |
| Field Detail |
protected int left
protected int top
protected int width
protected int height
| Constructor Detail |
public Rect()
public Rect(Pt p1,
Pt p2)
p1 - one corner of the rectanglep2 - the opposite corner of the rectanglepublic Rect(Drawable o)
o - an object to be used as the basis for the constructed rect.
public Rect(int cx,
int cy,
int r)
cx - the x coordinate of the centercy - the y coordinate of the centerr - the radius of the rectangle
public Rect(Pt p,
int r)
p - the center of the squarer - the radius of the square
public Rect(int x,
int y,
int w,
int h)
x - the left of the rectangley - the top of the rectanglew - the width of the rectangleh - the height of the rectangle| Method Detail |
public boolean contains(Pt p)
p - the point to be consideredpublic int left()
public int top()
public int right()
public int bottom()
public int width()
public int height()
public void width(int w)
w - the desired width.public void height(int h)
h - the desired height.public void left(int x)
x - the desired left side.public void top(int y)
y - the new top coordinate.public void bottom(int y)
y - the new bottom coordinate.public void right(int x)
x - the new right coordinate.public Pt center()
public void center(Pt p)
p - the new center point of the rectangle
public void move(int dx,
int dy)
dx - the horizontal change in positiondy - the vertical change in position
public void moveTo(int left,
int top)
left - the new left coordinatetop - the new top coordinatepublic void moveTo(Pt p)
p - the new top left position
public void extend(int dx,
int dy)
dx - the change in horizontal coordinates - positive is outwarddy - the change in vertical coordinates - positive is outwardpublic void fillOn(DrawingWindow d)
d - the target drawing window.DrawingWindow.fill(element.Drawable),
DrawingWindow.paintMode(),
DrawingWindow.invertMode()public void clearOn(DrawingWindow d)
d - the target drawing windowDrawingWindow.clear(element.Drawable)public void drawOn(DrawingWindow d)
d - the target drawing windowDrawingWindow.paintMode(),
DrawingWindow.invertMode(),
DrawingWindow.draw(element.Drawable)public int hashCode()
public boolean equals(java.lang.Object other)
other - another valid rectanglepublic java.lang.Object clone()
public java.awt.Rectangle Rectangle()
Rectanglepublic java.lang.String toString()
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||