public final class Region extends Resource
Application code must explicitly invoke the Region.dispose()
method to release the operating system resources managed by each instance
when those instances are no longer required.
Modifier and Type | Field and Description |
---|---|
int |
handle
the OS resource for the region
(Warning: This field is platform dependent)
IMPORTANT: This field is not part of the SWT
public API.
|
Constructor and Description |
---|
Region()
Constructs a new empty region.
|
Region(Device device)
Constructs a new empty region.
|
Region(Device device,
int handle)
Constructs a new region given a handle to the operating
system resources that it should represent.
|
Modifier and Type | Method and Description |
---|---|
void |
add(int[] pointArray)
Adds the given polygon to the collection of polygons
the receiver maintains to describe its area.
|
void |
add(int x,
int y,
int width,
int height)
Adds the given rectangle to the collection of polygons
the receiver maintains to describe its area.
|
void |
add(Rectangle rect)
Adds the given rectangle to the collection of polygons
the receiver maintains to describe its area.
|
void |
add(Region region)
Adds all of the polygons which make up the area covered
by the argument to the collection of polygons the receiver
maintains to describe its area.
|
boolean |
contains(int x,
int y)
Returns
true if the point specified by the
arguments is inside the area specified by the receiver,
and false otherwise. |
boolean |
contains(Point pt)
Returns
true if the given point is inside the
area specified by the receiver, and false
otherwise. |
(package private) void |
destroy() |
boolean |
equals(java.lang.Object object)
Compares the argument to the receiver, and returns true
if they represent the same object using a class
specific comparison.
|
Rectangle |
getBounds()
Returns a rectangle which represents the rectangular
union of the collection of polygons the receiver
maintains to describe its area.
|
int |
hashCode()
Returns an integer hash code for the receiver.
|
void |
intersect(int x,
int y,
int width,
int height)
Intersects the given rectangle to the collection of polygons
the receiver maintains to describe its area.
|
void |
intersect(Rectangle rect)
Intersects the given rectangle to the collection of polygons
the receiver maintains to describe its area.
|
void |
intersect(Region region)
Intersects all of the polygons which make up the area covered
by the argument to the collection of polygons the receiver
maintains to describe its area.
|
boolean |
intersects(int x,
int y,
int width,
int height)
Returns
true if the rectangle described by the
arguments intersects with any of the polygons the receiver
maintains to describe its area, and false otherwise. |
boolean |
intersects(Rectangle rect)
Returns
true if the given rectangle intersects
with any of the polygons the receiver maintains to describe
its area and false otherwise. |
boolean |
isDisposed()
Returns
true if the region has been disposed,
and false otherwise. |
boolean |
isEmpty()
Returns
true if the receiver does not cover any
area in the (x, y) coordinate plane, and false if
the receiver does cover some area in the plane. |
void |
subtract(int[] pointArray)
Subtracts the given polygon from the collection of polygons
the receiver maintains to describe its area.
|
void |
subtract(int x,
int y,
int width,
int height)
Subtracts the given rectangle from the collection of polygons
the receiver maintains to describe its area.
|
void |
subtract(Rectangle rect)
Subtracts the given rectangle from the collection of polygons
the receiver maintains to describe its area.
|
void |
subtract(Region region)
Subtracts all of the polygons which make up the area covered
by the argument from the collection of polygons the receiver
maintains to describe its area.
|
java.lang.String |
toString()
Returns a string containing a concise, human-readable
description of the receiver.
|
void |
translate(int x,
int y)
Translate all of the polygons the receiver maintains to describe
its area by the specified point.
|
void |
translate(Point pt)
Translate all of the polygons the receiver maintains to describe
its area by the specified point.
|
static Region |
win32_new(Device device,
int handle)
Invokes platform specific functionality to allocate a new region.
|
public int handle
IMPORTANT: This field is not part of the SWT public API. It is marked public only so that it can be shared within the packages provided by SWT. It is not available on all platforms and should never be accessed from application code.
public Region()
SWTError
- public Region(Device device)
You must dispose the region when it is no longer required.
device
- the device on which to allocate the regionjava.lang.IllegalArgumentException
- SWTError
- Resource.dispose()
Region(Device device, int handle)
handle
- the handle for the resultpublic void add(int[] pointArray)
pointArray
- points that describe the polygon to merge with the receiverjava.lang.IllegalArgumentException
- SWTException
- public void add(Rectangle rect)
rect
- the rectangle to merge with the receiverjava.lang.IllegalArgumentException
- SWTException
- public void add(int x, int y, int width, int height)
x
- the x coordinate of the rectangley
- the y coordinate of the rectanglewidth
- the width coordinate of the rectangleheight
- the height coordinate of the rectanglejava.lang.IllegalArgumentException
- SWTException
- public void add(Region region)
region
- the region to mergejava.lang.IllegalArgumentException
- SWTException
- public boolean contains(int x, int y)
true
if the point specified by the
arguments is inside the area specified by the receiver,
and false
otherwise.x
- the x coordinate of the point to test for containmenty
- the y coordinate of the point to test for containmenttrue
if the region contains the point and false
otherwiseSWTException
- public boolean contains(Point pt)
true
if the given point is inside the
area specified by the receiver, and false
otherwise.pt
- the point to test for containmenttrue
if the region contains the point and false
otherwisejava.lang.IllegalArgumentException
- SWTException
- public boolean equals(java.lang.Object object)
equals
in class java.lang.Object
object
- the object to compare with this objecttrue
if the object is the same as this object and false
otherwisehashCode()
public Rectangle getBounds()
SWTException
- Rectangle.union(org.eclipse.swt.graphics.Rectangle)
public int hashCode()
true
when passed to
equals
must return the same value for this
method.hashCode
in class java.lang.Object
equals(java.lang.Object)
public void intersect(Rectangle rect)
rect
- the rectangle to intersect with the receiverjava.lang.IllegalArgumentException
- SWTException
- public void intersect(int x, int y, int width, int height)
x
- the x coordinate of the rectangley
- the y coordinate of the rectanglewidth
- the width coordinate of the rectangleheight
- the height coordinate of the rectanglejava.lang.IllegalArgumentException
- SWTException
- public void intersect(Region region)
region
- the region to intersectjava.lang.IllegalArgumentException
- SWTException
- public boolean intersects(int x, int y, int width, int height)
true
if the rectangle described by the
arguments intersects with any of the polygons the receiver
maintains to describe its area, and false
otherwise.x
- the x coordinate of the origin of the rectangley
- the y coordinate of the origin of the rectanglewidth
- the width of the rectangleheight
- the height of the rectangletrue
if the rectangle intersects with the receiver, and false
otherwiseSWTException
- Rectangle.intersects(Rectangle)
public boolean intersects(Rectangle rect)
true
if the given rectangle intersects
with any of the polygons the receiver maintains to describe
its area and false
otherwise.rect
- the rectangle to test for intersectiontrue
if the rectangle intersects with the receiver, and false
otherwisejava.lang.IllegalArgumentException
- SWTException
- Rectangle.intersects(Rectangle)
public boolean isDisposed()
true
if the region has been disposed,
and false
otherwise.
This method gets the dispose state for the region.
When a region has been disposed, it is an error to
invoke any other method (except Resource.dispose()
) using the region.
isDisposed
in class Resource
true
when the region is disposed, and false
otherwisepublic boolean isEmpty()
true
if the receiver does not cover any
area in the (x, y) coordinate plane, and false
if
the receiver does cover some area in the plane.true
if the receiver is empty, and false
otherwiseSWTException
- public void subtract(int[] pointArray)
pointArray
- points that describe the polygon to merge with the receiverjava.lang.IllegalArgumentException
- SWTException
- public void subtract(Rectangle rect)
rect
- the rectangle to subtract from the receiverjava.lang.IllegalArgumentException
- SWTException
- public void subtract(int x, int y, int width, int height)
x
- the x coordinate of the rectangley
- the y coordinate of the rectanglewidth
- the width coordinate of the rectangleheight
- the height coordinate of the rectanglejava.lang.IllegalArgumentException
- SWTException
- public void subtract(Region region)
region
- the region to subtractjava.lang.IllegalArgumentException
- SWTException
- public void translate(int x, int y)
x
- the x coordinate of the point to translatey
- the y coordinate of the point to translateSWTException
- public void translate(Point pt)
pt
- the point to translatejava.lang.IllegalArgumentException
- SWTException
- public java.lang.String toString()
toString
in class java.lang.Object
public static Region win32_new(Device device, int handle)
IMPORTANT: This method is not part of the public
API for Region
. It is marked public only so that it
can be shared within the packages provided by SWT. It is not
available on all platforms, and should never be called from
application code.
device
- the device on which to allocate the regionhandle
- the handle for the region