com.jniwrapper.win32.gdi
Class Brush

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.Brush
All Implemented Interfaces:
com.jniwrapper.IntegerParameter, com.jniwrapper.PointerParameter

public class Brush
extends GdiObject

This class provides methods and enumerations to work with brushes.


Nested Class Summary
static class Brush.BrushStyle
          BrushStyle class represents the enumeration of brush styles.
static class Brush.HatchStyle
          HatchStyle class represents the enumeration of hatch styles.
static class Brush.StockBrush
          Enumeration of stock brushes.
 
Nested classes inherited from class com.jniwrapper.win32.gdi.GdiObject
GdiObject.ImageLoadParameters, GdiObject.ImageType, GdiObject.Type
 
Field Summary
 
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
Brush()
          Creates an empty brush.
Brush(Brush.BrushStyle style)
          Constructs a new brush with the passed style.
Brush(long handle)
          Constructs a brush with a given handle.
 
Method Summary
static Brush createBrushIndirect(LogBrush lb)
          Creates a logical brush that has the specified style, color, and pattern.
static Brush createHatchBrush(Brush.HatchStyle style, ColorRef colorRef)
          Creates a logical brush that has the specified hatch pattern and color.
static Brush createPatternBrush(Bitmap bitmap)
          Creates a logical brush with the specified bitmap pattern.
static Brush createSolidBrush(ColorRef colorRef)
          Creates a logical brush that has the specified solid color.
static Point getBrushOrigin(DC hDC)
          Retrieves the current brush origin for the specified device context.
static Brush getStockObject(Brush.StockBrush object)
          This method retrieves one of the predefined stock brushes.
static Brush getSysColorBrush(int index)
          Retrieves a handle of a logical brush that corresponds to the specified color index.
static Point setBrushOrigin(DC hDC, int xOrg, int yOrg)
          Sets the brush origin that GDI assigns to the next brush which an application selects into the specified device context.
 
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
 

Constructor Detail

Brush

public Brush()
Creates an empty brush.


Brush

public Brush(long handle)
Constructs a brush with a given handle.

Parameters:
handle - a handle for already existing brush object.

Brush

public Brush(Brush.BrushStyle style)
Constructs a new brush with the passed style.

Parameters:
style - brush style.
Method Detail

getStockObject

public static Brush getStockObject(Brush.StockBrush object)
This method retrieves one of the predefined stock brushes.

Parameters:
object - the type of stock brush.
Returns:
a requested brush, if the method succeeds, and null if the method fails.

createBrushIndirect

public static Brush createBrushIndirect(LogBrush lb)
Creates a logical brush that has the specified style, color, and pattern.

Parameters:
lb - definition of a new brush.
Returns:
a new brush if the method succeeds, and null if otherwise.

createHatchBrush

public static Brush createHatchBrush(Brush.HatchStyle style,
                                     ColorRef colorRef)
Creates a logical brush that has the specified hatch pattern and color.

Parameters:
style - hatch style of the brush.
colorRef - the color of a new brush.
Returns:
a new brush instance, or nullif the method fails.

createPatternBrush

public static Brush createPatternBrush(Bitmap bitmap)
Creates a logical brush with the specified bitmap pattern.

Parameters:
bitmap - the background for a newly created brush.
Returns:
a new brush or nullif the method fails.

createSolidBrush

public static Brush createSolidBrush(ColorRef colorRef)
Creates a logical brush that has the specified solid color.

NOTE: For painting with a system color, use getSysColorBrush(int) instead, because it returns a cached system object instead of allocating a new one.

Parameters:
colorRef - the color for a brush.
Returns:
a new brush or null class if the method fails.

getBrushOrigin

public static Point getBrushOrigin(DC hDC)
Retrieves the current brush origin for the specified device context.

Parameters:
hDC - current device context.
Returns:
the brush origin, or null if the method fails.

getSysColorBrush

public static Brush getSysColorBrush(int index)
Retrieves a handle of a logical brush that corresponds to the specified color index.

Parameters:
index - a color index.
Returns:
a brush if the index parameter is supported by the current platform. Otherwise, null.

setBrushOrigin

public static Point setBrushOrigin(DC hDC,
                                   int xOrg,
                                   int yOrg)
Sets the brush origin that GDI assigns to the next brush which an application selects into the specified device context.

Parameters:
hDC - current device context.
xOrg - the x-coordinate of the new brush origin in device units. If this value is greater than the brush width, the system reduces its value using the modulus operator (xOrg mod brush width).
yOrg - the y-coordinate of the new brush origin in device units. If this value is greater than the brush height, the system reduces it by using the modulus operator (yOrg mod brush height).
Returns:
the previous brush origin, or null if the method fails.