APIdia Launch Partner
Top Description Fields Constructors Methods
javafx.animation

public final Class Timeline

extends Animation
Class Inheritance
Imports
javafx.collections.ListChangeListener.Change, .ObservableList, javafx.util.Duration, com.sun.javafx.collections.TrackableObservableList, com.sun.scenario.animation.AbstractPrimaryTimer, com.sun.scenario.animation.shared.TimelineClipCore

A Timeline can be used to define a free form animation of any javafx.beans.value.WritableValue, for example, all JavaFX Properties.

A Timeline, defined by one or more KeyFrames, processes individual KeyFrames 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 an individual KeyFrame at or after the specified time interval elapsed, it does not guarantee the exact time when a KeyFrame is processed.

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 play() or playFromStart() are 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.

The cycleDurationProperty() will be set to the largest time value of Timeline's keyFrames.

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.

Since
JavaFX 2.0
See Also
Animation, KeyFrame, KeyValue

Field Summary

Modifier and TypeField and Description
pack-priv final TimelineClipCore
private final ObservableList<KeyFrame>
Inherited from javafx.animation.Animation:
clipEnvelopeINDEFINITEparentpulseReceiver

Constructor Summary

AccessConstructor and Description
public
Timeline(double
the custom target frame rate for this Timeline
targetFramerate
,
KeyFrame...
the keyframes of this Timeline
keyFrames
)

Creates a Timeline with the provided key frames and a target framerate.

public
Timeline(KeyFrame...
the keyframes of this Timeline
keyFrames
)

Creates a Timeline with the provided key frames.

public
Timeline(double
the custom target frame rate for this Timeline
targetFramerate
)

Creates a Timeline with no key frames and a target framerate.

public
Timeline()

Creates a Timeline with no key frames.

pack-priv

Method Summary

Modifier and TypeMethod and Description
pack-priv void
doJumpTo(long currentTicks, long cycleTicks, boolean forceJump)

Implements abstract javafx.animation.Animation.doJumpTo.

pack-priv void
doPlayTo(long currentTicks, long cycleTicks)

Implements abstract javafx.animation.Animation.doPlayTo.

pack-priv void
doStart(boolean forceSync)

Overrides javafx.animation.Animation.doStart.

public final ObservableList<KeyFrame>

Returns:

the KeyFrames
getKeyFrames
()

Returns the KeyFrames of this Timeline.

pack-priv void
pack-priv void
stopImpl()

Overrides javafx.animation.Animation.stopImpl.

This method must be run on the JavaFX Application Thread.

Inherited from javafx.animation.Animation:
autoReversePropertycurrentRatePropertycurrentTimePropertycycleCountPropertycycleDurationPropertydelayPropertydoPausedoResumedoStopdoTimePulsefinishedgetCuePointsgetCurrentRategetCurrentTimegetCycleCountgetCycleDurationgetDelaygetOnFinishedgetRategetStatusgetTargetFramerategetTotalDurationisAutoReverseisNearZeroisPausedisRunningisStoppedjumpTojumpToonFinishedPropertypausepauseReceiverplayplayFromplayFromplayFromStartratePropertyresumeReceiverrunHandlersetAutoReversesetCurrentTickssetCycleCountsetCycleDurationsetDelaysetOnFinishedsetRatesetStatusstartablestartReceiverstatusPropertystopsynctotalDurationProperty

Field Detail

clipCoreback to summary
pack-priv final TimelineClipCore clipCore
keyFramesback to summary
private final ObservableList<KeyFrame> keyFrames

Constructor Detail

Timelineback to summary
public Timeline(double targetFramerate, KeyFrame... keyFrames)

Creates a Timeline with the provided key frames and a target framerate. The key frames do not need to be ordered.

Parameters
targetFramerate:double

the custom target frame rate for this Timeline

keyFrames:KeyFrame[]

the keyframes of this Timeline

Timelineback to summary
public Timeline(KeyFrame... keyFrames)

Creates a Timeline with the provided key frames. The key frames do not need to be ordered.

Parameters
keyFrames:KeyFrame[]

the keyframes of this Timeline

Timelineback to summary
public Timeline(double targetFramerate)

Creates a Timeline with no key frames and a target framerate.

Parameters
targetFramerate:double

the custom target frame rate for this Timeline

Timelineback to summary
public Timeline()

Creates a Timeline with no key frames.

Timelineback to summary
pack-priv Timeline(final AbstractPrimaryTimer timer)

Method Detail

doJumpToback to summary
pack-priv void doJumpTo(long currentTicks, long cycleTicks, boolean forceJump)

Implements abstract javafx.animation.Animation.doJumpTo.

Annotations
@Override
doPlayToback to summary
pack-priv void doPlayTo(long currentTicks, long cycleTicks)

Implements abstract javafx.animation.Animation.doPlayTo.

Annotations
@Override
doStartback to summary
pack-priv void doStart(boolean forceSync)

Overrides javafx.animation.Animation.doStart.

Annotations
@Override
getKeyFramesback to summary
public final ObservableList<KeyFrame> getKeyFrames()

Returns the KeyFrames of this Timeline.

Returns:ObservableList<KeyFrame>

the KeyFrames

setCurrentRateback to summary
pack-priv void setCurrentRate(double currentRate)

Overrides javafx.animation.Animation.setCurrentRate.

Annotations
@Override
stopImplback to summary
pack-priv void stopImpl()

Overrides javafx.animation.Animation.stopImpl.

Doc from javafx.animation.Animation.stopImpl.

This method must be run on the JavaFX Application Thread.

Annotations
@Override