|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectdanger.ui.Rect
public class 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
Bottom coordinate of the rectangle |
int |
left
Left coordinate of the rectangle |
int |
right
Right coordinate of the rectangle |
int |
top
Top coordinate of the rectangle |
| 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)
Modifies this rectangle to be the intersection of two rectangles. |
Rect |
clipAdjust(Rect this_rect,
Rect that_rect,
int deltaX,
int deltaY)
Modifies this rectangle to be the intersection of two rectangles, offset by a specified amount. |
boolean |
contains(int x,
int y)
Returns whether or not a rectangle envelopes a specific point |
boolean |
contains(Point p)
Returns whether or not a rectangle envelopes a specific point |
boolean |
contains(Rect r)
Returns whether or not a rectangle envelopes a specific rectangle |
boolean |
equals(Object rhs)
|
boolean |
equals(Rect r)
Determines whether this rectangle is the same as the specified rectangle. |
int |
getHeight()
Returns the height of a rectangle |
int |
getWidth()
Returns the width of a rectangle |
int |
hashCode()
|
void |
inset(int delta)
Adjusts all the sides of a rectangle by a given amount |
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)
Modifies one rectangle to be the intersection of it and another rectangle. |
boolean |
intersects(int inLeft,
int inTop,
int inRight,
int inBottom)
Returns whether or not a rectangle intersects another rectangle |
boolean |
intersects(Rect rect)
Returns whether or not a rectangle intersects another rectangle |
boolean |
isEmpty()
Determines whether this rectangle is empty. |
static int |
manhattanDistance(Rect r1,
Rect r2)
Given two rectangles, return the "distance" between them in Manhattan geometry. |
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 |
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)
Modify a rectangle in place, changing it to be the same as the the specified rectangle, translated by the specified horizontal and vertical amount |
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, finalize, getClass, 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)
base - the rectangle base the delta fromdeltaX - the horizontal deltadeltaY - the vertical deltapublic final void union(Rect r)
r - the rectangle to union with the current rect
public final Rect clip(Rect this_rect,
Rect that_rect)
this_rect - one of the rectangles to intersectthat_rect - one of the rectangles to intersect
public final Rect clipAdjust(Rect this_rect,
Rect that_rect,
int deltaX,
int deltaY)
deltaX and deltaY
decrease the x and y coordinates of the rectangle.
If the intersection is empty, this method may return a rectangle where the
left coordinate is greater than or equal to the right, and the top coordinate
is greater than or equal to the bottom.
this_rect - one of the rectangles to intersectthat_rect - one of the rectangles to intersectdeltaX - negative horizontal offsetdeltaY - negative vertical offset
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)
delta - amount to move in the sides of the rectpublic 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)
p - the point being checkedpublic final boolean contains(Rect r)
r - the rectangle being checkedpublic final boolean intersects(Rect rect)
rect - the rectangle being compared against
public final boolean intersects(int inLeft,
int inTop,
int inRight,
int inBottom)
inLeft - left coordinate of the rectangle being compared againstinTop - top coordinate of the rectangle being compared againstinRight - right coordinate of the rectangle being compared againstinBottom - bottom coordinate of the rectangle being compared against
public final Rect intersection(Rect inR,
Rect outResult)
clip(Rect,Rect). One difference is that this method
specifies a rectangle of (0,0,0,0) if the intersection is empty, whereas
the other method may not.
inR - one of the rectangles to intersectoutResult - one of the rectangles to intersect, and to place the result
in
outResult
public static int manhattanDistance(Rect r1,
Rect r2)
r1 - One of the rectangles to comparer2 - The other of the rectangles to compare
public final boolean isEmpty()
public final boolean equals(Rect r)
r - the rectangle to compare topublic final boolean equals(Object rhs)
equals in class Objectpublic final int hashCode()
hashCode in class Objectpublic String toString()
toString in class Object
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||