com.jniwrapper.win32.gdi
Class Region

java.lang.Object
  extended bycom.jniwrapper.Parameter
      extended bycom.jniwrapper.Pointer.Void
          extended bycom.jniwrapper.win32.Handle
              extended bycom.jniwrapper.win32.gdi.GdiObject
                  extended bycom.jniwrapper.win32.gdi.Region
All Implemented Interfaces:
com.jniwrapper.IntegerParameter, com.jniwrapper.PointerParameter

public class Region
extends GdiObject

This class provides operations on region objects.


Nested Class Summary
static class Region.CombineMode
          CombineMode class represents EnumItemeration of combined operations.
 
Nested classes inherited from class com.jniwrapper.win32.gdi.GdiObject
GdiObject.ImageLoadParameters, GdiObject.ImageType, GdiObject.Type
 
Field Summary
static int COMPLEXREGION
          The region consists of more than one rectangle.
static int NULLREGION
          The region is empty.
static int RGN_ERROR
           
static int SIMPLEREGION
          The region consists of a single rectangle.
 
Fields inherited from class com.jniwrapper.win32.gdi.GdiObject
GDI_ERROR, HGDI_ERROR
 
Fields inherited from class com.jniwrapper.win32.Handle
INFINITE_TIMEOUT, INVALID_HANDLE_VALUE, STATUS_ABANDONED_WAIT_0, STATUS_TIMEOUT, STATUS_WAIT_0
 
Fields inherited from class com.jniwrapper.Parameter
LICENSE_TYPE, V
 
Constructor Summary
Region()
           
Region(long value)
           
 
Method Summary
static Region combineRgn(Region srcRgn1, Region srcRgn2, Region.CombineMode combineMode)
          Creates a combined region from two specified regions.
static Region createElliptic(int left, int top, int right, int bottom)
          Factory method for creating elliptic regions.
static Region createElliptic(Rect rect)
          Factory method for creating elliptic regions via bounding rectangle.
static Region createFromImage(java.awt.Image image)
          Creates a region from the specified image.
static Region createFromImage(java.awt.Image image, java.awt.Color transparent)
          Creates a region from the specified image.
static Region createFromImage(java.awt.Image image, java.awt.Color transparent, java.awt.Color tolerance)
          Creates a region from specified image.
static Region createPolygonRgn(Point[] points, int nPoints, PolyFillMode polyFillMode)
          Creates a polygonal region.
static Region createPolyPolygonRgn(Point[] points, int[] polyCounts, int count, PolyFillMode polyFillMode)
          Creates a region consisting of a series of polygons.
static Region createRectRegion(int left, int top, int right, int bottom)
          Creates a rectangular region.
static Region createRectRegion(Rect rect)
          Creates a rectangular region.
static Region createRoundRectRegion(int left, int top, int right, int bottom, int ellipseWidth, int ellipseHight)
           
 boolean equalRegion(Region region)
          Checks the two specified regions to determine whether they are identical.
 int getRagionData(com.jniwrapper.PrimitiveArray rgnData, int count)
          Fills the specified buffer with data describing a region.
 Rect getRegionBox()
          Retrieves the bounding rectangle of the region.
 boolean isPointInRegion(int x, int y)
          Determines whether the specified point is inside the specified region.
 boolean isPointInRegion(Point point)
          Determines whether the specified point is inside the specified region.
 boolean isRectInRegion(Rect rect)
          Determines whether any part of the specified rectangle is within the boundaries of a region.
 void offsetRegion(int xOffset, int yOffset)
          Moves a region by the specified offsets.
 void setRectRegion(int left, int top, int right, int bottom)
          Converts a region into a rectangular region with the specified coordinates.
 
Methods inherited from class com.jniwrapper.win32.gdi.GdiObject
deleteObject, getObject, getObjectType
 
Methods inherited from class com.jniwrapper.win32.Handle
clone, closeHandle, equals, waitFor, waitFor
 
Methods inherited from class com.jniwrapper.Pointer.Void
asFunction, asFunction, asTypedPointer, castTo, getDebugInfo, getLength, getValue, hashCode, isNull, read, setValue, toString, write
 
Methods inherited from class com.jniwrapper.Parameter
, a, a, acceptIOPerformer, asReturnValue, b, dataBufferAssigned, getAlignedLength, getAlignmentRequirement, getDataBuffer, getDataBufferOffset, indent, pop, push, read, read, setDataBuffer, toByteArray, write
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

RGN_ERROR

public static final int RGN_ERROR
See Also:
Constant Field Values

NULLREGION

public static final int NULLREGION
The region is empty.

See Also:
Constant Field Values

SIMPLEREGION

public static final int SIMPLEREGION
The region consists of a single rectangle.

