Package org.eclipse.swt.graphics
Class Region
java.lang.Object
org.eclipse.swt.graphics.Resource
org.eclipse.swt.graphics.Region
Instances of this class represent areas of an x-y coordinate
 system that are aggregates of the areas covered by a number
 of polygons.
 
 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.
 
- See Also:
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionvoidadd(int[] pointArray) Adds the given polygon to the collection of polygons the receiver maintains to describe its area.voidadd(int x, int y, int width, int height) Adds the given rectangle to the collection of polygons the receiver maintains to describe its area.voidAdds the given rectangle to the collection of polygons the receiver maintains to describe its area.voidAdds 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.booleancontains(int x, int y) Returnstrueif the point specified by the arguments is inside the area specified by the receiver, andfalseotherwise.booleanReturnstrueif the given point is inside the area specified by the receiver, andfalseotherwise.booleanCompares 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.inthashCode()Returns an integer hash code for the receiver.voidintersect(int x, int y, int width, int height) Intersects the given rectangle to the collection of polygons the receiver maintains to describe its area.voidIntersects the given rectangle to the collection of polygons the receiver maintains to describe its area.voidIntersects 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.booleanintersects(int x, int y, int width, int height) Returnstrueif the rectangle described by the arguments intersects with any of the polygons the receiver maintains to describe its area, andfalseotherwise.booleanintersects(Rectangle rect) Returnstrueif the given rectangle intersects with any of the polygons the receiver maintains to describe its area andfalseotherwise.booleanReturnstrueif the region has been disposed, andfalseotherwise.booleanisEmpty()Returnstrueif the receiver does not cover any area in the (x, y) coordinate plane, andfalseif the receiver does cover some area in the plane.voidsubtract(int[] pointArray) Subtracts the given polygon from the collection of polygons the receiver maintains to describe its area.voidsubtract(int x, int y, int width, int height) Subtracts the given rectangle from the collection of polygons the receiver maintains to describe its area.voidSubtracts the given rectangle from the collection of polygons the receiver maintains to describe its area.voidSubtracts 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, human-readable description of the receiver.voidtranslate(int x, int y) Translate all of the polygons the receiver maintains to describe its area by the specified point.voidTranslate all of the polygons the receiver maintains to describe its area by the specified point.static longwin32_getHandle(Region region, int zoom) IMPORTANT: This method is not part of the public API for Image.Methods inherited from class org.eclipse.swt.graphics.Resourcedispose, getDevice, setNonDisposeHandler
- 
Constructor Details- 
Regionpublic 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:
 
- 
RegionConstructs 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- 
addpublic 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
 
- 
addAdds 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
 
 
- 
addpublic 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 rectangle
- y- the y coordinate of the rectangle
- width- the width coordinate of the rectangle
- height- 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
 
- 
addAdds 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
 
 
- 
containspublic boolean contains(int x, int y) Returnstrueif the point specified by the arguments is inside the area specified by the receiver, andfalseotherwise.- Parameters:
- x- the x coordinate of the point to test for containment
- y- the y coordinate of the point to test for containment
- Returns:
- trueif the region contains the point and- falseotherwise
- Throws:
- SWTException-- ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed
 
 
- 
containsReturnstrueif the given point is inside the area specified by the receiver, andfalseotherwise.- Parameters:
- pt- the point to test for containment
- Returns:
- trueif the region contains the point and- falseotherwise
- Throws:
- IllegalArgumentException-- ERROR_NULL_ARGUMENT - if the argument is null
 
- SWTException-- ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed
 
 
- 
equalsCompares the argument to the receiver, and returns true if they represent the same object using a class specific comparison.
- 
getBoundsReturns 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:
 
- 
hashCodepublic int hashCode()Returns an integer hash code for the receiver. Any two objects that returntruewhen passed toequalsmust return the same value for this method.
- 
intersectIntersects 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
 
- 
intersectpublic 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 rectangle
- y- the y coordinate of the rectangle
- width- the width coordinate of the rectangle
- height- 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
 
- 
intersectIntersects 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
 
- 
intersectspublic boolean intersects(int x, int y, int width, int height) Returnstrueif the rectangle described by the arguments intersects with any of the polygons the receiver maintains to describe its area, andfalseotherwise.- Parameters:
- x- the x coordinate of the origin of the rectangle
- y- the y coordinate of the origin of the rectangle
- width- the width of the rectangle
- height- the height of the rectangle
- Returns:
- trueif the rectangle intersects with the receiver, and- falseotherwise
- Throws:
- SWTException-- ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed
 
- See Also:
 
- 
intersectsReturnstrueif the given rectangle intersects with any of the polygons the receiver maintains to describe its area andfalseotherwise.- Parameters:
- rect- the rectangle to test for intersection
- Returns:
- trueif the rectangle intersects with the receiver, and- falseotherwise
- Throws:
- IllegalArgumentException-- ERROR_NULL_ARGUMENT - if the argument is null
 
- SWTException-- ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed
 
- See Also:
 
- 
isDisposedpublic boolean isDisposed()Returnstrueif the region has been disposed, andfalseotherwise.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:
- isDisposedin class- Resource
- Returns:
- truewhen the region is disposed, and- falseotherwise
 
- 
isEmptypublic boolean isEmpty()Returnstrueif the receiver does not cover any area in the (x, y) coordinate plane, andfalseif the receiver does cover some area in the plane.- Returns:
- trueif the receiver is empty, and- falseotherwise
- Throws:
- SWTException-- ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed
 
 
- 
subtractpublic 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
 
- 
subtractSubtracts 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
 
- 
subtractpublic 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 rectangle
- y- the y coordinate of the rectangle
- width- the width coordinate of the rectangle
- height- 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
 
- 
subtractSubtracts 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
 
- 
translatepublic 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 translate
- y- the y coordinate of the point to translate
- Throws:
- SWTException-- ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed
 
- Since:
- 3.1
 
- 
translateTranslate 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
 
- 
win32_getHandleIMPORTANT: This method is not part of the public API for Image. 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. Gets the handle for the region scaled at required zoom level- Parameters:
- region- the region to be scaled
- zoom- the zoom level for which the region is needed
- Returns:
- the handle of the region scaled for the zoom level
- Restriction:
- This method is not intended to be referenced by clients.
 
- 
toStringReturns a string containing a concise, human-readable description of the receiver.
 
-