Top Description Fields Constructors Methods
org.eclipse.swt.graphics

public final Class Region

extends Resource
Class Inheritance
Imports
org.eclipse.swt.*, org.eclipse.swt.internal.*, org.eclipse.swt.internal.cairo.*, org.eclipse.swt.internal.gtk.*

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
SWT Example: GraphicsExample, Sample code and further information

Field Summary

Modifier and TypeField and Description
public long
handle

the OS resource for the region (Warning: This field is platform dependent)

Important Note

This field is not part of the SWT public API.

Inherited from org.eclipse.swt.graphics.Resource:
device

Constructor Summary

AccessConstructor and Description
public
Region()

Constructs a new empty region.

public
Region(Device
the device on which to allocate the region
device
)

Constructs a new empty region.

pack-priv
Region(Device device, long handle)

Method Summary

Modifier and TypeMethod and Description
public void
add(int[]
points that describe the polygon to merge with the receiver
pointArray
)

Adds the given polygon to the collection of polygons the receiver maintains to describe its area.

public void
add(Rectangle
the rectangle to merge with the receiver
rect
)

Adds the given rectangle to the collection of polygons the receiver maintains to describe its area.

public void
add(int
the x coordinate of the rectangle
x
,
int
the y coordinate of the rectangle
y
,
int
the width coordinate of the rectangle
width
,
int
the height coordinate of the rectangle
height
)

Adds the given rectangle to the collection of polygons the receiver maintains to describe its area.