See Also:
Constant Field Values

COMPLEXREGION

public static final int COMPLEXREGION
The region consists of more than one rectangle.

See Also:
Constant Field Values
Constructor Detail

Region

public Region()

Region

public Region(long value)
Method Detail

createElliptic

public static Region createElliptic(int left,
                                    int top,
                                    int right,
                                    int bottom)
Factory method for creating elliptic regions.

Returns:
a created region, which can hold NULL value in case of error.

createElliptic

public static Region createElliptic(Rect rect)
Factory method for creating elliptic regions via bounding rectangle.

Parameters:
rect - bounding rectangle for an elliptic region to be created.
Returns:
a created region, which can hold NULL value in case of error.

createRoundRectRegion

public static Region createRoundRectRegion(int left,
                                           int top,
                                           int right,
                                           int bottom,
                                           int ellipseWidth,
                                           int ellipseHight)

combineRgn

public static Region combineRgn(Region srcRgn1,
                                Region srcRgn2,
                                Region.CombineMode combineMode)
Creates a combined region from two specified regions.

Parameters:
srcRgn1 - the first region.
srcRgn2 - the second region.
combineMode - combine method.
Returns:
a combined region.

createPolygonRgn

public static Region createPolygonRgn(Point[] points,
                                      int nPoints,
                                      PolyFillMode polyFillMode)
Creates a polygonal region.

Parameters:
points -
polyFillMode -
Returns:
polygon region.

createPolyPolygonRgn

public static Region createPolyPolygonRgn(Point[] points,
                                          int[] polyCounts,
                                          int count,
                                          PolyFillMode polyFillMode)
Creates a region consisting of a series of polygons.

Parameters:
points -
polyCounts -
count -
polyFillMode -
Returns:
poly polygon region.

createRectRegion

public static Region createRectRegion(int left,
                                      int top,
                                      int right,
                                      int bottom)
Creates a rectangular region.

Parameters:
left -
top -
right -
bottom -
Returns:
rectangular region.

createRectRegion

public static Region createRectRegion(Rect rect)
Creates a rectangular region.

Parameters:
rect -
Returns:
rectangular region.

equalRegion

public boolean equalRegion(Region region)
Checks the two specified regions to determine whether they are identical.

Parameters:
region -
Returns:
true if the regions are equal, false if otherwise.

getRagionData

public int getRagionData(com.jniwrapper.PrimitiveArray rgnData,
                         int count)
Fills the specified buffer with data describing a region. This data includes the dimensions of the rectangles that make up the region.

Parameters:
rgnData - is a region data buffer.
count - is the size of the region data buffer.
Returns:
count if the function succeeds and count specifies an adequate number of bytes. If count is too small or the function fails, the return value is 0.

getRegionBox

public Rect getRegionBox()
Retrieves the bounding rectangle of the region.

Returns:
the bounding rectangle of the specified region.

offsetRegion

public void offsetRegion(int xOffset,
                         int yOffset)
Moves a region by the specified offsets.

Parameters:
xOffset -
yOffset -

isPointInRegion

public boolean isPointInRegion(int x,
                               int y)
Determines whether the specified point is inside the specified region.

Parameters:
x -
y -
Returns:
true if the point is inside the specified region; false if otherwise.

isPointInRegion

public boolean isPointInRegion(Point point)
Determines whether the specified point is inside the specified region.

Parameters:
point -
Returns:
true if the point is inside the specified region; false if otherwise.

isRectInRegion

public boolean isRectInRegion(Rect rect)
Determines whether any part of the specified rectangle is within the boundaries of a region.

Parameters:
rect -
Returns:
true if any part of the specified rectangle is within the boundaries of a region.; false if otherwise.

setRectRegion

public void setRectRegion(int left,
                          int top,
                          int right,
                          int bottom)
Converts a region into a rectangular region with the specified coordinates.

Parameters:
left -
top -
right -
bottom -

createFromImage

public static Region createFromImage(java.awt.Image image,
                                     java.awt.Color transparent)
Creates a region from the specified image.

Parameters:
image - is a source image.
transparent - is a transparent color of the image.
Returns:
a region created from the image.

createFromImage

public static Region createFromImage(java.awt.Image image,
                                     java.awt.Color transparent,
                                     java.awt.Color tolerance)
Creates a region from specified image.

Parameters:
image - is a source image.
transparent - is a transparent color of the image.
tolerance - is a color tolerance for the transparent color.
Returns:
a region created from the image.

createFromImage

public static Region createFromImage(java.awt.Image image)
Creates a region from the specified image. The image should be transparent so there is no need to specify transparency color.

Parameters:
image - is a source image.
Returns:
a region created from the image.