|
Build 1.0_r1(from source) | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectandroid.graphics.Rect
public final class Rect
Rect holds four integer coordinates for a rectangle. The rectangle is represented by the coordinates of its 4 edges (left, top, right bottom). These fields can be accessed directly. Use width() and height() to retrieve the rectangle's width and height. Note: most methods do not check to see that the coordinates are sorted correctly (i.e. left <= right and top <= bottom).
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from interface android.os.Parcelable |
|---|
Parcelable.Creator<T> |
| Field Summary | |
|---|---|
int |
bottom
|
static Parcelable.Creator<Rect> |
CREATOR
|
int |
left
|
int |
right
|
int |
top
|
| Fields inherited from interface android.os.Parcelable |
|---|
CONTENTS_FILE_DESCRIPTOR, PARCELABLE_WRITE_RETURN_VALUE |
| Constructor Summary | |
|---|---|
Rect()
Create a new empty Rect. |
|
Rect(int left,
int top,
int right,
int bottom)
Create a new rectangle with the specified coordinates. |
|
Rect(Rect r)
Create a new rectangle, initialized with the values in the specified rectangle (which is left unmodified). |
|
| Method Summary | |
|---|---|
int |
centerX()
|
int |
centerY()
|
boolean |
contains(int x,
int y)
Returns true if (x,y) is inside the rectangle. |
boolean |
contains(int left,
int top,
int right,
int bottom)
Returns true iff the 4 specified sides of a rectangle are inside or equal to this rectangle. |
boolean |
contains(Rect r)
Returns true iff the specified rectangle r is inside or equal to this rectangle. |
int |
describeContents()
Parcelable interface methods |
boolean |
equals(Object obj)
Compares the argument to the receiver, and returns true if they represent the same object using a class specific comparison. |
float |
exactCenterX()
|
float |
exactCenterY()
|
int |
height()
|
void |
inset(int dx,
int dy)
Inset the rectangle by (dx,dy). |
boolean |
intersect(int left,
int top,
int right,
int bottom)
If the rectangle specified by left,top,right,bottom intersects this rectangle, return true and set this rectangle to that intersection, otherwise return false and do not change this rectangle. |
boolean |
intersect(Rect r)
If the specified rectangle intersects this rectangle, return true and set this rectangle to that intersection, otherwise return false and do not change this rectangle. |
boolean |
intersects(int left,
int top,
int right,
int bottom)
Returns true if this rectangle intersects the specified rectangle. |
static boolean |
intersects(Rect a,
Rect b)
Returns true iff the two specified rectangles intersect. |
boolean |
isEmpty()
Returns true if the rectangle is empty (left >= right or top >= bottom) |
void |
offset(int dx,
int dy)
Offset the rectangle by adding dx to its left and right coordinates, and adding dy to its top and bottom coordinates. |
void |
offsetTo(int newLeft,
int newTop)
Offset the rectangle to a specific (left, top) position, keeping its width and height the same. |
void |
readFromParcel(Parcel in)
Set the rectangle's coordinates from the data stored in the specified parcel. |
void |
set(int left,
int top,
int right,
int bottom)
Set the rectangle's coordinates to the specified values. |
void |
set(Rect src)
Copy the coordinates from src into this rectangle. |
void |
setEmpty()
Set the rectangle to (0,0,0,0) |
boolean |
setIntersect(Rect a,
Rect b)
If rectangles a and b intersect, return true and set this rectangle to that intersection, otherwise return false and do not change this rectangle. |
void |
sort()
Swap top/bottom or left/right if there are flipped (i.e. |
String |
toString()
Returns a string containing a concise, human-readable description of the receiver. |
void |
union(int x,
int y)
Update this Rect to enclose itself and the [x,y] coordinate. |
void |
union(int left,
int top,
int right,
int bottom)
Update this Rect to enclose itself and the specified rectangle. |
void |
union(Rect r)
Update this Rect to enclose itself and the specified rectangle. |
int |
width()
|
void |
writeToParcel(Parcel out,
int flags)
Write this rectangle to the specified parcel. |
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public int left
public int top
public int right
public int bottom
public static final Parcelable.Creator<Rect> CREATOR
| Constructor Detail |
|---|
public Rect()
public Rect(int left,
int top,
int right,
int bottom)
left - The X coordinate of the left side of the rectagletop - The Y coordinate of the top of the rectangleright - The X coordinate of the right side of the rectaglebottom - The Y coordinate of the bottom of the rectanglepublic Rect(Rect r)
r - The rectangle whose coordinates are copied into the new
rectangle.| Method Detail |
|---|
public boolean equals(Object obj)
Object
equals in class Objectobj - Object the object to compare with this object.
true if the object is the same as this
object false if it is different from this object.Object.hashCode()public String toString()
Object
toString in class Objectpublic final boolean isEmpty()
public final int width()
public final int height()
public final int centerX()
public final int centerY()
public final float exactCenterX()
public final float exactCenterY()
public void setEmpty()
public void set(int left,
int top,
int right,
int bottom)
left - The X coordinate of the left side of the rectagletop - The Y coordinate of the top of the rectangleright - The X coordinate of the right side of the rectaglebottom - The Y coordinate of the bottom of the rectanglepublic void set(Rect src)
src - The rectangle whose coordinates are copied into this
rectangle.
public void offset(int dx,
int dy)
dx - The amount to add to the rectangle's left and right coordinatesdy - The amount to add to the rectangle's top and bottom coordinates
public void offsetTo(int newLeft,
int newTop)
newLeft - The new "left" coordinate for the rectanglenewTop - The new "top" coordinate for the rectangle
public void inset(int dx,
int dy)
dx - The amount to add(subtract) from the rectangle's left(right)dy - The amount to add(subtract) from the rectangle's top(bottom)
public boolean contains(int x,
int y)
x - The X coordinate of the point being tested for containmenty - The Y coordinate of the point being tested for containment
public boolean contains(int left,
int top,
int right,
int bottom)
left - The left side of the rectangle being tested for containmenttop - The top of the rectangle being tested for containmentright - The right side of the rectangle being tested for containmentbottom - The bottom of the rectangle being tested for containment
public boolean contains(Rect r)
r - The rectangle being tested for containment.
public boolean intersect(int left,
int top,
int right,
int bottom)
left - The left side of the rectangle being intersected with this
rectangletop - The top of the rectangle being intersected with this rectangleright - The right side of the rectangle being intersected with this
rectangle.bottom - The bottom of the rectangle being intersected with this
rectangle.
public boolean intersect(Rect r)
r - The rectangle being intersected with this rectangle.
public boolean setIntersect(Rect a,
Rect b)
a - The first rectangle being intersected withb - The second rectangle being intersected with
public boolean intersects(int left,
int top,
int right,
int bottom)
left - The left side of the rectangle being tested for intersectiontop - The top of the rectangle being tested for intersectionright - The right side of the rectangle being tested for
intersectionbottom - The bottom of the rectangle being tested for intersection
public static boolean intersects(Rect a,
Rect b)
a - The first rectangle being tested for intersectionb - The second rectangle being tested for intersection
public void union(int left,
int top,
int right,
int bottom)
left - The left edge being unioned with this rectangletop - The top edge being unioned with this rectangleright - The right edge being unioned with this rectanglebottom - The bottom edge being unioned with this rectanglepublic void union(Rect r)
r - The rectangle being unioned with this rectangle
public void union(int x,
int y)
x - The x coordinate of the point to add to the rectangley - The y coordinate of the point to add to the rectanglepublic void sort()
public int describeContents()
describeContents in interface Parcelable
public void writeToParcel(Parcel out,
int flags)
writeToParcel in interface Parcelableout - The parcel to write the rectangle's coordinates intoflags - Additional flags about how the object should be written.
May be 0 or Parcelable.PARCELABLE_WRITE_RETURN_VALUE.public void readFromParcel(Parcel in)
in - The parcel to read the rectangle's coordinates from
|
Build 1.0_r1(from source) | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||