Class Region
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.

Field Summary
Modifier and TypeFieldDescriptionlong
the OS resource for the region (Warning: This field is platform dependent) 
Constructor Summary

Method Summary
Modifier and TypeMethodDescriptionvoid
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
Adds the given rectangle to the collection of polygons the receiver maintains to describe its area.void
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) Returnstrue
if the point specified by the arguments is inside the area specified by the receiver, andfalse
otherwise.boolean
Returnstrue
if the given point is inside the area specified by the receiver, andfalse
otherwise.boolean
Compares the argument to the receiver, and returns true if they represent the same object using a class specific comparison.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
Intersects the given rectangle to the collection of polygons the receiver maintains to describe its area.void
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) Returnstrue
if the rectangle described by the arguments intersects with any of the polygons the receiver maintains to describe its area, andfalse
otherwise.boolean
intersects
(Rectangle rect) Returnstrue
if the given rectangle intersects with any of the polygons the receiver maintains to describe its area andfalse
otherwise.boolean
Returnstrue
if the region has been disposed, andfalse
otherwise.boolean
isEmpty()
Returnstrue
if the receiver does not cover any area in the (x, y) coordinate plane, andfalse
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
Subtracts the given rectangle from the collection of polygons the receiver maintains to describe its area.void
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.toString()
Returns a string containing a concise, humanreadable 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 all of the polygons the receiver maintains to describe its area by the specified point.static Region
Invokes platform specific functionality to allocate a new region.Methods inherited from class org.eclipse.swt.graphics.Resource
dispose, getDevice, setNonDisposeHandler

Field Details

handle
public long handlethe OS resource for the region (Warning: This field is platform dependent)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.
 Restriction:
 This field is not intended to be referenced by clients.


Constructor Details

Region
public Region()Constructs a new empty region.You must dispose the region when it is no longer required.
 Throws:
SWTError
 ERROR_NO_HANDLES if a handle could not be obtained for region creation
 See Also:

Region
Constructs a new empty region.You must dispose the region when it is no longer required.
 Parameters:
device
 the device on which to allocate the region Throws:
IllegalArgumentException
 ERROR_NULL_ARGUMENT  if device is null and there is no current device
SWTError
 ERROR_NO_HANDLES if a handle could not be obtained for region creation
 Since:
 3.0
 See Also:


Method Details

add
public void add(int[] pointArray) Adds the given polygon to the collection of polygons the receiver maintains to describe its area. Parameters:
pointArray
 points that describe the polygon to merge with the receiver Throws:
IllegalArgumentException
 ERROR_NULL_ARGUMENT  if the argument is null
SWTException
 ERROR_GRAPHIC_DISPOSED  if the receiver has been disposed
 Since:
 3.0

add
Adds the given rectangle to the collection of polygons the receiver maintains to describe its area. Parameters:
rect
 the rectangle to merge with the receiver Throws:
IllegalArgumentException
 ERROR_NULL_ARGUMENT  if the argument is null
 ERROR_INVALID_ARGUMENT  if the rectangle's width or height is negative
SWTException
 ERROR_GRAPHIC_DISPOSED  if the receiver has been disposed

add
public 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. Parameters:
x
 the x coordinate of the rectangley
 the y coordinate of the rectanglewidth
 the width coordinate of the rectangleheight
 the height coordinate of the rectangle Throws:
IllegalArgumentException
 ERROR_INVALID_ARGUMENT  if the rectangle's width or height is negative
SWTException
 ERROR_GRAPHIC_DISPOSED  if the receiver has been disposed
 Since:
 3.1

add
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. Parameters:
region
 the region to merge Throws:
IllegalArgumentException
 ERROR_NULL_ARGUMENT  if the argument is null
 ERROR_INVALID_ARGUMENT  if the argument has been disposed
SWTException
 ERROR_GRAPHIC_DISPOSED  if the receiver has been disposed

contains
public boolean contains(int x, int y) Returnstrue
if the point specified by the arguments is inside the area specified by the receiver, andfalse
otherwise. Parameters:
x
 the x coordinate of the point to test for containmenty
 the y coordinate of the point to test for containment Returns:
true
if the region contains the point andfalse
otherwise Throws:
SWTException
 ERROR_GRAPHIC_DISPOSED  if the receiver has been disposed

contains
Returnstrue
if the given point is inside the area specified by the receiver, andfalse
otherwise. Parameters:
pt
 the point to test for containment Returns:
true
if the region contains the point andfalse
otherwise Throws:
IllegalArgumentException
 ERROR_NULL_ARGUMENT  if the argument is null
SWTException
 ERROR_GRAPHIC_DISPOSED  if the receiver has been disposed

equals
Compares the argument to the receiver, and returns true if they represent the same object using a class specific comparison. 
getBounds
Returns a rectangle which represents the rectangular union of the collection of polygons the receiver maintains to describe its area. Returns:
 a bounding rectangle for the region
 Throws:
SWTException
 ERROR_GRAPHIC_DISPOSED  if the receiver has been disposed
 See Also:

hashCode
public int hashCode()Returns an integer hash code for the receiver. Any two objects that returntrue
when passed toequals
must return the same value for this method. 
intersect
Intersects the given rectangle to the collection of polygons the receiver maintains to describe its area. Parameters:
rect
 the rectangle to intersect with the receiver Throws:
