|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object | +--danger.ui.Rect
Various methods for constructing and manipulating a 2-dimension rectangle Danger rectangles are exclusive meaning that the upper-left and bottom-right points define the upper-left corner of a pixel rather than the center of a pixel. This has the advantage that the width of the rectangle is (right - left) and the height is (bottom - top). All rational people define rectangles this way.
| Field Summary | |
int |
bottom
Contains the values of the four sides of the rectangle Do not change the order of these; native code depends on it! |
int |
left
Contains the values of the four sides of the rectangle Do not change the order of these; native code depends on it! |
int |
right
Contains the values of the four sides of the rectangle Do not change the order of these; native code depends on it! |
int |
top
Contains the values of the four sides of the rectangle Do not change the order of these; native code depends on it! |
| Constructor Summary | |
Rect()
Generic constructor. |
|
Rect(int width,
int height)
Construct which creates a zero-based rectangle with a specific width and height. |
|
Rect(int left,
int top,
int right,
int bottom)
Constructor which creates a new rectangle and sets its ordinates to the specific values passed in. |
|
Rect(Rect r)
Copy constructor. |
|
| Method Summary | |
Rect |
clip(Rect this_rect,
Rect that_rect)
|
Rect |
clipAdjust(Rect this_rect,
Rect that_rect,
int deltaX,
int deltaY)
|
boolean |
contains(int x,
int y)
Returns whether or not a rectangle envelopes a specific point |
boolean |
contains(Point p)
|
boolean |
contains(Rect r)
|
boolean |
equals(Rect r)
|
int |
getHeight()
Returns the height of a rectangle |
int |
getWidth()
Returns the width of a rectangle |
void |
inset(int delta)
|
void |
inset(int deltax,
int deltay)
Adjusts all the sides of a rectangle by a given horizontal and vertical amount |
Rect |
intersection(Rect inR,
Rect outResult)
|
boolean |
intersects(int inLeft,
int inTop,
int inRight,
int inBottom)
|
boolean |
intersects(Rect rect)
Returns whether or not a rectangle intersects another rectangle |
boolean |
isEmpty()
|
static Rect |
newXYWH(int left,
int top,
int width,
int height)
"Constructor" which creates a new rectangle and sets its ordinates based on a left/top, and a width/height. |
void |
setPosition(int x,
int y)
Moves a rectangle to a specific horizontal and vertical position |
void |
setSize(int width,
int height)
Adjusts the width and height of a rectangle |
void |
setTo(int inLeft,
int inTop,
int inRight,
int inBottom)
Sets the left, top, right and bottom values of the rectangle |
void |
setTo(Rect inRect)
Sets the left, top, right and bottom values of the rectangle |
java.lang.String |
toString()
|
void |
translate(int inX,
int inY)
Move a rectangle by a specific horizontal and vertical amount |
void |
translate(Point inP)
Move a rectangle by a specific horizontal and vertical amount |
void |
translate(Rect base,
int deltaX,
int deltaY)
|
void |
union(Rect r)
Sets the dimensions of this rectangle to the union of itself and the specificed second rectangle. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
public int left
public int top
public int right
public int bottom
| Constructor Detail |
public Rect(Rect r)
r - the source rectangle to be used for the values
of the new rectanglepublic Rect()
public Rect(int width,
int height)
width - value for the right side of the rectheight - value for the bottom of the rect
public Rect(int left,
int top,
int right,
int bottom)
left - value for the left side of the recttop - value for the top of the rectright - value for the right side of the rectbottom - value for the bottom of the rect| Method Detail |
public static Rect newXYWH(int left,
int top,
int width,
int height)
left - value for the left side of the recttop - value for the top of the rectwidth - value for the width of the rectheight - value for the height of the rect
public final void translate(int inX,
int inY)
inX - distance to move the rect horizontallyinY - distance to move the rect verticallypublic final void translate(Point inP)
inP - distance to move the rect horizontally
public final void translate(Rect base,
int deltaX,
int deltaY)
public final void union(Rect r)
r - the rectangle to union with the current rect
public final Rect clip(Rect this_rect,
Rect that_rect)
public final Rect clipAdjust(Rect this_rect,
Rect that_rect,
int deltaX,
int deltaY)
public final void setPosition(int x,
int y)
x - new horizontal position for the recty - new vertical position for the rect
public final void setSize(int width,
int height)
width - new width for the rectheight - new height for the rectpublic final void setTo(Rect inRect)
inRect - rectangle to grab new values from
public final void setTo(int inLeft,
int inTop,
int inRight,
int inBottom)
inLeft - new value for left fieldinTop - new value for top fieldinRight - new value for right fieldinBottom - new value for bottom field
public final void inset(int deltax,
int deltay)
deltax - amount to move in the left and right sides of the rectdeltay - amount to move in the top and bottom of the rectpublic final void inset(int delta)
public final int getWidth()
public final int getHeight()
public final boolean contains(int x,
int y)
x - the horizontal offset of the point being checkedy - the vertical offset of the point being checkedpublic final boolean contains(Point p)
public final boolean contains(Rect r)
public final boolean intersects(Rect rect)
rect - the rectangle being compared against
public final boolean intersects(int inLeft,
int inTop,
int inRight,
int inBottom)
public final Rect intersection(Rect inR,
Rect outResult)
public final boolean isEmpty()
public final boolean equals(Rect r)
public java.lang.String toString()
toString in class java.lang.Object
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||