public class Region extends Object
| 限定符和类型 | 类 | 说明 |
|---|---|---|
static class |
Region.Op |
Enumerates operation types.
|
| 构造器 | 说明 |
|---|---|
Region() |
Default constructor used to create a
Region instance. |
Region(Region srcRegion) |
A constructor used to create a
Region instance by using an existing Region object. |
Region(Rect rect) |
A constructor used to create a
Region instance by using a specified rectangle. |
| 限定符和类型 | 方法 | 说明 |
|---|---|---|
void |
clear() |
Clears this
Region. |
boolean |
contains(int x,
int y) |
Checks whether the current region contains the specified point.
|
Path |
getBoundaryPath() |
Obtains the boundary path of this
Region. |
boolean |
getBoundaryPath(Path path) |
Obtains the boundary path of this
Region and sets it to a specified Path object. |
Rect |
getBounds() |
Obtains the boundary rectangle of this
Region. |
boolean |
getBounds(Rect rect) |
Obtains the boundary rectangle of this
Region and sets it to a specified Rect object. |
boolean |
isComplex() |
Checks whether this region contains multiple rectangles.
|
boolean |
isEmpty() |
Checks whether the current region is empty.
|
boolean |
isRect() |
Checks whether this region contains a rectangle.
|
boolean |
op(int left,
int top,
int right,
int bottom,
Region.Op op) |
Performs the specified operation on the current region and a rectangle specified by coordinates.
|
boolean |
op(Region region,
Region.Op op) |
Performs the specified operation on the current region and the specified region.
|
boolean |
op(Region regionA,
Region regionB,
Region.Op op) |
Performs the specified operation on two specified regions.
|
boolean |
op(Rect rect,
Region.Op op) |
Performs the specified operation on the current region and the specified rectangle.
|
boolean |
op(Rect rect,
Region region,
Region.Op op) |
Performs the specified operation on the specified rectangle and region.
|
boolean |
quickContains(Rect r) |
Checks whether this region contains a specified rectangle.
|
boolean |
quickReject(int left,
int top,
int right,
int bottom) |
Checks whether the current region is empty or does not intersect the rectangle specified by coordinates.
|
boolean |
quickReject(Region region) |
Checks whether the current region is empty or does not intersect the specified region.
|
boolean |
quickReject(Rect rect) |
Checks whether the current region is empty or does not intersect the specified rectangle.
|
boolean |
setPath(Path path,
Region clip) |
Obtains the intersection formed by a specified path and clip region.
|
boolean |
setRect(Rect r) |
Sets this region to a specified rectangle.
|
boolean |
setRegion(Region region) |
Sets this region to a specified region.
|
String |
toString() |
Obtains a string representation of this
Region object. |
void |
translate(int dx,
int dy,
Region dst) |
Translates this region by a specified distance.
|
boolean |
union(Rect rect) |
Merges a specified rectangle into this
Region. |
public Region()
Region instance.public Region(Region srcRegion)
Region instance by using an existing Region object.srcRegion - Indicates the existing Region object to use.public Region(Rect rect)
Region instance by using a specified rectangle.rect - Indicates the specified rectangle.public final boolean union(Rect rect)
Region.rect - Indicates the specified rectangle.true if the operation is successful; returns false otherwise.public void clear()
Region.public Rect getBounds()
Region.public boolean getBounds(Rect rect)
Region and sets it to a specified Rect object.rect - Indicates the Rect object to hold the boundary rectangle.true if the operation is successful; returns false otherwise.public Path getBoundaryPath()
Region.public boolean getBoundaryPath(Path path)
Region and sets it to a specified Path object.path - Indicates the Path object to hold the boundary path.true if the operation is successful; returns false otherwise.public boolean op(Region regionA, Region regionB, Region.Op op)
If successful, the operation will take effect on the current Region.
regionA - Indicates the first region.regionB - Indicates the second region.op - Indicates the operation to be performed.true if the operation is successful; returns false otherwise.public boolean op(Rect rect, Region region, Region.Op op)
If successful, the operation will take effect on the current Region.
rect - Indicates the specified rectangle.region - Indicates the specified region.op - Indicates the operation to be performed.true if the operation is successful; returns false otherwise.public boolean op(Region region, Region.Op op)
region - Indicates the specified region.op - Indicates the operation to be performed.true if the operation is successful; returns false otherwise.public boolean op(int left,
int top,
int right,
int bottom,
Region.Op op)
left - Indicates the X coordinate of the upper left corner of the specified rectangle.top - Indicates the Y coordinate of the upper left corner of the specified rectangle.right - Indicates the X coordinate of the lower right corner of the specified rectangle.bottom - Indicates the Y coordinate of the lower right corner of the specified rectangle.op - Indicates the operation to be performed.true if the operation is successful; returns false otherwise.public boolean op(Rect rect, Region.Op op)
rect - Indicates the specified rectangle.op - Indicates the operation to be performed.true if the operation is successful; returns false otherwise.public boolean contains(int x,
int y)
x - Indicates the X coordinate of the specified point.y - Indicates the Y coordinate of the specified point.true if the current region contains the specified point; returns false otherwise.public String toString()
Region object.public boolean quickReject(int left,
int top,
int right,
int bottom)
left - Indicates the X coordinate of the upper left corner of the specified rectangle.top - Indicates the Y coordinate of the upper left corner of the specified rectangle.right - Indicates the X coordinate of the lower right corner of the specified rectangle.bottom - Indicates the Y coordinate of the lower right corner of the specified rectangle.true if the current region is empty or does not intersect the rectangle
specified by coordinates; returns false otherwise.public boolean quickReject(Rect rect)
rect - Indicates the specified rectangle.true if the current region is empty or does not intersect the specified rectangle;
returns false otherwise.public boolean quickReject(Region region)
region - Indicates the specified region.true if the current region is empty or does not intersect the specified region;
returns false otherwise.public boolean isEmpty()
true if the current region is empty; returns false otherwise.public boolean setRect(Rect r)
r - Indicates the specified rectangle.true if the rectangle is not empty; returns false otherwise.public boolean setRegion(Region region)
region - Indicates the specified region.true if the region is not empty; returns false otherwise.public boolean isRect()
true if this region contains a rectangle; returns false otherwise.public boolean isComplex()
true if this region contains multiple rectangles; returns false otherwise.public boolean setPath(Path path, Region clip)
path - Indicates the specified path.clip - Indicates the clip region.true if the resulting region is not empty; returns false otherwise.public boolean quickContains(Rect r)
r - Indicates the specified rectangle.true if this region contains the specified rectangle; returns false otherwise.public void translate(int dx,
int dy,
Region dst)
dx - Indicates the offset of the region on the x-axis.dy - Indicates the offset of the region on the y-axis.dst - Indicates the destination region after translation.