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

public Class Pattern

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

Instances of this class represent patterns to use while drawing. Patterns can be specified either as bitmaps or gradients.

Application code must explicitly invoke the Pattern.dispose() method to release the operating system resources managed by each instance when those instances are no longer required.

This class requires the operating system's advanced graphics subsystem which may not be available on some platforms.

Since
3.1
See Also
Path, Pattern snippets, SWT Example: GraphicsExample, Sample code and further information

Field Summary

Modifier and TypeField and Description
public long
handle

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

Important Note

This field is not part of the SWT public API.

pack-priv long
Inherited from org.eclipse.swt.graphics.Resource:
device

Constructor Summary

AccessConstructor and Description
public
Pattern(Device
the device on which to allocate the pattern
device
,
Image
the image that the pattern will draw
image
)

Constructs a new Pattern given an image.

public
Pattern(Device
the device on which to allocate the pattern
device
,
float
the x coordinate of the starting corner of the gradient
x1
,
float
the y coordinate of the starting corner of the gradient
y1
,
float
the x coordinate of the ending corner of the gradient
x2
,
float
the y coordinate of the ending corner of the gradient
y2
,
Color
the starting color of the gradient
color1
,
Color
the ending color of the gradient
color2
)

Constructs a new Pattern that represents a linear, two color gradient.

public
Pattern(Device
the device on which to allocate the pattern
device
,
float
the x coordinate of the starting corner of the gradient
x1
,
float
the y coordinate of the starting corner of the gradient
y1
,
float
the x coordinate of the ending corner of the gradient
x2
,
float
the y coordinate of the ending corner of the gradient
y2
,
Color
the starting color of the gradient
color1
,
int
the starting alpha value of the gradient
alpha1
,
Color
the ending color of the gradient
color2
,
int
the ending alpha value of the gradient
alpha2
)

Constructs a new Pattern that represents a linear, two color gradient.

Method Summary

Modifier and TypeMethod and Description
pack-priv void
public boolean

Returns:

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

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

Returns true if the Pattern has been disposed, and false otherwise.
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.
Inherited from org.eclipse.swt.graphics.Resource:
disposegetDeviceignoreNonDisposedinitinitNonDisposeTrackingsetNonDisposeHandler

Field Detail

handleback to summary
public long handle

the OS resource for the Pattern (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.

surfaceback to summary
pack-priv long surface

Constructor Detail

Patternback to summary
public Pattern(Device device, Image image)

Constructs a new Pattern given an image. Drawing with the resulting pattern will cause the image to be tiled over the resulting area.

This operation requires the operating system's advanced graphics subsystem which may not be available on some platforms.

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

Parameters
device:Device

the device on which to allocate the pattern

image:Image

the image that the pattern will draw

Exceptions
IllegalArgumentException:
  • ERROR_NULL_ARGUMENT - if the device is null and there is no current device, or the image is null
  • ERROR_INVALID_ARGUMENT - if the image has been disposed
SWTException:
  • ERROR_NO_GRAPHICS_LIBRARY - if advanced graphics are not available
SWTError:
  • ERROR_NO_HANDLES if a handle for the pattern could not be obtained
See Also
dispose()
Patternback to summary
public Pattern(Device device, float x1, float y1, float x2, float y2, Color color1, Color color2)

Constructs a new Pattern that represents a linear, two color gradient. Drawing with the pattern will cause the resulting area to be tiled with the gradient specified by the arguments.

This operation requires the operating system's advanced graphics subsystem which may not be available on some platforms.

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

Parameters
device:Device

the device on which to allocate the pattern

x1:float

the x coordinate of the starting corner of the gradient

y1:float

the y coordinate of the starting corner of the gradient

x2:float

the x coordinate of the ending corner of the gradient

y2:float

the y coordinate of the ending corner of the gradient

color1:Color

the starting color of the gradient

color2:Color

the ending color of the gradient

Exceptions
IllegalArgumentException:
  • ERROR_NULL_ARGUMENT - if the device is null and there is no current device, or if either color1 or color2 is null
  • ERROR_INVALID_ARGUMENT - if either color1 or color2 has been disposed
SWTException:
  • ERROR_NO_GRAPHICS_LIBRARY - if advanced graphics are not available
SWTError:
  • ERROR_NO_HANDLES if a handle for the pattern could not be obtained
See Also
dispose()
Patternback to summary
public Pattern(Device device, float x1, float y1, float x2, float y2, Color color1, int alpha1, Color color2, int alpha2)

Constructs a new Pattern that represents a linear, two color gradient. Drawing with the pattern will cause the resulting area to be tiled with the gradient specified by the arguments.

This operation requires the operating system's advanced graphics subsystem which may not be available on some platforms.

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

Parameters
device:Device

the device on which to allocate the pattern

x1:float

the x coordinate of the starting corner of the gradient

y1:float

the y coordinate of the starting corner of the gradient

x2:float

the x coordinate of the ending corner of the gradient

y2:float

the y coordinate of the ending corner of the gradient

color1:Color

the starting color of the gradient

alpha1:int

the starting alpha value of the gradient

color2:Color

the ending color of the gradient

alpha2:int

the ending alpha value of the gradient

Exceptions
IllegalArgumentException:
  • ERROR_NULL_ARGUMENT - if the device is null and there is no current device, or if either color1 or color2 is null
  • ERROR_INVALID_ARGUMENT - if either color1 or color2 has been disposed
SWTException:
  • ERROR_NO_GRAPHICS_LIBRARY - if advanced graphics are not available
SWTError:
  • ERROR_NO_HANDLES if a handle for the pattern could not be obtained
Since
3.2
See Also
dispose()

Method Detail

destroyback to summary
pack-priv void destroy()

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

Annotations
@Override
isDisposedback to summary
public boolean isDisposed()

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

Returns true if the Pattern has been disposed, and false otherwise.

This method gets the dispose state for the Pattern. When a Pattern has been disposed, it is an error to invoke any other method (except dispose()) using the Pattern.

Returns:boolean

true when the Pattern is disposed, and false otherwise

Annotations
@Override
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