Most visited

Recently visited

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 instance's marshaled representation.

boolean equals(Object obj)

Indicates whether some other object is "equal to" this one.

boolean getBoundaryPath(Path path)

Set the path to the boundary of the region.

Path getBoundaryPath()

Return the boundary of the region as a new Path.

Rect getBounds()

Return a new Rect set to the bounds of the region.

boolean getBounds(Rect r)

Set the Rect 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(Region region1, Region region2, Region.Op op)

Set this region to the result of performing the Op on the specified regions.

boolean op(Rect r, Region.Op op)

Perform the specified Op on this region and the specified rect.

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 region, Region.Op op)

Perform the specified Op on this region and the specified region.

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 quickContains(Rect r)

Return true if the region is a single rectangle (not complex) and it contains the specified rectangle.

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 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 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 set(int left, int top, int right, int bottom)

Set the region to the specified rectangle

boolean set(Region region)

Set the region to the specified region.

boolean set(Rect r)

Set the region to the specified rectangle

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 representation of the 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()

Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.

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 instance's marshaled representation. For example, if the object will include a file descriptor in the output of writeToParcel(Parcel, int), the return value of this method must include the CONTENTS_FILE_DESCRIPTOR bit.

Returns
int a bitmask indicating the set of special object types marshaled by this Parcelable object instance.

equals

Added in API level 1
boolean equals (Object obj)

Indicates whether some other object is "equal to" this one.

The equals method implements an equivalence relation on non-null object references:

  • It is reflexive: for any non-null reference value x, x.equals(x) should return true.
  • It is symmetric: for any non-null reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any non-null reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.
  • It is consistent: for any non-null reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the objects is modified.
  • For any non-null reference value x, x.equals(null) should return false.

The equals method for class Object implements the most discriminating possible equivalence relation on objects; that is, for any non-null reference values x and y, this method returns true if and only if x and y refer to the same object (x == y has the value true).

Note that it is generally necessary to override the hashCode method whenever this method is overridden, so as to maintain the general contract for the hashCode method, which states that equal objects must have equal hash codes.

Parameters
obj Object: the reference object with which to compare.
Returns
boolean true if this object is the same as the obj argument; false otherwise.

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

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

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

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

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

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

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

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

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

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

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

Set the region to the specified region.

Parameters
region Region
Returns
boolean

set

Added in API level 1
boolean set (Rect r)

Set the region to the specified rectangle

Parameters
r Rect
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 representation of the object. In general, the toString method returns a string that "textually represents" this object. The result should be a concise but informative representation that is easy for a person to read. It is recommended that all subclasses override this method.

The toString method for class Object returns a string consisting of the name of the class of which the object is an instance, the at-sign character `@', and the unsigned hexadecimal representation of the hash code of the object. In other words, this method returns a string equal to the value of:

 getClass().getName() + '@' + Integer.toHexString(hashCode())
 

Returns
String a string representation of the 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 ()

Called by the garbage collector on an object when garbage collection determines that there are no more references to the object. A subclass overrides the finalize method to dispose of system resources or to perform other cleanup.

The general contract of finalize is that it is invoked if and when the JavaTM virtual machine has determined that there is no longer any means by which this object can be accessed by any thread that has not yet died, except as a result of an action taken by the finalization of some other object or class which is ready to be finalized. The finalize method may take any action, including making this object available again to other threads; the usual purpose of finalize, however, is to perform cleanup actions before the object is irrevocably discarded. For example, the finalize method for an object that represents an input/output connection might perform explicit I/O transactions to break the connection before the object is permanently discarded.

The finalize method of class Object performs no special action; it simply returns normally. Subclasses of Object may override this definition.

The Java programming language does not guarantee which thread will invoke the finalize method for any given object. It is guaranteed, however, that the thread that invokes finalize will not be holding any user-visible synchronization locks when finalize is invoked. If an uncaught exception is thrown by the finalize method, the exception is ignored and finalization of that object terminates.

After the finalize method has been invoked for an object, no further action is taken until the Java virtual machine has again determined that there is no longer any means by which this object can be accessed by any thread that has not yet died, including possible actions by other objects or classes which are ready to be finalized, at which point the object may be discarded.

The finalize method is never invoked more than once by a Java virtual machine for any given object.

Any exception thrown by the finalize method causes the finalization of this object to be halted, but is otherwise ignored.

Throws
Throwable

Hooray!