APIdia Launch Partner
Top Description Inners Fields Constructors Methods
javafx.scene.transform

public abstract Class Transform

extends Object
implements Cloneable, EventTarget
Class Inheritance
All Implemented Interfaces
javafx.event.EventTarget, java.lang.Cloneable
Known Direct Subclasses
javafx.scene.transform.Transform.ImmutableTransform, javafx.scene.transform.Translate, javafx.scene.transform.Affine, javafx.scene.transform.Rotate, javafx.scene.transform.Scale, javafx.scene.transform.Shear
Imports
java.util.Iterator, com.sun.javafx.geometry.BoundsUtils, javafx.event.EventDispatchChain, .Event, .EventHandler, .EventTarget, .EventType, javafx.scene.Node, com.sun.javafx.util.WeakReferenceQueue, com.sun.javafx.event.EventHandlerManager, com.sun.javafx.geom.transform.Affine3D, .BaseTransform, com.sun.javafx.scene.NodeHelper, com.sun.javafx.scene.transform.TransformHelper, .TransformUtils, java.lang.ref.SoftReference, javafx.beans.property.ObjectProperty, .ReadOnlyBooleanProperty, .ReadOnlyBooleanPropertyBase, .SimpleObjectProperty, javafx.geometry.Bounds, .Point2D, .Point3D

This class is a base class for different affine transformations. It provides factory methods for the simple transformations - rotating, scaling, shearing, and translation. It allows to get the transformation matrix elements for any transform.

Example:

Rectangle rect = new Rectangle(50,50, Color.RED);
 rect.getTransforms().add(new Rotate(45,0,0)); //rotate by 45 degrees
Since
JavaFX 2.0

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv static class
Transform.ImmutableTransform

Immutable transformation with performance optimizations based on Affine.

private abstract static class
Transform.LazyBooleanProperty

Lazily computed read-only boolean property implementation.

Field Summary

Modifier and TypeField and Description
private Transform.LazyBooleanProperty
identity

Determines if this is currently an identity transform.

private EventHandlerManager
private SoftReference<Transform>
inverseCache

For transforms with expensive inversion we cache the inverted matrix once it is needed and computed for some operation.

private WeakReferenceQueue<E>
private ObjectProperty<EventHandler<? super TransformChangedEvent>>
private Transform.LazyBooleanProperty
type2D

Determines if this is currently a 2D transform.

Constructor Summary

AccessConstructor and Description
public
Transform()

Constructor for subclasses to call.

Method Summary

Modifier and TypeMethod and Description
pack-priv void
add(final Node node)

public final <T extends Event> void
addEventFilter(final EventType<T> eventType, final EventHandler<? super T> eventFilter)

Overrides default javafx.event.EventTarget.addEventFilter.

Registers an event filter for this target.

public final <T extends Event> void
addEventHandler(final EventType<T> eventType, final EventHandler<? super T> eventHandler)

Overrides default javafx.event.EventTarget.addEventHandler.

Registers an event handler for this target.

public static Affine

Returns:

a new Affine object derived from specified parameters
affine
(double
the X coordinate scaling element of the 3x4 matrix
mxx
,
double
the Y coordinate shearing element of the 3x4 matrix
myx
,
double
the X coordinate shearing element of the 3x4 matrix
mxy
,
double
the Y coordinate scaling element of the 3x4 matrix
myy
,
double
the X coordinate translation element of the 3x4 matrix
tx
,
double
the Y coordinate translation element of the 3x4 matrix
ty
)

Returns a new Affine object from 12 number values representing the 6 specifiable entries of the 3x4 Affine transformation matrix.

public static Affine

Returns:

a new Affine object derived from specified parameters
affine
(double
the X coordinate scaling element of the 3x4 matrix
mxx
,
double
the XY element of the 3x4 matrix
mxy
,
double
the XZ element of the 3x4 matrix
mxz
,
double
the X coordinate translation element of the 3x4 matrix
tx
,
double
the YX element of the 3x4 matrix
myx
,
double
the Y coordinate scaling element of the 3x4 matrix
myy
,
double
the YZ element of the 3x4 matrix
myz
,
double
the Y coordinate translation element of the 3x4 matrix
ty
,
double
the ZX element of the 3x4 matrix
mzx
,
double
the ZY element of the 3x4 matrix
mzy
,
double
the Z coordinate scaling element of the 3x4 matrix
mzz
,
double
the Z coordinate translation element of the 3x4 matrix
tz
)

Returns a new Affine object from 12 number values representing the 12 specifiable entries of the 3x4 Affine transformation matrix.

pack-priv void
appendTo(Affine
Affine instance to append to
a
)

Visitor from Affine class which provides an efficient append operation for the subclasses.

pack-priv abstract void
public EventDispatchChain
buildEventDispatchChain(EventDispatchChain tail)

Implements javafx.event.EventTarget.buildEventDispatchChain.

Construct an event dispatch chain for this target.

pack-priv void
checkRequestedMAT(MatrixType
matrix type to check
type
)

Makes sure the specified matrix type can be requested from this transform.

pack-priv void
clearInverseCache()

Used only by tests to emulate garbage collecting the soft references

public Transform

Returns:

a copy of this transform
clone
()

Overrides java.lang.Object.clone.

Returns a deep copy of this transform.

public double[]

Returns:

an array containing the requested column of the requested matrix type representing this transform
column
(MatrixType
matrix type whose column is to be filled in the array
type
,
int
zero-based index of the column
column
,
double[]
array into which the elements of the column are to be stored, if it is non-null and big enough; otherwise, a new array is created for this purpose.
array
)

Returns an array containing a column of the transformation matrix.

public double[]

Returns:

an array containing the requested column of the requested matrix type representing this transform
column
(MatrixType
matrix type whose column is to be filled in the array
type
,
int
zero-based index of the column
column
)

Returns an array containing a column of the transformation matrix.

pack-priv boolean

Returns:

true if this transform is currently 2D-only
computeIs2D
()

Computes if this transform is currently a 2D transform (has no effect in the direction of Z axis).

pack-priv boolean

Returns:

true if this transform is currently an identity transform
computeIsIdentity
()

Computes if this transform is currently an identity (has no effect in any direction).

public Transform

Returns:

The concatenated transform
createConcatenation
(Transform
transform to be concatenated with this transform
transform
)

Returns the concatenation of this transform and the specified transform.

pack-priv static Transform
pack-priv static Transform
createImmutableTransform(double mxx, double mxy, double mxz, double tx, double myx, double myy, double myz, double ty, double mzx, double mzy, double mzz, double tz)

pack-priv static Transform
createImmutableTransform(Transform transform, double mxx, double mxy, double mxz, double tx, double myx, double myy, double myz, double ty, double mzx, double mzy, double mzz, double tz)

pack-priv static Transform
public Transform

Returns:

the inverse transform
createInverse
()

Returns the inverse transform of this transform.

public Point2D

Returns:

the transformed relative magnitude vector represented by a Point2D instance
deltaTransform
(double
vector magnitude in the direction of the X axis
x
,
double
vector magnitude in the direction of the Y axis
y
)

Transforms the relative magnitude vector by this transform.

public Point2D

Returns:

the transformed relative magnitude vector represented by a Point2D instance
deltaTransform
(Point2D
the relative magnitude vector
point
)

Transforms the relative magnitude vector represented by the specified Point2D instance by this transform.

public Point3D

Returns:

the transformed relative magnitude vector represented by a Point3D instance
deltaTransform
(double
vector magnitude in the direction of the X axis
x
,
double
vector magnitude in the direction of the Y axis
y
,
double
vector magnitude in the direction of the Z axis
z
)

Transforms the relative magnitude vector by this transform.

public Point3D

Returns:

the transformed relative magnitude vector represented by a Point3D instance
deltaTransform
(Point3D
the relative magnitude vector
point
)

Transforms the relative magnitude vector represented by the specified Point3D instance by this transform.

pack-priv abstract BaseTransform
public double

Returns:

Determinant of the transformation matrix
determinant
()

Computes determinant of the transformation matrix.

pack-priv void
ensureCanTransform2DPoint()

Makes sure this is a 2D transform.

pack-priv void
fill2DArray(double[]
array to be filled with the 6 2D elements
array
)

Core of the toArray implementation for the 2D case.

pack-priv void
fill3DArray(double[]
array to be filled with the 12 3D elements
array
)

Core of the toArray implementation for the 3D case.

public double

Returns:

value of the specified transformation matrix element
getElement
(MatrixType
type of matrix to get the value from
type
,
int
zero-based row number
row
,
int
zero-based column number
column
)

