Skip to content

Most visited

Recently visited

navigation
Added in API level 1

Region

public class Region
extends Object implements Parcelable

java.lang.Object
   ↳ android.graphics.Region


Summary

Nested classes

enum Region.Op

 

Inherited constants

From interface android.os.Parcelable

Fields

public static final Creator<Region> CREATOR

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.

String toString()

Returns a string containing a concise, human-readable description of this object.

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()

Invoked when the garbage collector has detected that this instance is no longer reachable.

Inherited methods

From class java.lang.Object
From interface android.os.Parcelable

Fields

CREATOR

Added in API level 1
Creator<Region> CREATOR

Public constructors

Region

Added in API level 1
Region ()

Create an empty region

Region

Added in API level 1
Region (Region region)

Return a copy of the specified region

Parameters
region Region

Region

Added in API level 1
Region (Rect r)

Return a region set to the specified rectangle

Parameters
r Rect

Region

Added in API level 1
Region (int left, 
                int top, 
                int right, 
                int bottom)

Return a region set to the specified rectangle

Parameters
left int
top int
right int
bottom int

Public methods

contains

Added in API level 1
boolean contains (int x, 
                int y)

Return true if the region contains the specified point

Parameters
x int
y int
Returns
boolean

describeContents

Added in API level 1
int describeContents ()

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

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

equals

Added in API level 1
boolean equals (Object obj)

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 Object: the object to compare this instance with.
Returns
boolean true if the specified object is equal to this Object; false otherwise.

getBoundaryPath

Added in API level 1
Path getBoundaryPath ()

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

Returns
Path

getBoundaryPath

Added in API level 1
boolean getBoundaryPath (Path path)

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

Parameters
path Path
Returns
boolean

getBounds

Added in API level 1
boolean getBounds (Rect r)

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

Parameters
r Rect
Returns
boolean

getBounds

Added in API level 1
Rect getBounds ()

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]

Returns
Rect

isComplex

Added in API level 1
boolean isComplex ()

Return true if the region contains more than one rectangle

Returns
boolean

isEmpty

Added in API level 1
boolean isEmpty ()

Return true if this region is empty

Returns
boolean

isRect

Added in API level 1
boolean isRect ()

Return true if the region contains a single rectangle

Returns
boolean

op

Added in API level 1
boolean op (Rect r, 
                Region.Op op)

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

Parameters
r Rect
op Region.Op
Returns
boolean

op

Added in API level 1
boolean op (int left, 
                int top, 
                int right, 
                int bottom, 
                Region.Op op)

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

Parameters
left int
top int
right int
bottom int
op Region.Op
Returns
boolean

op

Added in API level 1
boolean op (Region region, 
                Region.Op op)

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

Parameters
region Region
op Region.Op
Returns
boolean

op

Added in API level 1
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. Return true if the result is not empty.

Parameters
rect Rect
region Region
op Region.Op
Returns
boolean

op

Added in API level 1
boolean op (Region region1, 
                Region region2, 
                Region.Op op)

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

Parameters
region1 Region
region2 Region
op Region.Op
Returns
boolean

quickContains

Added in API level 1
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. 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.

Parameters
left int
top int
right int
bottom int
Returns
boolean

quickContains

Added in API level 1
boolean quickContains (Rect r)

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.

Parameters
r Rect
Returns
boolean

quickReject

Added in API level 1
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. Returning false is not a guarantee that they intersect, but returning true is a guarantee that they do not.

Parameters
left int
top int
right int
bottom int
Returns
boolean

quickReject

Added in API level 1
boolean quickReject (Region rgn)

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.

Parameters
rgn Region
Returns
boolean

quickReject

Added in API level 1
boolean quickReject (Rect r)

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.

Parameters
r Rect
Returns
boolean

set

Added in API level 1
boolean set (int left, 
                int top, 
                int right, 
                int bottom)

Set the region to the specified rectangle

Parameters
left int
top int
right int
bottom int
Returns
boolean

set

Added in API level 1
boolean set (Rect r)

Set the region to the specified rectangle

Parameters
r Rect
Returns
boolean

set

Added in API level 1
boolean set (Region region)

Set the region to the specified region.

Parameters
region Region
Returns
boolean

setEmpty

Added in API level 1
void setEmpty ()

Set the region to the empty region

setPath

Added in API level 1
boolean setPath (Path path, 
                Region clip)

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).

Parameters
path Path
clip Region
Returns
boolean

toString

Added in API level 1
String toString ()

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.

Returns
String a printable representation of this object.

translate

Added in API level 1
void translate (int dx, 
                int dy, 
                Region dst)

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.

Parameters
dx int
dy int
dst Region

translate

Added in API level 1
void translate (int dx, 
                int dy)

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

Parameters
dx int
dy int

union

Added in API level 1
boolean union (Rect r)

Parameters
r Rect
Returns
boolean

writeToParcel

Added in API level 1
void writeToParcel (Parcel p, 
                int flags)

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

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

Protected methods

finalize

Added in API level 1
void finalize ()

Invoked when the garbage collector has detected that this instance is no longer reachable. The default implementation does nothing, but this method can be overridden to free resources.

Note that objects that override finalize are significantly more expensive than objects that don't. Finalizers may be run a long time after the object is no longer reachable, depending on memory pressure, so it's a bad idea to rely on them for cleanup. Note also that finalizers are run on a single VM-wide finalizer thread, so doing blocking work in a finalizer is a bad idea. A finalizer is usually only necessary for a class that has a native peer and needs to call a native method to destroy that peer. Even then, it's better to provide an explicit close method (and implement Closeable), and insist that callers manually dispose of instances. This works well for something like files, but less well for something like a BigInteger where typical calling code would have to deal with lots of temporaries. Unfortunately, code that creates lots of temporaries is the worst kind of code from the point of view of the single finalizer thread.

If you must use finalizers, consider at least providing your own ReferenceQueue and having your own thread process that queue.

Unlike constructors, finalizers are not automatically chained. You are responsible for calling super.finalize() yourself.

Uncaught exceptions thrown by finalizers are ignored and do not terminate the finalizer thread. See Effective Java Item 7, "Avoid finalizers" for more.

Throws
Throwable
This site uses cookies to store your preferences for site-specific language and display options.

Hooray!

This class requires API level or higher

This doc is hidden because your selected API level for the documentation is . You can change the documentation API level with the selector above the left navigation.

For more information about specifying the API level your app requires, read Supporting Different Platform Versions.