IllegalArgumentException
 ERROR_NULL_ARGUMENT  if the argument is null
 ERROR_INVALID_ARGUMENT  if the rectangle's width or height is negative
SWTException
 ERROR_GRAPHIC_DISPOSED  if the receiver has been disposed
 Since:
 3.0

intersect
public 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. Parameters:
x
 the x coordinate of the rectangley
 the y coordinate of the rectanglewidth
 the width coordinate of the rectangleheight
 the height coordinate of the rectangle Throws:
IllegalArgumentException
 ERROR_INVALID_ARGUMENT  if the rectangle's width or height is negative
SWTException
 ERROR_GRAPHIC_DISPOSED  if the receiver has been disposed
 Since:
 3.1

intersect
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. Parameters:
region
 the region to intersect Throws:
IllegalArgumentException
 ERROR_NULL_ARGUMENT  if the argument is null
 ERROR_INVALID_ARGUMENT  if the argument has been disposed
SWTException
 ERROR_GRAPHIC_DISPOSED  if the receiver has been disposed
 Since:
 3.0

intersects
public boolean intersects(int x, int y, int width, int height) Returnstrue
if the rectangle described by the arguments intersects with any of the polygons the receiver maintains to describe its area, andfalse
otherwise. Parameters:
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 rectangle Returns:
true
if the rectangle intersects with the receiver, andfalse
otherwise Throws:
SWTException
 ERROR_GRAPHIC_DISPOSED  if the receiver has been disposed
 See Also:

intersects
Returnstrue
if the given rectangle intersects with any of the polygons the receiver maintains to describe its area andfalse
otherwise. Parameters:
rect
 the rectangle to test for intersection Returns:
true
if the rectangle intersects with the receiver, andfalse
otherwise Throws:
IllegalArgumentException
 ERROR_NULL_ARGUMENT  if the argument is null
SWTException
 ERROR_GRAPHIC_DISPOSED  if the receiver has been disposed
 See Also:

isDisposed
public boolean isDisposed()Returnstrue
if the region has been disposed, andfalse
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. Specified by:
isDisposed
in classResource
 Returns:
true
when the region is disposed, andfalse
otherwise

isEmpty
public boolean isEmpty()Returnstrue
if the receiver does not cover any area in the (x, y) coordinate plane, andfalse
if the receiver does cover some area in the plane. Returns:
true
if the receiver is empty, andfalse
otherwise Throws:
SWTException
 ERROR_GRAPHIC_DISPOSED  if the receiver has been disposed

subtract
public void subtract(int[] pointArray) Subtracts the given polygon from the collection of polygons the receiver maintains to describe its area. Parameters:
pointArray
 points that describe the polygon to merge with the receiver Throws:
IllegalArgumentException
 ERROR_NULL_ARGUMENT  if the argument is null
SWTException
 ERROR_GRAPHIC_DISPOSED  if the receiver has been disposed
 Since:
 3.0

subtract
Subtracts the given rectangle from the collection of polygons the receiver maintains to describe its area. Parameters:
rect
 the rectangle to subtract from the receiver Throws:
IllegalArgumentException
 ERROR_NULL_ARGUMENT  if the argument is null
 ERROR_INVALID_ARGUMENT  if the rectangle's width or height is negative
SWTException
 ERROR_GRAPHIC_DISPOSED  if the receiver has been disposed
 Since:
 3.0

subtract
public 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. Parameters:
x
 the x coordinate of the rectangley
 the y coordinate of the rectanglewidth
 the width coordinate of the rectangleheight
 the height coordinate of the rectangle Throws:
IllegalArgumentException
 ERROR_INVALID_ARGUMENT  if the rectangle's width or height is negative
SWTException
 ERROR_GRAPHIC_DISPOSED  if the receiver has been disposed
 Since:
 3.1

subtract
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. Parameters:
region
 the region to subtract Throws:
IllegalArgumentException
 ERROR_NULL_ARGUMENT  if the argument is null
 ERROR_INVALID_ARGUMENT  if the argument has been disposed
SWTException
 ERROR_GRAPHIC_DISPOSED  if the receiver has been disposed
 Since:
 3.0

translate
public void translate(int x, int y) Translate all of the polygons the receiver maintains to describe its area by the specified point. Parameters:
x
 the x coordinate of the point to translatey
 the y coordinate of the point to translate Throws:
SWTException
 ERROR_GRAPHIC_DISPOSED  if the receiver has been disposed
 Since:
 3.1

translate
Translate all of the polygons the receiver maintains to describe its area by the specified point. Parameters:
pt
 the point to translate Throws:
IllegalArgumentException
 ERROR_NULL_ARGUMENT  if the argument is null
SWTException
 ERROR_GRAPHIC_DISPOSED  if the receiver has been disposed
 Since:
 3.1

toString
Returns a string containing a concise, humanreadable description of the receiver. 
win32_new
Invokes platform specific functionality to allocate a new region.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. Parameters:
device
 the device on which to allocate the regionhandle
 the handle for the region Returns:
 a new region object containing the specified device and handle
 Restriction:
 This method is not intended to be referenced by clients.
