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

public Class Transform

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

Instances of this class represent transformation matrices for points expressed as (x, y) pairs of floating point numbers.

Application code must explicitly invoke the Transform.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
SWT Example: GraphicsExample, Sample code and further information

Field Summary

Modifier and TypeField and Description
public double[]
handle

the OS resource for the Transform (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
Transform(Device
the device on which to allocate the Transform
device
)

Constructs a new identity Transform.

public
Transform(Device
the device on which to allocate the Transform
device
,
float[]
an array of floats that describe the transformation matrix
elements
)

Constructs a new Transform given an array of elements that represent the matrix that describes the transformation.

public
Transform(Device
the device on which to allocate the Transform
device
,
float
the first element of the first row of the matrix
m11
,
float
the second element of the first row of the matrix
m12
,
float
the first element of the second row of the matrix
m21
,
float
the second element of the second row of the matrix
m22
,
float
the third element of the first row of the matrix
dx
,
float
the third element of the second row of the matrix
dy
)

Constructs a new Transform given all of the elements that represent the matrix that describes the transformation.

Method Summary

Modifier and TypeMethod and Description
pack-priv static float[]
checkTransform(float[] elements)

pack-priv void
public void
getElements(float[]
array to hold the matrix values
elements
)

Fills the parameter with the values of the transformation matrix that the receiver represents, in the order {m11, m12, m21, m22, dx, dy}.

public void
identity()

Modifies the receiver such that the matrix it represents becomes the identity matrix.

public void
invert()

Modifies the receiver such that the matrix it represents becomes the mathematical inverse of the matrix it previously represented.

public boolean

Returns:

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

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

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

Returns:

true if the receiver is an identity Transform, and false otherwise
isIdentity
()

Returns true if the Transform represents the identity matrix and false otherwise.

public void
multiply(Transform
the matrix to multiply the receiver by
matrix
)

Modifies the receiver such that the matrix it represents becomes the the result of multiplying the matrix it previously represented by the argument.

public void
rotate(float
the angle to rotate the transformation by
angle
)

Modifies the receiver so that it represents a transformation that is equivalent to its previous transformation rotated by the specified angle.

public void
scale(float
the amount to scale in the X direction
scaleX
,
float
the amount to scale in the Y direction
scaleY
)

Modifies the receiver so that it represents a transformation that is equivalent to its previous transformation scaled by (scaleX, scaleY).

public void
setElements(float
the first element of the first row of the matrix
m11
,
float
the second element of the first row of the matrix
m12
,
float
the first element of the second row of the matrix
m21
,
float
the second element of the second row of the matrix
m22
,
float
the third element of the first row of the matrix
dx
,
float
the third element of the second row of the matrix
dy
)

Modifies the receiver to represent a new transformation given all of the elements that represent the matrix that describes that transformation.

public void
shear(float
the shear factor in the X direction
shearX
,
float
the shear factor in the Y direction
shearY
)

Modifies the receiver so that it represents a transformation that is equivalent to its previous transformation sheared by (shearX, shearY).

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
transform(float[]
an array of alternating x and y values to be transformed
pointArray
)

Given an array containing points described by alternating x and y values, modify that array such that each point has been replaced with the result of applying the transformation represented by the receiver to that point.

public void
translate(float
the distance to translate in the X direction
offsetX
,
float
the distance to translate in the Y direction
offsetY
)

Modifies the receiver so that it represents a transformation that is equivalent to its previous transformation translated by (offsetX, offsetY).

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

Field Detail

handleback to summary
public double[] handle

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

Transformback to summary
public Transform(Device device)

Constructs a new identity Transform.

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

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

Parameters
device:Device

the device on which to allocate the Transform

Exceptions
IllegalArgumentException:
  • ERROR_NULL_ARGUMENT - if device is null and there is no current device
SWTException:
  • ERROR_NO_GRAPHICS_LIBRARY - if advanced graphics are not available
SWTError:
  • ERROR_NO_HANDLES if a handle for the Transform could not be obtained
See Also
dispose()
Transformback to summary
public Transform(Device device, float[] elements)

Constructs a new Transform given an array of elements that represent the matrix that describes the transformation.

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

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

Parameters
device:Device

the device on which to allocate the Transform

elements:float[]

an array of floats that describe the transformation matrix

Exceptions
IllegalArgumentException:
  • ERROR_NULL_ARGUMENT - if device is null and there is no current device, or the elements array is null
  • ERROR_INVALID_ARGUMENT - if the elements array is too small to hold the matrix values
SWTException:
  • ERROR_NO_GRAPHICS_LIBRARY - if advanced graphics are not available
SWTError:
  • ERROR_NO_HANDLES if a handle for the Transform could not be obtained
See Also
dispose()
Transformback to summary
public Transform(Device device, float m11, float m12, float m21, float m22, float dx, float dy)

Constructs a new Transform given all of the elements that represent the matrix that describes the transformation.

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

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

Parameters
device:Device

the device on which to allocate the Transform

m11:float

the first element of the first row of the matrix

m12:float

the second element of the first row of the matrix

m21:float

the first element of the second row of the matrix

m22:float

the second element of the second row of the matrix

dx:float

the third element of the first row of the matrix

dy:float

the third element of the second row of the matrix

Exceptions
IllegalArgumentException:
  • ERROR_NULL_ARGUMENT - if device is null and there is no current device
SWTException:
  • ERROR_NO_GRAPHICS_LIBRARY - if advanced graphics are not available
SWTError:
  • ERROR_NO_HANDLES if a handle for the Transform could not be obtained
See Also
dispose()

Method Detail

checkTransformback to summary
pack-priv static float[] checkTransform(float[] elements)
destroyback to summary
pack-priv void destroy()

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

Annotations
@Override
getElementsback to summary
public void getElements(float[] elements)

Fills the parameter with the values of the transformation matrix that the receiver represents, in the order {m11, m12, m21, m22, dx, dy}.

Parameters
elements:float[]

array to hold the matrix values

Exceptions
SWTException:
  • ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed
IllegalArgumentException:
  • ERROR_NULL_ARGUMENT - if the parameter is null
  • ERROR_INVALID_ARGUMENT - if the parameter is too small to hold the matrix values
identityback to summary
public void identity()

Modifies the receiver such that the matrix it represents becomes the identity matrix.

Exceptions
SWTException:
  • ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed
Since
3.4
invertback to summary
public void invert()

Modifies the receiver such that the matrix it represents becomes the mathematical inverse of the matrix it previously represented.

Exceptions
SWTException:
  • ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed
  • ERROR_CANNOT_INVERT_MATRIX - if the matrix is not invertible
isDisposedback to summary
public boolean isDisposed()

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

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

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

Returns:boolean

true when the Transform is disposed, and false otherwise

Annotations
@Override
isIdentityback to summary
public boolean isIdentity()

Returns true if the Transform represents the identity matrix and false otherwise.

Returns:boolean

true if the receiver is an identity Transform, and false otherwise

multiplyback to summary
public void multiply(Transform matrix)

Modifies the receiver such that the matrix it represents becomes the the result of multiplying the matrix it previously represented by the argument.

Parameters
matrix:Transform

the matrix to multiply the receiver by

Exceptions
SWTException:
  • ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed
IllegalArgumentException:
  • ERROR_NULL_ARGUMENT - if the parameter is null
  • ERROR_INVALID_ARGUMENT - if the parameter has been disposed
rotateback to summary
public void rotate(float angle)

Modifies the receiver so that it represents a transformation that is equivalent to its previous transformation rotated by the specified angle. The angle is specified in degrees and for the identity transform 0 degrees is at the 3 o'clock position. A positive value indicates a clockwise rotation while a negative value indicates a counter-clockwise rotation.

Parameters
angle:float

the angle to rotate the transformation by

Exceptions
SWTException:
  • ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed
scaleback to summary
public void scale(float scaleX, float scaleY)

Modifies the receiver so that it represents a transformation that is equivalent to its previous transformation scaled by (scaleX, scaleY).

Parameters
scaleX:float

the amount to scale in the X direction

scaleY:float

the amount to scale in the Y direction

Exceptions
SWTException:
  • ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed
setElementsback to summary
public void setElements(float m11, float m12, float m21, float m22, float dx, float dy)

Modifies the receiver to represent a new transformation given all of the elements that represent the matrix that describes that transformation.

Parameters
m11:float

the first element of the first row of the matrix

m12:float

the second element of the first row of the matrix

m21:float

the first element of the second row of the matrix

m22:float

the second element of the second row of the matrix

dx:float

the third element of the first row of the matrix

dy:float

the third element of the second row of the matrix

Exceptions
SWTException:
  • ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed
shearback to summary
public void shear(float shearX, float shearY)

Modifies the receiver so that it represents a transformation that is equivalent to its previous transformation sheared by (shearX, shearY).

Parameters
shearX:float

the shear factor in the X direction

shearY:float

the shear factor in the Y direction

Exceptions
SWTException:
  • ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed
Since
3.4
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
transformback to summary
public void transform(float[] pointArray)

Given an array containing points described by alternating x and y values, modify that array such that each point has been replaced with the result of applying the transformation represented by the receiver to that point.

Parameters
pointArray:float[]

an array of alternating x and y values to be transformed

Exceptions
IllegalArgumentException:
  • ERROR_NULL_ARGUMENT - if the point array is null
SWTException:
  • ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed
translateback to summary
public void translate(float offsetX, float offsetY)

Modifies the receiver so that it represents a transformation that is equivalent to its previous transformation translated by (offsetX, offsetY).

Parameters
offsetX:float

the distance to translate in the X direction

offsetY:float

the distance to translate in the Y direction

Exceptions
SWTException:
  • ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed