public class

Region

extends Object
implements Parcelable
java.lang.Object
   ↳ android.graphics.Region

Summary

Nested Classes
enum Region.Op  
Constants
Creator<Region> CREATOR
[Expand]
Inherited Constants
From interface android.os.Parcelable
Public Constructors
Region()
Create an empty region
Region(Region region)
Return a copy of the specified region
Region(Rect r)
Return a region set to the specified rectangle
Region(int left, int top, int right, int bottom)
Return a region set to the specified rectangle
Public Methods
boolean contains(int x, int y)
Return true if the region contains the specified point
int describeContents()
Describe the kinds of special objects contained in this Parcelable's marshalled representation.
boolean equals(Object obj)
Compares this instance with the specified object and indicates if they are equal.
Path getBoundaryPath()
Return the boundary of the region as a new Path.
boolean getBoundaryPath(Path path)
Set the path to the boundary of the region.
boolean getBounds(Rect r)
Set the Rect to the bounds of the region.
Rect getBounds()
Return a new Rect set to the bounds of the region.
boolean isComplex()
Return true if the region contains more than one rectangle
boolean isEmpty()
Return true if this region is empty
boolean isRect()
Return true if the region contains a single rectangle
boolean op(Rect r, Region.Op op)
Perform the specified Op on this region and the specified rect.
boolean op(int left, int top, int right, int bottom, Region.Op op)
Perform the specified Op on this region and the specified rect.
boolean op(Region region, Region.Op op)
Perform the specified Op on this region and the specified region.
boolean op(Rect rect, Region region, Region.Op op)
Set this region to the result of performing the Op on the specified rect and region.
boolean op(Region region1, Region region2, Region.Op op)
Set this region to the result of performing the Op on the specified regions.
boolean quickContains(int left, int top, int right, int bottom)
Return true if the region is a single rectangle (not complex) and it contains the specified rectangle.
boolean quickContains(Rect r)
Return true if the region is a single rectangle (not complex) and it contains the specified rectangle.
boolean quickReject(int left, int top, int right, int bottom)
Return true if the region is empty, or if the specified rectangle does not intersect the region.
boolean quickReject(Region rgn)
Return true if the region is empty, or if the specified region does not intersect the region.
boolean quickReject(Rect r)
Return true if the region is empty, or if the specified rectangle does not intersect the region.
boolean set(int left, int top, int right, int bottom)
Set the region to the specified rectangle
boolean set(Rect r)
Set the region to the specified rectangle
boolean set(Region region)
Set the region to the specified region.
void setEmpty()
Set the region to the empty region
boolean setPath(Path path, Region clip)
Set the region to the area described by the path and clip.
void translate(int dx, int dy, Region dst)
Set the dst region to the result of translating this region by [dx, dy].
void translate(int dx, int dy)
Translate the region by [dx, dy].
final boolean union(Rect r)
void writeToParcel(Parcel p, int flags)
Write the region and its pixels to the parcel.
Protected Methods
void finalize()
Called before the object's memory is reclaimed by the VM.
[Expand]
Inherited Methods
From class java.lang.Object
From interface android.os.Parcelable

Constants

public static final Creator<Region> CREATOR

Since: API Level 1

Public Constructors

public Region ()

Since: API Level 1

Create an empty region

public Region (Region region)

Since: API Level 1

Return a copy of the specified region

public Region (Rect r)

Since: API Level 1

Return a region set to the specified rectangle

public Region (int left, int top, int right, int bottom)

Since: API Level 1

Return a region set to the specified rectangle

Public Methods

public boolean contains (int x, int y)

Since: API Level 1

Return true if the region contains the specified point

public int describeContents ()

Since: API Level 1

Describe the kinds of special objects contained in this Parcelable's marshalled representation.

Returns
  • a bitmask indicating the set of special object types marshalled by the Parcelable.

public boolean equals (Object obj)

Since: API Level 1

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.

Parameters
obj the object to compare this instance with.
Returns
  • true if the specified object is equal to this Object; false otherwise.

public Path getBoundaryPath ()

Since: API Level 1

Return the boundary of the region as a new Path. If the region is empty, the path will also be empty.

public boolean getBoundaryPath (Path path)

Since: API Level 1

Set the path to the boundary of the region. If the region is empty, the path will also be empty.

public boolean getBounds (Rect r)

Since: API Level 1

Set the Rect to the bounds of the region. If the region is empty, the Rect will be set to [0, 0, 0, 0]

public Rect getBounds ()

Since: API Level 1

Return a new Rect set to the bounds of the region. If the region is empty, the Rect will be set to [0, 0, 0, 0]

public boolean isComplex ()

Since: API Level 1

Return true if the region contains more than one rectangle

public boolean isEmpty ()

Since: API Level 1

Return true if this region is empty

public boolean isRect ()

Since: API Level 1

Return true if the region contains a single rectangle

public boolean op (Rect r, Region.Op op)

Since: API Level 1

Perform the specified Op on this region and the specified rect. Return true if the result of the op is not empty.

public boolean op (int left, int top, int right, int bottom, Region.Op op)

Since: API Level 1

Perform the specified Op on this region and the specified rect. Return true if the result of the op is not empty.

public boolean op (Region region, Region.Op op)

Since: API Level 1

Perform the specified Op on this region and the specified region. Return true if the result of the op is not empty.

public boolean op (Rect rect, Region region, Region.Op op)

Since: API Level 1

Set this region to the result of performing the Op on the specified rect and region. Return true if the result is not empty.

public boolean op (Region region1, Region region2, Region.Op op)

Since: API Level 1

Set this region to the result of performing the Op on the specified regions. Return true if the result is not empty.

public boolean quickContains (int left, int top, int right, int bottom)

Since: API Level 1

Return true if the region is a single rectangle (not complex) and it contains the specified rectangle. Returning false is not a guarantee that the rectangle is not contained by this region, but return true is a guarantee that the rectangle is contained by this region.

public boolean quickContains (Rect r)

Since: API Level 1

Return true if the region is a single rectangle (not complex) and it contains the specified rectangle. Returning false is not a guarantee that the rectangle is not contained by this region, but return true is a guarantee that the rectangle is contained by this region.

public boolean quickReject (int left, int top, int right, int bottom)

Since: API Level 1

Return true if the region is empty, or if the specified rectangle does not intersect the region. Returning false is not a guarantee that they intersect, but returning true is a guarantee that they do not.

public boolean quickReject (Region rgn)

Since: API Level 1

Return true if the region is empty, or if the specified region does not intersect the region. Returning false is not a guarantee that they intersect, but returning true is a guarantee that they do not.

public boolean quickReject (Rect r)

Since: API Level 1

Return true if the region is empty, or if the specified rectangle does not intersect the region. Returning false is not a guarantee that they intersect, but returning true is a guarantee that they do not.

public boolean set (int left, int top, int right, int bottom)

Since: API Level 1

Set the region to the specified rectangle

public boolean set (Rect r)

Since: API Level 1

Set the region to the specified rectangle

public boolean set (Region region)

Since: API Level 1

Set the region to the specified region.

public void setEmpty ()

Since: API Level 1

Set the region to the empty region

public boolean setPath (Path path, Region clip)

Since: API Level 1

Set the region to the area described by the path and clip. Return true if the resulting region is non-empty. This produces a region that is identical to the pixels that would be drawn by the path (with no antialiasing).

public void translate (int dx, int dy, Region dst)

Since: API Level 1

Set the dst region to the result of translating this region by [dx, dy]. If this region is empty, then dst will be set to empty.

public void translate (int dx, int dy)

Since: API Level 1

Translate the region by [dx, dy]. If the region is empty, do nothing.

public final boolean union (Rect r)

Since: API Level 1

public void writeToParcel (Parcel p, int flags)

Since: API Level 1

Write the region and its pixels to the parcel. The region can be rebuilt from the parcel by calling CREATOR.createFromParcel().

Parameters
p Parcel object to write the region data into
flags Additional flags about how the object should be written. May be 0 or PARCELABLE_WRITE_RETURN_VALUE.

Protected Methods

protected void finalize ()

Since: API Level 1

Called before the object's memory is reclaimed by the VM. This can only happen once the garbage collector has detected that the object is no longer reachable by any thread of the running application.

The method can be used to free system resources or perform other cleanup before the object is garbage collected. The default implementation of the method is empty, which is also expected by the VM, but subclasses can override finalize() as required. Uncaught exceptions which are thrown during the execution of this method cause it to terminate immediately but are otherwise ignored.

Note that the VM does guarantee that finalize() is called at most once for any object, but it doesn't guarantee when (if at all) finalize() will be called. For example, object B's finalize() can delay the execution of object A's finalize() method and therefore it can delay the reclamation of A's memory. To be safe, use a ReferenceQueue, because it provides more control over the way the VM deals with references during garbage collection.

Throws
Throwable