Top Description Inners Fields Constructors Methods
javafx.animation

public abstract Class Animation

extends Object
Class Inheritance
Known Direct Subclasses
javafx.animation.Timeline, javafx.animation.Transition
Imports
java.util.Objects, com.sun.javafx.tk.Toolkit, com.sun.javafx.util.Utils, javafx.beans.property.BooleanProperty, .BooleanPropertyBase, .DoubleProperty, .DoublePropertyBase, .IntegerProperty, .IntegerPropertyBase, .ObjectProperty, .ObjectPropertyBase, .ReadOnlyDoubleProperty, .ReadOnlyDoublePropertyBase, .ReadOnlyObjectProperty, .ReadOnlyObjectPropertyBase, javafx.collections.FXCollections, .ObservableMap, javafx.event.ActionEvent, .EventHandler, javafx.util.Duration, com.sun.javafx.animation.TickCalculation, com.sun.scenario.animation.AbstractPrimaryTimer, com.sun.scenario.animation.shared.ClipEnvelope, .PulseReceiver

The class Animation provides the core functionality of all animations used in the JavaFX runtime.

An animation can run in a loop by setting cycleCount. To make an animation run back and forth while looping, set the autoReverse -flag.

Call play() or playFromStart() to play an Animation . The Animation progresses in the direction and speed specified by rate, and stops when its duration is elapsed. An Animation with indefinite duration (a cycleCount of INDEFINITE) runs repeatedly until the stop() method is explicitly called, which will stop the running Animation and reset its play head to the initial position.

An Animation can be paused by calling pause(), and the next play() call will resume the Animation from where it was paused.

An Animation's play head can be randomly positioned, whether it is running or not. If the Animation is running, the play head jumps to the specified position immediately and continues playing from new position. If the Animation is not running, the next play() will start the Animation from the specified position.

Inverting the value of rate toggles the play direction.

The animation runs on the JavaFX Application Thread.

Since
JavaFX 2.0
See Also
Timeline, Transition

Nested and Inner Type Summary

Modifier and TypeClass and Description
private class
private class
private class
public static enum
Animation.Status

The possible states for status.

Field Summary

Modifier and TypeField and Description
private BooleanProperty
autoReverse

Defines whether this Animation reverses direction on alternating cycles.

pack-priv ClipEnvelope
clipEnvelope

The type of ClipEnvelope for the animation is determined by its cycleCount and cycleDuration and is updated when these values change.

private ObservableMap<String, Duration>
private ReadOnlyDoubleProperty
currentRate

Read-only variable to indicate current direction/speed at which the Animation is being played.

private long
private Animation.CurrentTimeProperty
currentTime

Defines the Animation's play head position.

private IntegerProperty
cycleCount

Defines the number of cycles in this animation.

private ReadOnlyObjectProperty<Duration>
cycleDuration

Read-only variable to indicate the duration of one cycle of this Animation: the time it takes to play from time 0 to the end of the Animation (at the default rate of 1.0).

private static final boolean
private static final double
private static final int
private static final Duration
private static final Duration
private static final EventHandler<ActionEvent>
private static final double
private static final Animation.Status
private static final Duration
private ObjectProperty<Duration>
delay

Delays the start of an animation.

private static final double
public static final int
INDEFINITE

Used as a value for cycleCount to specify an animation that repeats indefinitely, until the stop() method is called.

private boolean
private boolean
private long
private double
private ObjectProperty<EventHandler<ActionEvent>>
onFinished

The action to be executed at the conclusion of this Animation.

pack-priv Animation
parent

The parent of this Animation.

private boolean
private long
pack-priv final PulseReceiver
private DoubleProperty
rate

Defines the direction/speed at which the Animation is expected to be played.

private final int
private long
private ReadOnlyObjectProperty<Animation.Status>
status

The status of the Animation.

private final double
private final AbstractPrimaryTimer
private ReadOnlyObjectProperty<Duration>
totalDuration