public void
add(Region
the region to merge
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.

pack-priv void
addInPixels(int[] pointArray)

pack-priv void
pack-priv void
addInPixels(int x, int y, int width, int height)

pack-priv static void
cairo_region_get_rectangles(long region, long[] rectangles, int[] n_rectangles)

public boolean

Returns:

true if the region contains the point and false otherwise
contains
(int
the x coordinate of the point to test for containment
x
,
int
the y coordinate of the point to test for containment
y
)

Returns true if the point specified by the arguments is inside the area specified by the receiver, and false otherwise.

public boolean

Returns:

true if the region contains the point and false otherwise
contains
(Point
the point to test for containment
pt
)

Returns true if the given point is inside the area specified by the receiver, and false otherwise.

pack-priv boolean
containsInPixels(int x, int y)

pack-priv boolean
pack-priv void
public boolean

Returns:

true if the object is the same as this object and false otherwise
equals
(Object
the object to compare with this object
object
)

Overrides java.lang.Object.equals.

Compares the argument to the receiver, and returns true if they represent the same object using a class specific comparison.
pack-priv static long
gdk_region_polygon(int[] pointArray, int npoints, int fill_rule)

public Rectangle

Returns:

a bounding rectangle for the region
getBounds
()

Returns a rectangle which represents the rectangular union of the collection of polygons the receiver maintains to describe its area.

pack-priv Rectangle
public static Region

Returns:

a new region object containing the specified device and handle
gtk_new
(Device
the device on which to allocate the region
device
,
long
the handle for the region
handle
)

Invokes platform specific functionality to allocate a new region.

public int

Returns:

the receiver's hash
hashCode
()

Overrides java.lang.Object.hashCode.

Returns an integer hash code for the receiver.
public void
intersect(Rectangle
the rectangle to intersect with the receiver
rect
)

Intersects the given rectangle to the collection of polygons the receiver maintains to describe its area.

public void
intersect(int
the x coordinate of the rectangle
x
,
int
the y coordinate of the rectangle
y
,
int
the width coordinate of the rectangle
width
,
int
the height coordinate of the rectangle
height
)

Intersects the given rectangle to the collection of polygons the receiver maintains to describe its area.

public void
intersect(Region
the region to intersect
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.

pack-priv void
pack-priv void
intersectInPixels(int x, int y, int width, int height)

public boolean

Returns:

true if the rectangle intersects with the receiver, and false otherwise
intersects
(int
the x coordinate of the origin of the rectangle
x
,
int
the y coordinate of the origin of the rectangle
y
,
int
the width of the rectangle
width
,
int
the height of the rectangle
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.

public boolean

Returns:

true if the rectangle intersects with the receiver, and false otherwise
intersects
(Rectangle
the rectangle to test for intersection
rect
)

Returns true if the given rectangle intersects with any of the polygons the receiver maintains to describe its area and false otherwise.

pack-priv boolean
intersectsInPixels(int x, int y, int width, int height)

pack-priv boolean
public boolean

Returns:

true when the region is disposed, and false otherwise
isDisposed
()

Implements abstract org.eclipse.swt.graphics.Resource.isDisposed.

Returns true if the region has been disposed, and false otherwise.
public boolean

Returns:

true if the receiver is empty, and false otherwise
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.

public void
subtract(int[]
points that describe the polygon to merge with the receiver
pointArray
)

Subtracts the given polygon from the collection of polygons the receiver maintains to describe its area.

public void
subtract(Rectangle
the rectangle to subtract from the receiver
rect
)

Subtracts the given rectangle from the collection of polygons the receiver maintains to describe its area.

public void
subtract(int
the x coordinate of the rectangle
x
,
int
the y coordinate of the rectangle
y
,
int
the width coordinate of the rectangle
width
,
int
the height coordinate of the rectangle
height
)

Subtracts the given rectangle from the collection of polygons the receiver maintains to describe its area.

public void
subtract(Region
the region to subtract
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.

pack-priv void
subtractInPixels(int[] pointArray)

pack-priv void
pack-priv void
subtractInPixels(int x, int y, int width, int height)

public String

Returns:

a string representation of the receiver
toString
()

Overrides java.lang.Object.toString.

Returns a string containing a concise, human-readable description of the receiver.
public void
translate(int
the x coordinate of the point to translate
x
,
int
the y coordinate of the point to translate
y
)

Translate all of the polygons the receiver maintains to describe its area by the specified point.

public void
translate(Point
the point to translate
pt
)

Translate all of the polygons the receiver maintains to describe its area by the specified point.

pack-priv void
translateInPixels(int x, int y)

Inherited from org.eclipse.swt.graphics.Resource:
disposegetDeviceignoreNonDisposedinitinitNonDisposeTrackingsetNonDisposeHandler

Field Detail

handleback to summary
public long handle

the OS resource for the region (Warning: This field is platform dependent)

Important Note

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.

Constructor Detail

Regionback to summary
public Region()

Constructs a new empty region.

You must dispose the region when it is no longer required.

Exceptions
SWTError:
  • ERROR_NO_HANDLES if a handle could not be obtained for region creation
See Also
dispose()
Regionback to summary
public Region(Device device)

Constructs a new empty region.

You must dispose the region when it is no longer required.

Parameters
device:Device

the device on which to allocate the region

Exceptions
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
dispose()
Regionback to summary
pack-priv Region(Device device, long handle)

Method Detail

addback to summary
public void add(int[] pointArray)

Adds the given polygon to the collection of polygons the receiver maintains to describe its area.

Parameters
pointArray:int[]

points that describe the polygon to merge with the receiver

Exceptions
IllegalArgumentException:
  • ERROR_NULL_ARGUMENT - if the argument is null
SWTException:
  • ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed
Since
3.0
addback to summary
public void add(Rectangle rect)

Adds the given rectangle to the collection of polygons the receiver maintains to describe its area.

Parameters
rect:Rectangle

the rectangle to merge with the receiver

Exceptions
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
addback to summary
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:int

the x coordinate of the rectangle

y:int

the y coordinate of the rectangle

width:int

the width coordinate of the rectangle

height:int

the height coordinate of the rectangle

Exceptions
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
addback to summary
public 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.

Parameters
region:Region

the region to merge

Exceptions
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
addInPixelsback to summary
pack-priv void addInPixels(int[] pointArray)
addInPixelsback to summary
pack-priv void addInPixels(Rectangle rect)
addInPixelsback to summary
pack-priv void addInPixels(int x, int y, int width, int height)
cairo_region_get_rectanglesback to summary
pack-priv static void cairo_region_get_rectangles(long region, long[] rectangles, int[] n_rectangles)
containsback to summary
public 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.

Parameters
x:int

the x coordinate of the point to test for containment

y:int

the y coordinate of the point to test for containment

Returns:boolean

true if the region contains the point and false otherwise

Exceptions
SWTException:
  • ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed
containsback to summary
public boolean contains(Point pt)

Returns true if the given point is inside the area specified by the receiver, and false otherwise.

Parameters
pt:Point

the point to test for containment

Returns:boolean

true if the region contains the point and false otherwise

Exceptions
IllegalArgumentException:
  • ERROR_NULL_ARGUMENT - if the argument is null
SWTException:
  • ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed
containsInPixelsback to summary
pack-priv boolean containsInPixels(int x, int y)
containsInPixelsback to summary
pack-priv boolean containsInPixels(Point pt)
destroyback to summary
pack-priv void destroy()

Overrides org.eclipse.swt.graphics.Resource.destroy.

Annotations
@Override
equalsback to summary
public boolean equals(Object object)

Overrides java.lang.Object.equals.

Compares the argument to the receiver, and returns true if they represent the same object using a class specific comparison.

Parameters
object:Object

the object to compare with this object

Returns:boolean

true if the object is the same as this object and false otherwise

Annotations
@Override
See Also
hashCode
gdk_region_polygonback to summary
pack-priv static long gdk_region_polygon(int[] pointArray, int npoints, int fill_rule)
getBoundsback to summary
public Rectangle getBounds()

Returns a rectangle which represents the rectangular union of the collection of polygons the receiver maintains to describe its area.

Returns:Rectangle

a bounding rectangle for the region

Exceptions
SWTException:
  • ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed
See Also
Rectangle#union
getBoundsInPixelsback to summary
pack-priv Rectangle getBoundsInPixels()
gtk_newback to summary
public static Region gtk_new(Device device, long handle)

Invokes platform specific functionality to allocate a new region.

Important Note

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:Device

the device on which to allocate the region

handle:long

the handle for the region

Returns:Region

a new region object containing the specified device and handle

hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Returns an integer hash code for the receiver. Any two objects that return true when passed to equals must return the same value for this method.

Returns:int

the receiver's hash

Annotations
@Override
See Also
equals
intersectback to summary
public void intersect(Rectangle rect)

Intersects the given rectangle to the collection of polygons the receiver maintains to describe its area.

Parameters
rect:Rectangle

the rectangle to intersect with the receiver

Exceptions
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
intersectback to summary
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:int

the x coordinate of the rectangle

y:int

the y coordinate of the rectangle

width:int

the width coordinate of the rectangle

height:int

the height coordinate of the rectangle

Exceptions
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
intersectback to summary
public 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.

Parameters
region:Region

the region to intersect

Exceptions
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
intersectInPixelsback to summary
pack-priv void intersectInPixels(Rectangle rect)
intersectInPixelsback to summary
pack-priv void intersectInPixels(int x, int y, int width, int height)
intersectsback to summary
public 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.

Parameters
x:int

the x coordinate of the origin of the rectangle

y:int

the y coordinate of the origin of the rectangle

width:int

the width of the rectangle

height:int

the height of the rectangle

Returns:boolean

true if the rectangle intersects with the receiver, and false otherwise

Exceptions
SWTException:
  • ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed
See Also
Rectangle#intersects(Rectangle)
intersectsback to summary
public 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.

Parameters
rect:Rectangle

the rectangle to test for intersection

Returns:boolean

true if the rectangle intersects with the receiver, and false otherwise

Exceptions
IllegalArgumentException:
  • ERROR_NULL_ARGUMENT - if the argument is null
SWTException:
  • ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed
See Also
Rectangle#intersects(Rectangle)
intersectsInPixelsback to summary
pack-priv boolean intersectsInPixels(int x, int y, int width, int height)
intersectsInPixelsback to summary
pack-priv boolean intersectsInPixels(Rectangle rect)
isDisposedback to summary
public boolean isDisposed()

Implements abstract org.eclipse.swt.graphics.Resource.isDisposed.

Returns 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 dispose()) using the region.

Returns:boolean

true when the region is disposed, and false otherwise

Annotations
@Override
isEmptyback to summary
public 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.

Returns:boolean

true if the receiver is empty, and false otherwise

Exceptions
SWTException:
  • ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed
subtractback to summary
public void subtract(int[] pointArray)

Subtracts the given polygon from the collection of polygons the receiver maintains to describe its area.

Parameters
pointArray:int[]

points that describe the polygon to merge with the receiver

Exceptions
IllegalArgumentException:
  • ERROR_NULL_ARGUMENT - if the argument is null
SWTException:
  • ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed
Since
3.0
subtractback to summary
public void subtract(Rectangle rect)

Subtracts the given rectangle from the collection of polygons the receiver maintains to describe its area.

Parameters
rect:Rectangle

the rectangle to subtract from the receiver

Exceptions
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
subtractback to summary
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:int

the x coordinate of the rectangle

y:int

the y coordinate of the rectangle

width:int

the width coordinate of the rectangle

height:int

the height coordinate of the rectangle

Exceptions
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
subtractback to summary
public 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.

Parameters
region:Region

the region to subtract

Exceptions
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
subtractInPixelsback to summary
pack-priv void subtractInPixels(int[] pointArray)
subtractInPixelsback to summary
pack-priv void subtractInPixels(Rectangle rect)
subtractInPixelsback to summary
pack-priv void subtractInPixels(int x, int y, int width, int height)
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Returns a string containing a concise, human-readable description of the receiver.

Returns:String

a string representation of the receiver

Annotations
@Override
translateback to summary
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:int

the x coordinate of the point to translate

y:int

the y coordinate of the point to translate

Exceptions
SWTException:
  • ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed
Since
3.1
translateback to summary
public void translate(Point pt)

Translate all of the polygons the receiver maintains to describe its area by the specified point.

Parameters
pt:Point

the point to translate

Exceptions
IllegalArgumentException:
  • ERROR_NULL_ARGUMENT - if the argument is null
SWTException:
  • ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed
Since
3.1
translateInPixelsback to summary
pack-priv void translateInPixels(int x, int y)