Gets the specified element of the transformation matrix.

private int

Returns:

the (if necessary fixed) srcOff
getFixedSrcOffset
(double[] srcPts, int srcOff, double[] dstPts, int dstOff, int numPts, int dimensions)

Helper method for transforming arrays of points that deals with overlapping arrays.

private EventHandlerManager
private Transform

Returns:

the cached inverse transformation
getInverseCache
()

Gets the inverse transform cache.

public double

Returns:

the X coordinate scaling element of the 3x4 matrix
getMxx
()

Gets the X coordinate scaling element of the 3x4 matrix.

public double

Returns:

the XY coordinate element of the 3x4 matrix
getMxy
()

Gets the XY coordinate element of the 3x4 matrix.

public double

Returns:

the XZ coordinate element of the 3x4 matrix
getMxz
()

Gets the XZ coordinate element of the 3x4 matrix.

public double

Returns:

the YX coordinate element of the 3x4 matrix
getMyx
()

Gets the YX coordinate element of the 3x4 matrix.

public double

Returns:

the Y coordinate scaling element of the 3x4 matrix
getMyy
()

Gets the Y coordinate scaling element of the 3x4 matrix.

public double

Returns:

the YZ coordinate element of the 3x4 matrix
getMyz
()

Gets the YZ coordinate element of the 3x4 matrix.

public double

Returns:

the ZX coordinate element of the 3x4 matrix
getMzx
()

Gets the ZX coordinate element of the 3x4 matrix.

public double

Returns:

the ZY coordinate element of the 3x4 matrix
getMzy
()

Gets the ZY coordinate element of the 3x4 matrix.

public double

Returns:

the Z coordinate scaling element of the 3x4 matrix
getMzz
()

Gets the Z coordinate scaling element of the 3x4 matrix.

public final EventHandler<? super TransformChangedEvent>

Returns:

the event handler previously set by setOnTransformChanged method, null if the handler is not set.
getOnTransformChanged
()

Gets the onTransformChanged event handler.

public double

Returns:

the X coordinate translation element of the 3x4 matrix
getTx
()

Gets the X coordinate translation element of the 3x4 matrix.

public double

Returns:

the Y coordinate translation element of the 3x4 matrix
getTy
()

Gets the Y coordinate translation element of the 3x4 matrix.

public double

Returns:

the Z coordinate translation element of the 3x4 matrix
getTz
()

Gets the Z coordinate translation element of the 3x4 matrix.

public final ReadOnlyBooleanProperty
public Point2D

Returns:

the inversely transformed relative magnitude vector represented by a Point2D instance
inverseDeltaTransform
(double
vector magnitude in the direction of the X axis
x
,
double
vector magnitude in the direction of the Y axis
y
)

Transforms the relative magnitude vector by the inverse of this transform.

public Point2D

Returns:

the inversely transformed relative magnitude vector represented by a Point2D instance
inverseDeltaTransform
(Point2D
the relative magnitude vector
point
)

Transforms the relative magnitude vector represented by the specified Point2D instance by the inverse of this transform.

public Point3D

Returns:

the inversely transformed relative magnitude vector represented by a Point3D instance
inverseDeltaTransform
(double
vector magnitude in the direction of the X axis
x
,
double
vector magnitude in the direction of the Y axis
y
,
double
vector magnitude in the direction of the Z axis
z
)

Transforms the relative magnitude vector by the inverse of this transform.

public Point3D

Returns:

the inversely transformed relative magnitude vector represented by a Point3D instance
inverseDeltaTransform
(Point3D
the relative magnitude vector
point
)

Transforms the relative magnitude vector represented by the specified Point3D instance by the inverse of this transform.

public Point2D

Returns:

the inversely transformed point
inverseTransform
(double
the X coordinate of the point
x
,
double
the Y coordinate of the point
y
)

Transforms the specified point by the inverse of this transform.

public Point2D

Returns:

the inversely transformed point
inverseTransform
(Point2D
the point to be transformed
point
)

Transforms the specified point by the inverse of this transform.

public Point3D

Returns:

the inversely transformed point
inverseTransform
(double
the X coordinate of the point
x
,
double
the Y coordinate of the point
y
,
double
the Z coordinate of the point
z
)

Transforms the specified point by the inverse of this transform.