Read-only variable to indicate the total duration of this Animation, including repeats.

Constructor Summary

AccessConstructor and Description
protected
Animation(double
The custom target frame rate for this Animation
targetFramerate
)

The constructor of Animation.

protected
Animation()

The constructor of Animation.

pack-priv
pack-priv
Animation(AbstractPrimaryTimer timer, ClipEnvelope clipEnvelope, int resolution)

Method Summary

Modifier and TypeMethod and Description
private void
private static boolean

Returns:

true i.f.f. Math.abs(rate1 - rate2) < EPSILON
areNearEqual
(double rate1, double rate2)

Checks if 2 rates are effectively equal.

public final BooleanProperty
public final ReadOnlyDoubleProperty
public final ReadOnlyObjectProperty<Duration>
public final IntegerProperty
public final ReadOnlyObjectProperty<Duration>
public final ObjectProperty<Duration>
pack-priv abstract void
doJumpTo(long currentTicks, long cycleTicks, boolean forceJump)

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

pack-priv void
private void
doSetCurrentRate(double
the value of the new current rate
value
)

The current rate changes in 3 cases:

  1. When the rate is changed.
  2. When the status is changed (paused/stopped/resumed/started).
  3. When switching between a forwards and backwards cycle.
pack-priv void
doStart(boolean forceSync)

pack-priv void
pack-priv void
doTimePulse(long elapsedTime)

pack-priv final void
public final ObservableMap<String, Duration>

Returns:

javafx.collections.ObservableMap of cue points
getCuePoints
()

The cue points can be used to mark important positions of the Animation.

public final double
public final Duration
public final int
public final Duration
public final Duration
public final EventHandler<ActionEvent>
public final double
public final Animation.Status
public final double

Returns:

the target framerate
getTargetFramerate
()

The target framerate is the maximum framerate at which this Animation will run, in frames per second.

public final Duration
public final boolean
pack-priv static final boolean

Returns:

true i.f.f. abs(rate) < EPSILON
isNearZero
(double rate)

Checks if the rate is effectively 0.

pack-priv boolean
pack-priv boolean
private boolean
pack-priv boolean
public void
jumpTo(Duration
the new position
time
)

Jumps to a given position in this Animation.

public void
jumpTo(String
the name of the cue point
cuePoint
)

Jumps to a predefined position in this Animation.

private long
now()

public final ObjectProperty<EventHandler<ActionEvent>>
public void
pause()

Pauses the animation.

private void
pauseImpl()

This method must be run on the JavaFX Application Thread.

pack-priv void
public void
play()

Plays Animation from current position in the direction indicated by rate.

public void
playFrom(String
name of the cue point
cuePoint
)

A convenience method to play this Animation from a predefined position.

public void
playFrom(Duration
position where to play from
time
)

A convenience method to play this Animation from a specific position.

private void
playFromImpl(String cuePoint)

This method must be run on the JavaFX Application Thread.

private void
playFromImpl(Duration time)

This method must be run on the JavaFX Application Thread.

public void
playFromStart()

Plays an Animation from initial position in forward direction.

private void
playFromStartImpl()

This method must be run on the JavaFX Application Thread.

private void
playImpl()

This method must be run on the JavaFX Application Thread.

public final DoubleProperty
pack-priv void
pack-priv void
public final void
setAutoReverse(boolean value)

pack-priv void
setCurrentRate(double currentRate)

pack-priv void
setCurrentTicks(long ticks)

public final void
setCycleCount(int value)

protected final void
public final void
public final void
public final void
setRate(double value)

protected final void
pack-priv boolean
startable(boolean forceSync)

pack-priv void
startReceiver(long delay)

public final ReadOnlyObjectProperty<Animation.Status>
public void
stop()

Stops the animation and resets the play head to its initial position.

pack-priv void
stopImpl()

This method must be run on the JavaFX Application Thread.

pack-priv void
sync(boolean forceSync)

private void
public final ReadOnlyObjectProperty<Duration>
private void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait