public final class Timeline extends Animation
Timeline can be used to define a free form animation of any
WritableValue, e.g. all
JavaFX Properties.
A Timeline, defined by one or more KeyFrames, processes
individual KeyFrame sequentially, in the order specified by
KeyFrame.time. The animated properties, defined as key values in
KeyFrame.values, are interpolated
to/from the targeted key values at the specified time of the KeyFrame
to Timeline's initial position, depends on Timeline's
direction.
Timeline processes individual KeyFrame at or after specified
time interval elapsed, it does not guarantee the timing when KeyFrame
is processed.
The Animation.cycleDurationProperty() will be set to the largest time value
of Timeline's keyFrames.
If a KeyFrame is not provided for the time==0s instant, one
will be synthesized using the target values that are current at the time
Animation.play() or Animation.playFromStart() is called.
It is not possible to change the keyFrames of a running Timeline.
If the value of keyFrames is changed for a running Timeline, it
has to be stopped and started again to pick up the new value.
A simple Timeline can be created like this:
final Timeline timeline = new Timeline();
timeline.setCycleCount(2);
timeline.setAutoReverse(true);
timeline.getKeyFrames().add(new KeyFrame(Duration.millis(5000),
new KeyValue (node.translateXProperty(), 25)));
timeline.play();
This Timeline will run for 10s, animating the node by x axis to value 25 and then back to 0 on the second cycle.
Warning : A running Timeline is being referenced from the FX runtime. Infinite Timeline might result in a memory leak if not stopped properly. All the objects with animated properties would not be garbage collected.
Animation.Status| Modifier and Type | Field and Description |
|---|---|
(package private) TimelineClipCore |
clipCore |
private ObservableList<KeyFrame> |
keyFrames |
clipEnvelope, INDEFINITE, parent, pulseReceiver| Constructor and Description |
|---|
Timeline()
The constructor of
Timeline. |
Timeline(AbstractMasterTimer timer) |
Timeline(double targetFramerate)
The constructor of
Timeline. |
Timeline(double targetFramerate,
KeyFrame... keyFrames)
The constructor of
Timeline. |
Timeline(KeyFrame... keyFrames)
The constructor of
Timeline. |
| Modifier and Type | Method and Description |
|---|---|
ObservableList<KeyFrame> |
getKeyFrames()
Returns the
KeyFrames of this Timeline. |
(package private) void |
impl_jumpTo(long currentTicks,
long cycleTicks,
boolean forceJump) |
(package private) void |
impl_playTo(long currentTicks,
long cycleTicks) |
(package private) void |
impl_setCurrentRate(double currentRate) |
(package private) void |
impl_start(boolean forceSync) |
void |
stop()
Stops the animation and resets the play head to its initial position.
|
autoReverseProperty, currentRateProperty, currentTimeProperty, cycleCountProperty, cycleDurationProperty, delayProperty, getCuePoints, getCurrentRate, getCurrentTime, getCycleCount, getCycleDuration, getDelay, getOnFinished, getRate, getStatus, getTargetFramerate, getTotalDuration, impl_finished, impl_pause, impl_resume, impl_setCurrentTicks, impl_startable, impl_stop, impl_sync, impl_timePulse, isAutoReverse, jumpTo, jumpTo, onFinishedProperty, pause, pauseReceiver, play, playFrom, playFrom, playFromStart, rateProperty, resumeReceiver, setAutoReverse, setCycleCount, setCycleDuration, setDelay, setOnFinished, setRate, setStatus, startReceiver, statusProperty, totalDurationPropertyfinal TimelineClipCore clipCore
private final ObservableList<KeyFrame> keyFrames
public Timeline(double targetFramerate,
KeyFrame... keyFrames)
Timeline.
This constructor allows to define a Animation.targetFramerate.targetFramerate - The custom target frame rate for this TimelinekeyFrames - The keyframes of this Timelinepublic Timeline(KeyFrame... keyFrames)
Timeline.keyFrames - The keyframes of this Timelinepublic Timeline(double targetFramerate)
Timeline.
This constructor allows to define a Animation.targetFramerate.targetFramerate - The custom target frame rate for this Timelinepublic Timeline()
Timeline.Timeline(AbstractMasterTimer timer)
public final ObservableList<KeyFrame> getKeyFrames()
KeyFrames of this Timeline.void impl_playTo(long currentTicks,
long cycleTicks)
impl_playTo in class Animationvoid impl_jumpTo(long currentTicks,
long cycleTicks,
boolean forceJump)
impl_jumpTo in class Animationvoid impl_setCurrentRate(double currentRate)
impl_setCurrentRate in class Animationvoid impl_start(boolean forceSync)
impl_start in class Animation