public abstract class Transform extends Object implements Cloneable, EventTarget
Example:
Rectangle rect = new Rectangle(50,50, Color.RED);
rect.getTransforms().add(new Rotate(45,0,0)); //rotate by 45 degrees
Type | Property and Description |
---|---|
ReadOnlyBooleanProperty |
identity
Determines if this is currently an identity transform.
|
ObjectProperty<EventHandler<? super TransformChangedEvent>> |
onTransformChanged
The onTransformChanged event handler is called whenever the transform
changes any of its parameters.
|
ReadOnlyBooleanProperty |
type2D
Determines if this is currently a 2D transform.
|
Constructor and Description |
---|
Transform() |
Modifier and Type | Method and Description |
---|---|
<T extends Event> |
addEventFilter(EventType<T> eventType,
EventHandler<? super T> eventFilter)
Registers an event filter to this transform.
|
<T extends Event> |
addEventHandler(EventType<T> eventType,
EventHandler<? super T> eventHandler)
Registers an event handler to this transform.
|
static Affine |
affine(double mxx,
double myx,
double mxy,
double myy,
double tx,
double ty)
Returns a new
Affine object from 12 number
values representing the 6 specifiable entries of the 3x4
Affine transformation matrix. |
static Affine |
affine(double mxx,
double mxy,
double mxz,
double tx,
double myx,
double myy,
double myz,
double ty,
double mzx,
double mzy,
double mzz,
double tz)
Returns a new
Affine object from 12 number
values representing the 12 specifiable entries of the 3x4
Affine transformation matrix. |
EventDispatchChain |
buildEventDispatchChain(EventDispatchChain tail)
Construct an event dispatch chain for this target.
|
Transform |
clone()
Returns a deep copy of this transform.
|
double[] |
column(MatrixType type,
int column)
Returns an array containing a column of the transformation matrix.
|
double[] |
column(MatrixType type,
int column,
double[] array)
Returns an array containing a column of the transformation matrix.
|
Transform |
createConcatenation(Transform transform)
Returns the concatenation of this transform and the specified transform.
|
Transform |
createInverse()
Returns the inverse transform of this transform.
|
Point2D |
deltaTransform(double x,
double y)
Transforms the relative magnitude vector by this transform.
|
Point3D |
deltaTransform(double x,
double y,
double z)
Transforms the relative magnitude vector by this transform.
|
Point2D |
deltaTransform(Point2D point)
Transforms the relative magnitude vector represented by the specified
Point2D instance by this transform. |
Point3D |
deltaTransform(Point3D point)
Transforms the relative magnitude vector represented by the specified
Point3D instance by this transform. |
double |
determinant()
Computes determinant of the transformation matrix.
|
double |
getElement(MatrixType type,
int row,
int column)
Gets the specified element of the transformation matrix.
|
double |
getMxx()
Gets the X coordinate scaling element of the 3x4 matrix.
|
double |
getMxy()
Gets the XY coordinate element of the 3x4 matrix.
|
double |
getMxz()
Gets the XZ coordinate element of the 3x4 matrix.
|
double |
getMyx()
Gets the YX coordinate element of the 3x4 matrix.
|
double |
getMyy()
Gets the Y coordinate scaling element of the 3x4 matrix.
|
double |
getMyz()
Gets the YZ coordinate element of the 3x4 matrix.
|
double |
getMzx()
Gets the ZX coordinate element of the 3x4 matrix.
|
double |
getMzy()
Gets the ZY coordinate element of the 3x4 matrix.
|
double |
getMzz()
Gets the Z coordinate scaling element of the 3x4 matrix.
|
EventHandler<? super TransformChangedEvent> |
getOnTransformChanged()
Gets the onTransformChanged event handler.
|
double |
getTx()
Gets the X coordinate translation element of the 3x4 matrix.
|
double |
getTy()
Gets the Y coordinate translation element of the 3x4 matrix.
|
double |
getTz()
Gets the Z coordinate translation element of the 3x4 matrix.
|
ReadOnlyBooleanProperty |
identityProperty()
Determines if this is currently an identity transform.
|
Point2D |
inverseDeltaTransform(double x,
double y)
Transforms the relative magnitude vector by the inverse of this transform.
|
Point3D |
inverseDeltaTransform(double x,
double y,
double z)
Transforms the relative magnitude vector by the inverse of this transform.
|
Point2D |
inverseDeltaTransform(Point2D point)
Transforms the relative magnitude vector represented by the specified
Point2D instance by the inverse of this transform. |
Point3D |
inverseDeltaTransform(Point3D point)
Transforms the relative magnitude vector represented by the specified
Point3D instance by the inverse of this transform. |
Bounds |
inverseTransform(Bounds bounds)
Transforms the specified bounds by the inverse of this transform.
|
Point2D |
inverseTransform(double x,
double y)
Transforms the specified point by the inverse of this transform.
|
Point3D |
inverseTransform(double x,
double y,
double z)
Transforms the specified point by the inverse of this transform.
|
Point2D |
inverseTransform(Point2D point)
Transforms the specified point by the inverse of this transform.
|
Point3D |
inverseTransform(Point3D point)
Transforms the specified point by the inverse of this transform.
|
void |
inverseTransform2DPoints(double[] srcPts,
int srcOff,
double[] dstPts,
int dstOff,
int numPts)
Transforms an array of coordinates by the inverse of this transform.
|
void |
inverseTransform3DPoints(double[] srcPts,
int srcOff,
double[] dstPts,
int dstOff,
int numPts)
Transforms an array of floating point coordinates by the inverse
of this transform.
|
boolean |
isIdentity()
Gets the value of the property identity.
|
boolean |
isType2D()
Gets the value of the property type2D.
|
ObjectProperty<EventHandler<? super TransformChangedEvent>> |
onTransformChangedProperty()
The onTransformChanged event handler is called whenever the transform
changes any of its parameters.
|
<T extends Event> |
removeEventFilter(EventType<T> eventType,
EventHandler<? super T> eventFilter)
Unregisters a previously registered event filter from this transform.
|
<T extends Event> |
removeEventHandler(EventType<T> eventType,
EventHandler<? super T> eventHandler)
Unregisters a previously registered event handler from this transform.
|
static Rotate |
rotate(double angle,
double pivotX,
double pivotY)
Returns a
Rotate object that rotates coordinates around a pivot
point. |
double[] |
row(MatrixType type,
int row)
Returns an array containing a row of the transformation matrix.
|
double[] |
row(MatrixType type,
int row,
double[] array)
Returns an array containing a row of the transformation matrix.
|
static Scale |
scale(double x,
double y)
Returns a
Scale object representing a scaling transformation. |
static Scale |
scale(double x,
double y,
double pivotX,
double pivotY)
Returns a
Scale object representing a scaling transformation. |
void |
setOnTransformChanged(EventHandler<? super TransformChangedEvent> value)
Sets the onTransformChanged event handler which is called whenever
the transform changes any of its parameters.
|
static Shear |
shear(double x,
double y)
Returns a
Shear object representing a shearing transformation. |
static Shear |
shear(double x,
double y,
double pivotX,
double pivotY)
Returns a
Shear object representing a shearing transformation. |
boolean |
similarTo(Transform transform,
Bounds range,
double maxDelta)
Checks if this transform is similar to the specified transform.
|
double[] |
toArray(MatrixType type)
Returns an array containing the flattened transformation matrix.
|
double[] |
toArray(MatrixType type,
double[] array)
Returns an array containing the flattened transformation matrix.
|
Bounds |
transform(Bounds bounds)
Transforms the specified bounds by this transform.
|
Point2D |
transform(double x,
double y)
Transforms the specified point by this transform.
|
Point3D |
transform(double x,
double y,
double z)
Transforms the specified point by this transform.
|
Point2D |
transform(Point2D point)
Transforms the specified point by this transform.
|
Point3D |
transform(Point3D point)
Transforms the specified point by this transform.
|
void |
transform2DPoints(double[] srcPts,
int srcOff,
double[] dstPts,
int dstOff,
int numPts)
Transforms an array of coordinates by this transform.
|
void |
transform3DPoints(double[] srcPts,
int srcOff,
double[] dstPts,
int dstOff,
int numPts)
Transforms an array of floating point coordinates by this transform.
|
protected void |
transformChanged()
This method must be called by all transforms whenever any of their
parameters changes.
|
static Translate |
translate(double x,
double y)
Returns a
Translate object representing a translation transformation. |
ReadOnlyBooleanProperty |
type2DProperty()
Determines if this is currently a 2D transform.
|
public final ReadOnlyBooleanProperty type2DProperty
isType2D()
public final ReadOnlyBooleanProperty identityProperty
isIdentity()
public final ObjectProperty<EventHandler<? super TransformChangedEvent>> onTransformChangedProperty
getOnTransformChanged()
,
setOnTransformChanged(EventHandler)
public static Affine affine(double mxx, double myx, double mxy, double myy, double tx, double ty)
Affine
object from 12 number
values representing the 6 specifiable entries of the 3x4
Affine transformation matrix.mxx
- the X coordinate scaling element of the 3x4 matrixmyx
- the Y coordinate shearing element of the 3x4 matrixmxy
- the X coordinate shearing element of the 3x4 matrixmyy
- the Y coordinate scaling element of the 3x4 matrixtx
- the X coordinate translation element of the 3x4 matrixty
- the Y coordinate translation element of the 3x4 matrixAffine
object derived from specified parameterspublic static Affine affine(double mxx, double mxy, double mxz, double tx, double myx, double myy, double myz, double ty, double mzx, double mzy, double mzz, double tz)
Affine
object from 12 number
values representing the 12 specifiable entries of the 3x4
Affine transformation matrix.mxx
- the X coordinate scaling element of the 3x4 matrixmxy
- the XY element of the 3x4 matrixmxz
- the XZ element of the 3x4 matrixtx
- the X coordinate translation element of the 3x4 matrixmyx
- the YX element of the 3x4 matrixmyy
- the Y coordinate scaling element of the 3x4 matrixmyz
- the YZ element of the 3x4 matrixty
- the Y coordinate translation element of the 3x4 matrixmzx
- the ZX element of the 3x4 matrixmzy
- the ZY element of the 3x4 matrixmzz
- the Z coordinate scaling element of the 3x4 matrixtz
- the Z coordinate translation element of the 3x4 matrixAffine
object derived from specified parameterspublic static Translate translate(double x, double y)
Translate
object representing a translation transformation.
This is equivalent to:
new Translate(x, y);
public static Rotate rotate(double angle, double pivotX, double pivotY)
Rotate
object that rotates coordinates around a pivot
point.
This is equivalent to:
new Rotate(angle, pivotX, pivotY);
public static Scale scale(double x, double y)
Scale
object representing a scaling transformation.
This is equivalent to:
new Scale(x, y);
public static Scale scale(double x, double y, double pivotX, double pivotY)
Scale
object representing a scaling transformation.
The returned scale operation will be about the given pivot point.
This is equivalent to:
new Scale(x, y, pivotX, pivotY);
public static Shear shear(double x, double y)
Shear
object representing a shearing transformation.
This is equivalent to:
new Shear(x, y);
public static Shear shear(double x, double y, double pivotX, double pivotY)
Shear
object representing a shearing transformation.
This is equivalent to:
new Shear(x, y, pivotX, pivotY);
public double getMxx()
public double getMxy()
public double getMxz()
public double getTx()
public double getMyx()
public double getMyy()
public double getMyz()
public double getTy()
public double getMzx()
public double getMzy()
public double getMzz()
public double getTz()
public double getElement(MatrixType type, int row, int column)
type
- type of matrix to get the value fromrow
- zero-based row numbercolumn
- zero-based column numberIllegalArgumentException
- if a 2D matrix type is requested for
a 3D transformIndexOutOfBoundsException
- if the indices are not within
the specified matrix typeNullPointerException
- if the specified type
is nullpublic double determinant()
public final boolean isType2D()
public final ReadOnlyBooleanProperty type2DProperty()
isType2D()
public final boolean isIdentity()
public final ReadOnlyBooleanProperty identityProperty()
isIdentity()
public boolean similarTo(Transform transform, Bounds range, double maxDelta)
range
is transformed by them to points that are no farther
than maxDelta
from each other.transform
- transform to be compared to this transformrange
- region of interest on which the two transforms are comparedmaxDelta
- maximum allowed distance for the results of transforming
any single point from range
by the two transformsNullPointerException
- if the specified transform
or range
is nullpublic double[] toArray(MatrixType type, double[] array)
type
- matrix type to be filled in the arrayarray
- 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.IllegalArgumentException
- if a 2D matrix type is requested for
a 3D transformNullPointerException
- if the specified type
is nullpublic double[] toArray(MatrixType type)
type
- matrix type to be filled in the arrayIllegalArgumentException
- if a 2D matrix type is requested for
a 3D transformNullPointerException
- if the specified type
is nullpublic double[] row(MatrixType type, int row, double[] array)
type
- matrix type whose row is to be filled in the arrayrow
- zero-based index of the rowarray
- 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.IllegalArgumentException
- if a 2D matrix type is requested for
a 3D transformIndexOutOfBoundsException
- if the row
index is not within
the number of rows of the specified matrix typeNullPointerException
- if the specified type
is nullpublic double[] row(MatrixType type, int row)
type
- matrix type whose row is to be filled in the arrayrow
- zero-based index of the rowIllegalArgumentException
- if a 2D matrix type is requested for
a 3D transformIndexOutOfBoundsException
- if the row
index is not within
the number of rows of the specified matrix typeNullPointerException
- if the specified type
is nullpublic double[] column(MatrixType type, int column, double[] array)
type
- matrix type whose column is to be filled in the arraycolumn
- zero-based index of the columnarray
- 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.IllegalArgumentException
- if a 2D matrix type is requested for
a 3D transformIndexOutOfBoundsException
- if the column
index
is not within the number of columns of the specified matrix typeNullPointerException
- if the specified type
is nullpublic double[] column(MatrixType type, int column)
type
- matrix type whose column is to be filled in the arraycolumn
- zero-based index of the columnIllegalArgumentException
- if a 2D matrix type is requested for
a 3D transformIndexOutOfBoundsException
- if the column
index
is not within the number of columns of the specified matrix typeNullPointerException
- if the specified type
is nullpublic Transform createConcatenation(Transform transform)
getTransforms()
list,
this
transform first and the specified transform
second.transform
- transform to be concatenated with this transformNullPointerException
- if the specified transform
is nullpublic Transform createInverse() throws NonInvertibleTransformException
NonInvertibleTransformException
- if this transform
cannot be invertedpublic Transform clone()
public Point2D transform(double x, double y)
x
- the X coordinate of the pointy
- the Y coordinate of the pointIllegalStateException
- if this is a 3D transformpublic Point2D transform(Point2D point)
point
- the point to be transformedIllegalStateException
- if this is a 3D transformNullPointerException
- if the specified point
is nullpublic Point3D transform(double x, double y, double z)
x
- the X coordinate of the pointy
- the Y coordinate of the pointz
- the Z coordinate of the pointpublic Point3D transform(Point3D point)
point
- the point to be transformedNullPointerException
- if the specified point
is nullpublic Bounds transform(Bounds bounds)
bounds
- the bounds to be transformedpublic void transform2DPoints(double[] srcPts, int srcOff, double[] dstPts, int dstOff, int numPts)
[x0, y0, x1, y1, ..., xn, yn]
.
This method can be used only for 2D transforms.srcPts
- the array containing the source point coordinates.
Each point is stored as a pair of x, y coordinates.srcOff
- the offset to the first point to be transformed
in the source arraydstPts
- the array into which the transformed point coordinates
are returned. Each point is stored as a pair of x, y
coordinates.dstOff
- the offset to the location of the first
transformed point that is stored in the destination arraynumPts
- the number of points to be transformedIllegalStateException
- if this is a 3D transformNullPointerException
- if srcPts
or (@code dstPts} is nullpublic void transform3DPoints(double[] srcPts, int srcOff, double[] dstPts, int dstOff, int numPts)
[x0, y0, z0, x1, y1, z1, ..., xn, yn, zn]
.srcPts
- the array containing the source point coordinates.
Each point is stored as a tiplet of x, y, z coordinates.srcOff
- the offset to the first point to be transformed
in the source arraydstPts
- the array into which the transformed point coordinates
are returned. Each point is stored as a triplet of x, y, z
coordinates.dstOff
- the offset to the location of the first
transformed point that is stored in the destination arraynumPts
- the number of points to be transformedNullPointerException
- if srcPts
or (@code dstPts} is nullpublic Point2D deltaTransform(double x, double y)
x
- vector magnitude in the direction of the X axisy
- vector magnitude in the direction of the Y axisPoint2D
instanceIllegalStateException
- if this is a 3D transformpublic Point2D deltaTransform(Point2D point)
Point2D
instance by this transform.
The vector is transformed without applying the translation components
of the affine transformation matrix.
This method can be used only for a 2D transform.point
- the relative magnitude vectorPoint2D
instanceIllegalStateException
- if this is a 3D transformNullPointerException
- if the specified point
is nullpublic Point3D deltaTransform(double x, double y, double z)
x
- vector magnitude in the direction of the X axisy
- vector magnitude in the direction of the Y axisPoint3D
instancepublic Point3D deltaTransform(Point3D point)
Point3D
instance by this transform.
The vector is transformed without applying the translation components
of the affine transformation matrix.point
- the relative magnitude vectorPoint3D
instanceNullPointerException
- if the specified point
is nullpublic Point2D inverseTransform(double x, double y) throws NonInvertibleTransformException
x
- the X coordinate of the pointy
- the Y coordinate of the pointIllegalStateException
- if this is a 3D transformNonInvertibleTransformException
- if this transform
cannot be invertedpublic Point2D inverseTransform(Point2D point) throws NonInvertibleTransformException
point
- the point to be transformedIllegalStateException
- if this is a 3D transformNonInvertibleTransformException
- if this transform
cannot be invertedNullPointerException
- if the specified point
is nullpublic Point3D inverseTransform(double x, double y, double z) throws NonInvertibleTransformException
x
- the X coordinate of the pointy
- the Y coordinate of the pointz
- the Z coordinate of the pointNonInvertibleTransformException
- if this transform
cannot be invertedpublic Point3D inverseTransform(Point3D point) throws NonInvertibleTransformException
point
- the point to be transformedNonInvertibleTransformException
- if this transform
cannot be invertedNullPointerException
- if the specified point
is nullpublic Bounds inverseTransform(Bounds bounds) throws NonInvertibleTransformException
bounds
- the bounds to be transformedNonInvertibleTransformException
- if this transform
cannot be invertedNullPointerException
- if the specified bounds
is nullpublic void inverseTransform2DPoints(double[] srcPts, int srcOff, double[] dstPts, int dstOff, int numPts) throws NonInvertibleTransformException
[x0, y0, x1, y1, ..., xn, yn]
.
This method can be used only for 2D transforms.srcPts
- the array containing the source point coordinates.
Each point is stored as a pair of x, y coordinates.srcOff
- the offset to the first point to be transformed
in the source arraydstPts
- the array into which the transformed point coordinates
are returned. Each point is stored as a pair of x, y
coordinates.dstOff
- the offset to the location of the first
transformed point that is stored in the destination arraynumPts
- the number of points to be transformedIllegalStateException
- if this is a 3D transformNonInvertibleTransformException
- if this transform
cannot be invertedNullPointerException
- if srcPts
or (@code dstPts} is nullpublic void inverseTransform3DPoints(double[] srcPts, int srcOff, double[] dstPts, int dstOff, int numPts) throws NonInvertibleTransformException
[x0, y0, z0, x1, y1, z1, ..., xn, yn, zn]
.srcPts
- the array containing the source point coordinates.
Each point is stored as a triplet of x, y, z coordinates.srcOff
- the offset to the first point to be transformed
in the source arraydstPts
- the array into which the transformed point coordinates
are returned. Each point is stored as a triplet of x, y, z
coordinates.dstOff
- the offset to the location of the first
transformed point that is stored in the destination arraynumPts
- the number of points to be transformedNonInvertibleTransformException
- if this transform
cannot be invertedNullPointerException
- if srcPts
or (@code dstPts} is nullpublic Point2D inverseDeltaTransform(double x, double y) throws NonInvertibleTransformException
x
- vector magnitude in the direction of the X axisy
- vector magnitude in the direction of the Y axisPoint2D
instanceIllegalStateException
- if this is a 3D transformNonInvertibleTransformException
- if this transform
cannot be invertedpublic Point2D inverseDeltaTransform(Point2D point) throws NonInvertibleTransformException
Point2D
instance by the inverse of this transform.
The vector is transformed without applying the translation components
of the affine transformation matrix.
This method can be used only for a 2D transform.point
- the relative magnitude vectorPoint2D
instanceIllegalStateException
- if this is a 3D transformNonInvertibleTransformException
- if this transform
cannot be invertedNullPointerException
- if the specified point
is nullpublic Point3D inverseDeltaTransform(double x, double y, double z) throws NonInvertibleTransformException
x
- vector magnitude in the direction of the X axisy
- vector magnitude in the direction of the Y axisPoint3D
instanceNonInvertibleTransformException
- if this transform
cannot be invertedpublic Point3D inverseDeltaTransform(Point3D point) throws NonInvertibleTransformException
Point3D
instance by the inverse of this transform.
The vector is transformed without applying the translation components
of the affine transformation matrix.point
- the relative magnitude vectorPoint3D
instanceNonInvertibleTransformException
- if this transform
cannot be invertedNullPointerException
- if the specified point
is nullpublic EventDispatchChain buildEventDispatchChain(EventDispatchChain tail)
EventTarget
EventTarget
. This event target is
not automatically added to the chain, so if it wants to process events,
it needs to add an EventDispatcher
for itself to the chain.
In the case the event target is part of some hierarchy, the chain for it is usually built from event dispatchers collected from the root of the hierarchy to the event target.
The event dispatch chain is constructed by modifications to the provided initial event dispatch chain. The returned chain should have the initial chain at its end so the dispatchers should be prepended to the initial chain.
The caller shouldn't assume that the initial chain remains unchanged nor that the returned value will reference a different chain.
buildEventDispatchChain
in interface EventTarget
tail
- the initial chain to build frompublic final <T extends Event> void addEventHandler(EventType<T> eventType, EventHandler<? super T> eventHandler)
Registers an event handler to this transform. Any event filters are first processed, then the specified onFoo event handlers, and finally any event handlers registered by this method.
Currently the only event delivered to a Transform
is the
TransformChangedEvent
with it's single type
TRANSFORM_CHANGED
.
T
- the specific event class of the handlereventType
- the type of the events to receive by the handlereventHandler
- the handler to registerNullPointerException
- if the event type or handler is nullpublic final <T extends Event> void removeEventHandler(EventType<T> eventType, EventHandler<? super T> eventHandler)
T
- the specific event class of the handlereventType
- the event type from which to unregistereventHandler
- the handler to unregisterNullPointerException
- if the event type or handler is nullpublic final <T extends Event> void addEventFilter(EventType<T> eventType, EventHandler<? super T> eventFilter)
Registers an event filter to this transform. Registered event filters get an event before any associated event handlers.
Currently the only event delivered to a Transform
is the
TransformChangedEvent
with it's single type
TRANSFORM_CHANGED
.
T
- the specific event class of the filtereventType
- the type of the events to receive by the filtereventFilter
- the filter to registerNullPointerException
- if the event type or filter is nullpublic final <T extends Event> void removeEventFilter(EventType<T> eventType, EventHandler<? super T> eventFilter)
T
- the specific event class of the filtereventType
- the event type from which to unregistereventFilter
- the filter to unregisterNullPointerException
- if the event type or filter is nullpublic final void setOnTransformChanged(EventHandler<? super TransformChangedEvent> value)
value
- the event handler, can be null to clear itpublic final EventHandler<? super TransformChangedEvent> getOnTransformChanged()
setOnTransformChanged
method, null if the handler is not set.public final ObjectProperty<EventHandler<? super TransformChangedEvent>> onTransformChangedProperty()
getOnTransformChanged()
,
setOnTransformChanged(EventHandler)
protected void transformChanged()
Submit a bug or feature
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright © 2008, 2020, Oracle and/or its affiliates. All rights reserved. Use is subject to license terms. Also see the documentation redistribution policy.