public Point3D

Returns:

the inversely transformed point
inverseTransform
(Point3D
the point to be transformed
point
)

Transforms the specified point by the inverse of this transform.

public Bounds

Returns:

the inversely transformed bounds
inverseTransform
(Bounds
the bounds to be transformed
bounds
)

Transforms the specified bounds by the inverse of this transform.

public void
inverseTransform2DPoints(double[]
the array containing the source point coordinates. Each point is stored as a pair of x, y coordinates.
srcPts
,
int
the offset to the first point to be transformed in the source array
srcOff
,
double[]
the array into which the transformed point coordinates are returned. Each point is stored as a pair of x, y coordinates.
dstPts
,
int
the offset to the location of the first transformed point that is stored in the destination array
dstOff
,
int
the number of points to be transformed
numPts
)

Transforms an array of coordinates by the inverse of this transform.

pack-priv void
inverseTransform2DPointsImpl(double[] srcPts, int srcOff, double[] dstPts, int dstOff, int numPts)

Core of the inverseTransform2DPoints method.

public void
inverseTransform3DPoints(double[]
the array containing the source point coordinates. Each point is stored as a triplet of x, y, z coordinates.
srcPts
,
int
the offset to the first point to be transformed in the source array
srcOff
,
double[]
the array into which the transformed point coordinates are returned. Each point is stored as a triplet of x, y, z coordinates.
dstPts
,
int
the offset to the location of the first transformed point that is stored in the destination array
dstOff
,
int
the number of points to be transformed
numPts
)

Transforms an array of floating point coordinates by the inverse of this transform.

pack-priv void
inverseTransform3DPointsImpl(double[] srcPts, int srcOff, double[] dstPts, int dstOff, int numPts)

Core of the inverseTransform3DPoints method.

public final boolean
public final boolean
public final ObjectProperty<EventHandler<? super TransformChangedEvent>>

Returns:

the onTransformChanged event handler
onTransformChangedProperty
()

The onTransformChanged event handler is called whenever the transform changes any of its parameters.

pack-priv void
prependTo(Affine
Affine instance to prepend to
a
)

Visitor from Affine class which provides an efficient prepend operation for the subclasses.

pack-priv void
remove(final Node node)

public final <T extends Event> void
removeEventFilter(final EventType<T> eventType, final EventHandler<? super T> eventFilter)

Overrides default javafx.event.EventTarget.removeEventFilter.

Unregisters a previously registered event filter from this target.

public final <T extends Event> void
removeEventHandler(final EventType<T> eventType, final EventHandler<? super T> eventHandler)

Overrides default javafx.event.EventTarget.removeEventHandler.

Unregisters a previously registered event handler from this target.

public static Rotate

Returns:

the Rotate object that rotates coordinates around a pivot point
rotate
(double
the rotation angle
angle
,
double
the pivot x value
pivotX
,
double
the pivot y value
pivotY
)

Returns a Rotate object that rotates coordinates around a pivot point.

public double[]

Returns:

an array containing the requested row of the requested matrix type representing this transform
row
(MatrixType
matrix type whose row is to be filled in the array
type
,
int
zero-based index of the row
row
,
double[]
array into which the elements of the row are to be stored, if it is non-null and big enough; otherwise, a new array is created for this purpose.
array
)

Returns an array containing a row of the transformation matrix.

public double[]

Returns:

an array containing the requested row of the requested matrix type representing this transform
row
(MatrixType
matrix type whose row is to be filled in the array
type
,
int
zero-based index of the row
row
)

Returns an array containing a row of the transformation matrix.

public static Scale

Returns:

the Scale object representing a scaling transformation
scale
(double
the scale x value
x
,
double
the scale y value
y
)

Returns a Scale object representing a scaling transformation.

public static Scale

Returns:

the Scale object representing a scaling transformation
scale
(double
the scale x value
x
,
double
the scale y value
y
,
double
the pivot x value
pivotX
,
double
the pivot y value
pivotY
)

Returns a Scale object representing a scaling transformation.

public final void
setOnTransformChanged(EventHandler<? super TransformChangedEvent>
the event handler, can be null to clear it
value
)

Sets the onTransformChanged event handler which is called whenever the transform changes any of its parameters.

public static Shear

Returns:

the Shear object representing a shearing transformation
shear
(double
the shear x value
x
,
double
the shear y value
y
)

