public final class TranslateTransition extends Transition
Transition
creates a move/translate animation that spans its
duration
. This is done by updating the translateX
,
translateY
and translateZ
variables of the node
at
regular interval.
It starts from the (fromX
, fromY
, fromZ
) value if
provided else uses the node
's (translateX
, translateY
, translateZ
) value.
It stops at the (toX
, toY
, toZ
) value if provided
else it will use start value plus (byX
, byY
, byZ
)
value.
The (toX
, toY
, toZ
) value takes precedence if both (
toX
, toY
, toZ
) and (byX
, byY
,
byZ
) values are specified.
Code Segment Example:
import javafx.scene.shape.*;
import javafx.animation.transition.*;
...
Rectangle rect = new Rectangle (100, 40, 100, 100);
rect.setArcHeight(50);
rect.setArcWidth(50);
rect.setFill(Color.VIOLET);
TranslateTransition tt = new TranslateTransition(Duration.millis(2000), rect);
tt.setByX(200f);
tt.setCycleCount(4f);
tt.setAutoReverse(true);
tt.play();
...
Transition
,
Animation
Animation.Status
Modifier and Type | Field and Description |
---|---|
private DoubleProperty |
byX
Specifies the incremented stop X coordinate value, from the start, of
this
TranslateTransition . |
private DoubleProperty |
byY
Specifies the incremented stop Y coordinate value, from the start, of
this
TranslateTransition . |
private DoubleProperty |
byZ
Specifies the incremented stop Z coordinate value, from the start, of
this
TranslateTransition . |
private Node |
cachedNode |
private static double |
DEFAULT_BY_X |
private static double |
DEFAULT_BY_Y |
private static double |
DEFAULT_BY_Z |
private static Duration |
DEFAULT_DURATION |
private static double |
DEFAULT_FROM_X |
private static double |
DEFAULT_FROM_Y |
private static double |
DEFAULT_FROM_Z |
private static Node |
DEFAULT_NODE |
private static double |
DEFAULT_TO_X |
private static double |
DEFAULT_TO_Y |
private static double |
DEFAULT_TO_Z |
private double |
deltaX |
private double |
deltaY |
private double |
deltaZ |
private ObjectProperty<Duration> |
duration
The duration of this
TranslateTransition . |
private static double |
EPSILON |
private DoubleProperty |
fromX
Specifies the start X coordinate value of this
TranslateTransition . |
private DoubleProperty |
fromY
Specifies the start Y coordinate value of this
TranslateTransition . |
private DoubleProperty |
fromZ
Specifies the start Z coordinate value of this
TranslateTransition . |
private ObjectProperty<Node> |
node
The target node of this
TranslateTransition . |
private double |
startX |
private double |
startY |
private double |
startZ |
private DoubleProperty |
toX
Specifies the stop X coordinate value of this
TranslateTransition . |
private DoubleProperty |
toY
Specifies the stop Y coordinate value of this
TranslateTransition . |
private DoubleProperty |
toZ
Specifies the stop Z coordinate value of this
TranslateTransition . |
clipEnvelope, INDEFINITE, parent, pulseReceiver
Constructor and Description |
---|
TranslateTransition()
The constructor of
TranslateTransition |
TranslateTransition(Duration duration)
The constructor of
TranslateTransition |
TranslateTransition(Duration duration,
Node node)
The constructor of
TranslateTransition |
Modifier and Type | Method and Description |
---|---|
DoubleProperty |
byXProperty() |
DoubleProperty |
byYProperty() |
DoubleProperty |
byZProperty() |
ObjectProperty<Duration> |
durationProperty() |
DoubleProperty |
fromXProperty() |
DoubleProperty |
fromYProperty() |
DoubleProperty |
fromZProperty() |
double |
getByX() |
double |
getByY() |
double |
getByZ() |
Duration |
getDuration() |
double |
getFromX() |
double |
getFromY() |
double |
getFromZ() |
Node |
getNode() |
private Node |
getTargetNode() |
double |
getToX() |
double |
getToY() |
double |
getToZ() |
(package private) boolean |
impl_startable(boolean forceSync) |
(package private) void |
impl_sync(boolean forceSync) |
void |
interpolate(double frac)
The method
interpolate() has to be provided by implementations of
Transition . |
ObjectProperty<Node> |
nodeProperty() |
void |
setByX(double value) |
void |
setByY(double value) |
void |
setByZ(double value) |
void |
setDuration(Duration value) |
void |
setFromX(double value) |
void |
setFromY(double value) |
void |
setFromZ(double value) |
void |
setNode(Node value) |
void |
setToX(double value) |
void |
setToY(double value) |
void |
setToZ(double value) |
DoubleProperty |
toXProperty() |
DoubleProperty |
toYProperty() |
DoubleProperty |
toZProperty() |
getCachedInterpolator, getInterpolator, getParentTargetNode, impl_jumpTo, impl_playTo, interpolatorProperty, setInterpolator
autoReverseProperty, currentRateProperty, currentTimeProperty, cycleCountProperty, cycleDurationProperty, delayProperty, getCuePoints, getCurrentRate, getCurrentTime, getCycleCount, getCycleDuration, getDelay, getOnFinished, getRate, getStatus, getTargetFramerate, getTotalDuration, impl_finished, impl_pause, impl_resume, impl_setCurrentRate, impl_setCurrentTicks, impl_start, impl_stop, impl_timePulse, isAutoReverse, jumpTo, jumpTo, onFinishedProperty, pause, pauseReceiver, play, playFrom, playFrom, playFromStart, rateProperty, resumeReceiver, setAutoReverse, setCycleCount, setCycleDuration, setDelay, setOnFinished, setRate, setStatus, startReceiver, statusProperty, stop, totalDurationProperty
private static final double EPSILON
private double startX
private double startY
private double startZ
private double deltaX
private double deltaY
private double deltaZ
private ObjectProperty<Node> node
TranslateTransition
.
It is not possible to change the target node
of a running
TranslateTransition
. If the value of node
is changed for
a running TranslateTransition
, the animation has to be stopped
and started again to pick up the new value.
private static final Node DEFAULT_NODE
private Node cachedNode
private ObjectProperty<Duration> duration
TranslateTransition
.
It is not possible to change the duration
of a running
TranslateTransition
. If the value of duration
is changed
for a running TranslateTransition
, the animation has to be
stopped and started again to pick up the new value.
Note: While the unit of duration
is a millisecond, the
granularity depends on the underlying operating system and will in
general be larger. For example animations on desktop systems usually run
with a maximum of 60fps which gives a granularity of ~17 ms.
Setting duration to value lower than Duration.ZERO
will result
in IllegalArgumentException
.
private static final Duration DEFAULT_DURATION
private DoubleProperty fromX
TranslateTransition
.
It is not possible to change fromX
of a running
TranslateTransition
. If the value of fromX
is changed for
a running TranslateTransition
, the animation has to be stopped
and started again to pick up the new value.
private static final double DEFAULT_FROM_X
private DoubleProperty fromY
TranslateTransition
.
It is not possible to change fromY
of a running
TranslateTransition
. If the value of fromY
is changed for
a running TranslateTransition
, the animation has to be stopped
and started again to pick up the new value.
private static final double DEFAULT_FROM_Y
private DoubleProperty fromZ
TranslateTransition
.
It is not possible to change fromZ
of a running
TranslateTransition
. If the value of fromZ
is changed for
a running TranslateTransition
, the animation has to be stopped
and started again to pick up the new value.
private static final double DEFAULT_FROM_Z
private DoubleProperty toX
TranslateTransition
.
It is not possible to change toX
of a running
TranslateTransition
. If the value of toX
is changed for a
running TranslateTransition
, the animation has to be stopped and
started again to pick up the new value.
private static final double DEFAULT_TO_X
private DoubleProperty toY
TranslateTransition
.
It is not possible to change toY
of a running
TranslateTransition
. If the value of toY
is changed for a
running TranslateTransition
, the animation has to be stopped and
started again to pick up the new value.
private static final double DEFAULT_TO_Y
private DoubleProperty toZ
TranslateTransition
.
It is not possible to change toZ
of a running
TranslateTransition
. If the value of toZ
is changed for a
running TranslateTransition
, the animation has to be stopped and
started again to pick up the new value.
private static final double DEFAULT_TO_Z
private DoubleProperty byX
TranslateTransition
.
It is not possible to change byX
of a running
TranslateTransition
. If the value of byX
is changed for a
running TranslateTransition
, the animation has to be stopped and
started again to pick up the new value.
private static final double DEFAULT_BY_X
private DoubleProperty byY
TranslateTransition
.
It is not possible to change byY
of a running
TranslateTransition
. If the value of byY
is changed for a
running TranslateTransition
, the animation has to be stopped and
started again to pick up the new value.
private static final double DEFAULT_BY_Y
private DoubleProperty byZ
TranslateTransition
.
It is not possible to change byZ
of a running
TranslateTransition
. If the value of byZ
is changed for a
running TranslateTransition
, the animation has to be stopped and
started again to pick up the new value.
private static final double DEFAULT_BY_Z
public TranslateTransition(Duration duration, Node node)
TranslateTransition
duration
- The duration of the TranslateTransition
node
- The node
which will be translatedpublic TranslateTransition(Duration duration)
TranslateTransition
duration
- The duration of the TranslateTransition
public TranslateTransition()
TranslateTransition
public final void setNode(Node value)
public final Node getNode()
public final ObjectProperty<Node> nodeProperty()
public final void setDuration(Duration value)
public final Duration getDuration()
public final ObjectProperty<Duration> durationProperty()
public final void setFromX(double value)
public final double getFromX()
public final DoubleProperty fromXProperty()
public final void setFromY(double value)
public final double getFromY()
public final DoubleProperty fromYProperty()
public final void setFromZ(double value)
public final double getFromZ()
public final DoubleProperty fromZProperty()
public final void setToX(double value)
public final double getToX()
public final DoubleProperty toXProperty()
public final void setToY(double value)
public final double getToY()
public final DoubleProperty toYProperty()
public final void setToZ(double value)
public final double getToZ()
public final DoubleProperty toZProperty()
public final void setByX(double value)
public final double getByX()
public final DoubleProperty byXProperty()
public final void setByY(double value)
public final double getByY()
public final DoubleProperty byYProperty()
public final void setByZ(double value)
public final double getByZ()
public final DoubleProperty byZProperty()
public void interpolate(double frac)
interpolate()
has to be provided by implementations of
Transition
. While a Transition
is running, this method is
called in every frame.
The parameter defines the current position with the animation. At the
start, the fraction will be 0.0
and at the end it will be
1.0
. How the parameter increases, depends on the
interpolator
, e.g. if the
interpolator
is Interpolator.LINEAR
, the fraction will
increase linear.
This method must not be called by the user directly.interpolate
in class Transition
frac
- The relative positionprivate Node getTargetNode()
boolean impl_startable(boolean forceSync)
impl_startable
in class Transition
void impl_sync(boolean forceSync)
impl_sync
in class Transition