public class FXTransformPolicy extends AbstractTransformPolicy<javafx.scene.Node>
FXTransformPolicy
is a JavaFX-specific
AbstractTransformPolicy
that handles the transformation of its
host
.
When working with transformations, the order in which the individual transformations are concatenated is important. The transformation that is concatenated last will be applied first. For example, the rotation around a pivot point consists of 3 steps:
(-px, -py)
.
(px, py)
.
--> --> --> direction of concatenation --> --> --> postTransforms initialNodeTransform preTransforms |------------| |-----------| postIndex: n, n-1, ... 0 preIndex: 0, 1, ... m <-- <-- <-- <-- direction of effect <-- <-- <-- <--
As you can see, the last pre-transform is concatenated last, and therefore, will affect the host first. Generally, a post-transform manipulates the transformed node, while a pre-transform manipulates the coordinate system before the node is transformed.
You can use the AbstractTransformPolicy.createPreTransform()
and
AbstractTransformPolicy.createPostTransform()
methods to create a pre- or a post-transform
and append it to the respective list. Therefore, the most recently created
pre-transform will be applied first, and the most recently created
post-transform will be applied last. When creating a pre- or post-transform,
the index of that transform within the respective list will be returned. This
index can later be used to manipulate the transform.
The AbstractTransformPolicy.setPostRotate(int, Angle)
,
AbstractTransformPolicy.setPostScale(int, double, double)
,
AbstractTransformPolicy.setPostTransform(int, AffineTransform)
,
AbstractTransformPolicy.setPostTranslate(int, double, double)
,
AbstractTransformPolicy.setPreRotate(int, Angle)
, AbstractTransformPolicy.setPreScale(int, double, double)
,
AbstractTransformPolicy.setPreTransform(int, AffineTransform)
, and
AbstractTransformPolicy.setPreTranslate(int, double, double)
methods can be used to change a
previously created pre- or post-transform.
Modifier and Type | Field and Description |
---|---|
static AdapterKey<com.google.inject.Provider<? extends javafx.scene.transform.Affine>> |
TRANSFORM_PROVIDER_KEY
The adapter key for the
Provider<Affine> that will be
used to obtain the host's Affine transformation. |
Constructor and Description |
---|
FXTransformPolicy() |
Modifier and Type | Method and Description |
---|---|
protected ITransactionalOperation |
createOperation()
Creates an
ITransactionalOperation that is used to encapsulate
the changes that are applied by this AbstractTransactionPolicy
through its "work" methods. |
AffineTransform |
getCurrentTransform()
Returns the
AffineTransform that matches the node transformation
of the host . |
protected void |
updateTransformOperation(AffineTransform newTransform)
Updates the operation that was created within
AbstractTransactionPolicy.createOperation()
so that it will set the host's transformation to match
the given AffineTransform upon execution. |
applyTransform, commit, createPostTransform, createPreTransform, createTransformContentOperation, getInitialTransform, getSnapToGridOffset, init, isContentTransformable, setPostRotate, setPostScale, setPostTransform, setPostTranslate, setPreRotate, setPreScale, setPreTransform, setPreTranslate, setTransform, updateTransform
checkInitialized, getOperation, isInitialized, locallyExecuteOperation, rollback
getAdaptable, getHost, setAdaptable
public static final AdapterKey<com.google.inject.Provider<? extends javafx.scene.transform.Affine>> TRANSFORM_PROVIDER_KEY
Provider<Affine>
that will be
used to obtain the host's Affine
transformation.protected ITransactionalOperation createOperation()
AbstractTransactionPolicy
ITransactionalOperation
that is used to encapsulate
the changes that are applied by this AbstractTransactionPolicy
through its "work" methods. The created operation should allow for
local execution
at each time.createOperation
in class AbstractTransactionPolicy<javafx.scene.Node>
ITransactionalOperation
to encapsulate all applied
changes.public AffineTransform getCurrentTransform()
AbstractTransformPolicy
AffineTransform
that matches the node transformation
of the host
.getCurrentTransform
in class AbstractTransformPolicy<javafx.scene.Node>
AffineTransform
.protected void updateTransformOperation(AffineTransform newTransform)
AbstractTransformPolicy
AbstractTransactionPolicy.createOperation()
so that it will set the host's
transformation to match
the given AffineTransform
upon execution.updateTransformOperation
in class AbstractTransformPolicy<javafx.scene.Node>
newTransform
- The new transformation for the host.Copyright (c) 2014 itemis AG and others. All rights reserved.