Returns a Shear object representing a shearing transformation.

public static Shear

Returns:

the Shear object representing a shearing transformation
shear
(double
the shear x value
x
,
double
the shear y value
y
,
double
the pivot x value
pivotX
,
double
the pivot y value
pivotY
)

Returns a Shear object representing a shearing transformation.

public boolean

Returns:

true if the transforms are similar according to the specified criteria
similarTo
(Transform
transform to be compared to this transform
transform
,
Bounds
region of interest on which the two transforms are compared
range
,
double
maximum allowed distance for the results of transforming any single point from range by the two transforms
maxDelta
)

Checks if this transform is similar to the specified transform.

public double[]

Returns:

an array containing the elements of the requested matrix type representing this transform
toArray
(MatrixType
matrix type to be filled in the array
type
,
double[]
array into which the elements of the matrix are to be stored, if it is non-null and big enough; otherwise, a new array is created for this purpose.
array
)

Returns an array containing the flattened transformation matrix.

public double[]

Returns:

an array containing the elements of the requested matrix type representing this transform
toArray
(MatrixType
matrix type to be filled in the array
type
)

Returns an array containing the flattened transformation matrix.

public Point2D

Returns:

the transformed point
transform
(double
the X coordinate of the point
x
,
double
the Y coordinate of the point
y
)

Transforms the specified point by this transform.

public Point2D

Returns:

the transformed point
transform
(Point2D
the point to be transformed
point
)

Transforms the specified point by this transform.

public Point3D

Returns:

the transformed point
transform
(double
the X coordinate of the point
x
,
double
the Y coordinate of the point
y
,
double
the Z coordinate of the point
z
)

Transforms the specified point by this transform.

public Point3D

Returns:

the transformed point
transform
(Point3D
the point to be transformed
point
)

Transforms the specified point by this transform.

public Bounds

Returns:

the transformed bounds
transform
(Bounds
the bounds to be transformed
bounds
)

Transforms the specified bounds by this transform.

public void
transform2DPoints(double[]
the array containing the source point coordinates. Each point is stored as a pair of x, y coordinates.
srcPts
,
int
the offset to the first point to be transformed in the source array
srcOff
,
double[]
the array into which the transformed point coordinates are returned. Each point is stored as a pair of x, y coordinates.
dstPts
,
int
the offset to the location of the first transformed point that is stored in the destination array
dstOff
,
int
the number of points to be transformed
numPts
)

Transforms an array of coordinates by this transform.

pack-priv void
transform2DPointsImpl(double[] srcPts, int srcOff, double[] dstPts, int dstOff, int numPts)

Core of the transform2DPoints method.

public void
transform3DPoints(double[]
the array containing the source point coordinates. Each point is stored as a triplet of x, y, z coordinates.
srcPts
,
int
the offset to the first point to be transformed in the source array
srcOff
,
double[]
the array into which the transformed point coordinates are returned. Each point is stored as a triplet of x, y, z coordinates.
dstPts
,
int
the offset to the location of the first transformed point that is stored in the destination array
dstOff
,
int
the number of points to be transformed
numPts
)

Transforms an array of floating point coordinates by this transform.

pack-priv void
transform3DPointsImpl(double[] srcPts, int srcOff, double[] dstPts, int dstOff, int numPts)

Core of the transform3DPoints method.

protected void
transformChanged()

This method must be called by all transforms whenever any of their parameters changes.

private double

Returns:

distance of the transformed points
transformDiff
(Transform
the other transform
t
,
double
point's X coordinate
x
,
double
point's Y coordinate
y
)

Transforms the specified point by this transform and by the specified transform and returns distance of the result points.

private double

Returns:

distance of the transformed points
transformDiff
(Transform
the other transform
t
,
double
point's X coordinate
x
,
double
point's Y coordinate
y
,
double
point's Z coordinate
z
)

Transforms the specified point by this transform and by the specified transform and returns distance of the result points.

public static Translate

Returns:

the Translate object representing a translation transformation
translate
(double
the translate x value
x
,
double
the translate y value
y
)

Returns a Translate object representing a translation transformation.

public final ReadOnlyBooleanProperty
pack-priv void
validate()

Needed for the proper delivery of the TransformChangedEvent.

Inherited from java.lang.Object:
equalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait