java.lang.Object | |
↳ | android.graphics.RectF |
RectF holds four float 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).
[Expand]
Inherited Constants | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From interface
android.os.Parcelable
|
Fields | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
CREATOR | |||||||||||
bottom | |||||||||||
left | |||||||||||
right | |||||||||||
top |
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Create a new empty RectF.
| |||||||||||
Create a new rectangle with the specified coordinates.
| |||||||||||
Create a new rectangle, initialized with the values in the specified
rectangle (which is left unmodified).
| |||||||||||
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Returns true iff the 4 specified sides of a rectangle are inside or equal
to this rectangle.
| |||||||||||
Returns true if (x,y) is inside the rectangle.
| |||||||||||
Returns true iff the specified rectangle r is inside or equal to this
rectangle.
| |||||||||||
Parcelable interface methods
| |||||||||||
Compares this instance with the specified object and indicates if they
are equal.
| |||||||||||
Returns an integer hash code for this object.
| |||||||||||
Inset the rectangle by (dx,dy).
| |||||||||||
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.
| |||||||||||
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.
| |||||||||||
Returns true iff the two specified rectangles intersect.
| |||||||||||
Returns true if this rectangle intersects the specified rectangle.
| |||||||||||
Returns true if the rectangle is empty (left >= right or top >= bottom)
| |||||||||||
Offset the rectangle by adding dx to its left and right coordinates, and
adding dy to its top and bottom coordinates.
| |||||||||||
Offset the rectangle to a specific (left, top) position,
keeping its width and height the same.
| |||||||||||
Set the rectangle's coordinates from the data stored in the specified
parcel.
| |||||||||||
Set the dst integer Rect by rounding this rectangle's coordinates
to their nearest integer values.
| |||||||||||
Set the dst integer Rect by rounding "out" this rectangle, choosing the
floor of top and left, and the ceiling of right and bottom.
| |||||||||||
Set the rectangle's coordinates to the specified values.
| |||||||||||
Copy the coordinates from src into this rectangle.
| |||||||||||
Copy the coordinates from src into this rectangle.
| |||||||||||
Set the rectangle to (0,0,0,0)
| |||||||||||
If rectangles a and b intersect, return true and set this rectangle to
that intersection, otherwise return false and do not change this
rectangle.
| |||||||||||
Swap top/bottom or left/right if there are flipped (i.e.
| |||||||||||
Return a string representation of the rectangle in a compact form.
| |||||||||||
Returns a string containing a concise, human-readable description of this
object.
| |||||||||||
Update this Rect to enclose itself and the specified rectangle.
| |||||||||||
Update this Rect to enclose itself and the specified rectangle.
| |||||||||||
Update this Rect to enclose itself and the [x,y] coordinate.
| |||||||||||
Write this rectangle to the specified parcel.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
java.lang.Object
| |||||||||||
From interface
android.os.Parcelable
|
Create a new empty RectF. All coordinates are initialized to 0.
Create a new rectangle with the specified coordinates. Note: no range checking is performed, so the caller must ensure that left <= right and top <= bottom.
left | The X coordinate of the left side of the rectangle |
---|---|
top | The Y coordinate of the top of the rectangle |
right | The X coordinate of the right side of the rectangle |
bottom | The Y coordinate of the bottom of the rectangle |
Create a new rectangle, initialized with the values in the specified rectangle (which is left unmodified).
r | The rectangle whose coordinates are copied into the new rectangle. |
---|
Returns true iff the 4 specified sides of a rectangle are inside or equal to this rectangle. i.e. is this rectangle a superset of the specified rectangle. An empty rectangle never contains another rectangle.
left | The left side of the rectangle being tested for containment |
---|---|
top | The top of the rectangle being tested for containment |
right | The right side of the rectangle being tested for containment |
bottom | The bottom of the rectangle being tested for containment |
Returns true if (x,y) is inside the rectangle. The left and top are considered to be inside, while the right and bottom are not. This means that for a x,y to be contained: left <= x < right and top <= y < bottom. An empty rectangle never contains any point.
x | The X coordinate of the point being tested for containment |
---|---|
y | The Y coordinate of the point being tested for containment |
Returns true iff the specified rectangle r is inside or equal to this rectangle. An empty rectangle never contains another rectangle.
r | The rectangle being tested for containment. |
---|
Parcelable interface methods
Compares this instance with the specified object and indicates if they
are equal. In order to be equal, o
must represent the same object
as this instance using a class-specific comparison. The general contract
is that this comparison should be reflexive, symmetric, and transitive.
Also, no object reference other than null is equal to null.
The default implementation returns true
only if this ==
o
. See Writing a correct
equals
method
if you intend implementing your own equals
method.
The general contract for the equals
and hashCode()
methods is that if equals
returns true
for
any two objects, then hashCode()
must return the same value for
these objects. This means that subclasses of Object
usually
override either both methods or neither of them.
o | the object to compare this instance with. |
---|
true
if the specified object is equal to this Object
; false
otherwise.Returns an integer hash code for this object. By contract, any two
objects for which equals(Object)
returns true
must return
the same hash code value. This means that subclasses of Object
usually override both methods or neither method.
Note that hash values must not change over time unless information used in equals comparisons also changes.
See Writing a correct
hashCode
method
if you intend implementing your own hashCode
method.
Inset the rectangle by (dx,dy). If dx is positive, then the sides are moved inwards, making the rectangle narrower. If dx is negative, then the sides are moved outwards, making the rectangle wider. The same holds true for dy and the top and bottom.
dx | The amount to add(subtract) from the rectangle's left(right) |
---|---|
dy | The amount to add(subtract) from the rectangle's top(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. No check is performed to see if either rectangle is empty. Note: To just test for intersection, use intersects()
left | The left side of the rectangle being intersected with this rectangle |
---|---|
top | The top of the rectangle being intersected with this rectangle |
right | The right side of the rectangle being intersected with this rectangle. |
bottom | The bottom of the rectangle being intersected with this rectangle. |
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. No check is performed to see if either rectangle is empty. To just test for intersection, use intersects()
r | The rectangle being intersected with this rectangle. |
---|
Returns true iff the two specified rectangles intersect. In no event are either of the rectangles modified. To record the intersection, use intersect() or setIntersect().
a | The first rectangle being tested for intersection |
---|---|
b | The second rectangle being tested for intersection |
Returns true if this rectangle intersects the specified rectangle. In no event is this rectangle modified. No check is performed to see if either rectangle is empty. To record the intersection, use intersect() or setIntersect().
left | The left side of the rectangle being tested for intersection |
---|---|
top | The top of the rectangle being tested for intersection |
right | The right side of the rectangle being tested for intersection |
bottom | The bottom of the rectangle being tested for intersection |
Returns true if the rectangle is empty (left >= right or top >= bottom)
Offset the rectangle by adding dx to its left and right coordinates, and adding dy to its top and bottom coordinates.
dx | The amount to add to the rectangle's left and right coordinates |
---|---|
dy | The amount to add to the rectangle's top and bottom coordinates |
Offset the rectangle to a specific (left, top) position, keeping its width and height the same.
newLeft | The new "left" coordinate for the rectangle |
---|---|
newTop | The new "top" coordinate for the rectangle |
Set the rectangle's coordinates from the data stored in the specified parcel. To write a rectangle to a parcel, call writeToParcel().
in | The parcel to read the rectangle's coordinates from |
---|
Set the dst integer Rect by rounding this rectangle's coordinates to their nearest integer values.
Set the dst integer Rect by rounding "out" this rectangle, choosing the floor of top and left, and the ceiling of right and bottom.
Set the rectangle's coordinates to the specified values. Note: no range checking is performed, so it is up to the caller to ensure that left <= right and top <= bottom.
left | The X coordinate of the left side of the rectangle |
---|---|
top | The Y coordinate of the top of the rectangle |
right | The X coordinate of the right side of the rectangle |
bottom | The Y coordinate of the bottom of the rectangle |
Copy the coordinates from src into this rectangle.
src | The rectangle whose coordinates are copied into this rectangle. |
---|
Copy the coordinates from src into this rectangle.
src | The rectangle whose coordinates are copied into this rectangle. |
---|
If rectangles a and b intersect, return true and set this rectangle to that intersection, otherwise return false and do not change this rectangle. No check is performed to see if either rectangle is empty. To just test for intersection, use intersects()
a | The first rectangle being intersected with |
---|---|
b | The second rectangle being intersected with |
Swap top/bottom or left/right if there are flipped (i.e. left > right and/or top > bottom). This can be called if the edges are computed separately, and may have crossed over each other. If the edges are already correct (i.e. left <= right and top <= bottom) then nothing is done.
Return a string representation of the rectangle in a compact form.
Returns a string containing a concise, human-readable description of this object. Subclasses are encouraged to override this method and provide an implementation that takes into account the object's type and data. The default implementation is equivalent to the following expression:
getClass().getName() + '@' + Integer.toHexString(hashCode())
See Writing a useful
toString
method
if you intend implementing your own toString
method.
Update this Rect to enclose itself and the specified rectangle. If the specified rectangle is empty, nothing is done. If this rectangle is empty it is set to the specified rectangle.
left | The left edge being unioned with this rectangle |
---|---|
top | The top edge being unioned with this rectangle |
right | The right edge being unioned with this rectangle |
bottom | The bottom edge being unioned with this rectangle |
Update this Rect to enclose itself and the specified rectangle. If the specified rectangle is empty, nothing is done. If this rectangle is empty it is set to the specified rectangle.
r | The rectangle being unioned with this rectangle |
---|
Update this Rect to enclose itself and the [x,y] coordinate. There is no check to see that this rectangle is non-empty.
x | The x coordinate of the point to add to the rectangle |
---|---|
y | The y coordinate of the point to add to the rectangle |
Write this rectangle to the specified parcel. To restore a rectangle from a parcel, use readFromParcel()
out | The parcel to write the rectangle's coordinates into |
---|---|
flags | Additional flags about how the object should be written.
May be 0 or PARCELABLE_WRITE_RETURN_VALUE .
|