Spec-Zone .ru
спецификации, руководства, описания, API

JavaFX: Bringing Rich Experiences To All the Screens Of Your Life

Profile: desktop, common

Overview

An animation is driven by its associated properties, such as size, location and color, etc. Timeline provides the capability to update the property values along the progression of time.

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 (when interpolation is enabled) 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.

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

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

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

Invert the value of rate can invert Timeline play direction. Inverting a running Timeline causes it to reverse direction in play and play back over the portion it has elapsed.

See Also:
KeyFrame

Profile: common

Script Variable Summary

accessnametypeCan ReadCan InitCan WriteDefault Valuedescription
publicINDEFINITEInteger

Used to specify an animation that repeats indefinitely, until the stop() method is called.

Variable Summary

accessnametypeCan ReadCan InitCan WriteDefault Valuedescription
publicautoReverseBooleanfalse

Defines whether this animation reverses direction on alternating cycles.

Defines whether this animation reverses direction on alternating cycles. If true, the animation will proceed forward on the first cycle, then reverses on the second cycle, and so on. Otherwise, animation will loop such that each cycle proceeds forward from the initial KeyFrame.

false

Profile: common

 
public-readcurrentRateNumber0.0

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

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

currentRate is not necessary equal to rate. currentRate is set to 0.0 when animation is paused or stopped. currentRate may also point to different direction during reverse cycles when autoReverse is true

0.0

Profile: common

 
public-read protectedcycleDurationDurationsubclasssubclass0ms

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

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

This is set to the largest time value of its keyFrames.

0ms

Profile: common

 
public-initframerateNumber

The maximum framerate at which this animation will run, in frames per second.

The maximum framerate at which this animation will run, in frames per second. This can be used, for example, to keep particularly complex Timelines from over-consuming system resources. By default, a Timeline's framerate is not explicitly limited, meaning the Timeline will run at an optimal framerate for the underlying platform.

Profile: common

 
publicinterpolateBooleantrue

Enable/disable interpolation.

publickeyFramesKeyFrame[]

Defines the sequence of KeyFrames in this animation.

Defines the sequence of KeyFrames in this animation. 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() is called.

Profile: common

 
public-readpausedBoolean

Read-only var that indicates whether the animation is currently paused.

Read-only var that indicates whether the animation is currently paused.

This value is initially false. It will become true after pause() has been called on a running animation, and then becomes false again after an explicit call to resume() or stop().

Note that running will remain true even when paused==true.

Profile: common

 
publicrateNumber1.0

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

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

The absolute value of rate indicates the speed which the Timeline is to be played, while the sign of rate indicates the direction. A postive value of rate indicates forward play, a negative value indicates backward play and 0.0 to stop a running timeline.

Rate 1.0 is normal play, 2.0 is 2 time normal, -1.0 is backwards, etc...

Inverting the rate of a running Timeline will cause the Timeline to reverse direction in place and play back over the portion of the Timeline that has alreay elapsed.

1.0

Profile: common

 
publicrepeatCountNumber1.0

Defines the number of cycles in this animation.

Defines the number of cycles in this animation. The repeatCount may be INDEFINITE for animations that repeat indefinitely, but must otherwise be >= 0.

1.0

Profile: common

 
public-readrunningBoolean

Read-only var that indicates whether the animation is currently running.

Read-only var that indicates whether the animation is currently running.

This value is initially false. It will become true after start() has been called, and then becomes false again after the animation ends naturally, or after an explicit call to stop().

Note that running will remain true even when paused==true.

Profile: common

 
publictimeDuration0ms

Defines the Timeline's play head position.

Defines the Timeline's play head position.

If Timeline is running, it jumps to the specified position immediately. If it is not running, the time indicates from where the Timeline to start when next play() is called.

If user wants to bind the variable and update it simultaneously, bidirectional bind is needed.

var pos: Duration;
var t: Timeline = Timeline {
time: bind pos with inverse;
...
}

0ms

Profile: common

 
public-readtotalDurationDuration0ms

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

Read-only variable to indicate the total duration of this Timeline, including repeats. A Timeline with a repeatCount of Timeline.INDEFINITE will have a totalDuration of Duration.INDEFINITE.

This is set to cycleDuration * repeatCount.

0ms

Profile: common

 

Inherited Variables

Function Summary

public pause() : Void

Pauses the animation.

Pauses the animation. If the animation is not currently running, this method has no effect.

Note:

  • pause() is an asynchronous call, timeline may not pause immediately.

    Profile: common

     
  • public play() : Void

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

    Plays Timeline from current position in the direction indicated by rate. If the timeline is running, it has no effect.

    When rate > 0 (forward play), if a Timeline is already positioned at the end, the first cycle will not be played, it is considered to have already finished. This also applies to a backward (rate < 0) cycle if a timeline is positioned at the beginning. However, if the Timeline has repeatCount > 1, following cycle(s) will be played as usual.

    When Timeline reaches the end, Timeline is stopped and the play head remains at the end.

    To play a Timeline backwards from the end:
    timeline.rate = negative rate
    timeline.time = overall duration of timeline
    timeline.play()

    Note:

  • play() is an asynchronous call, Timeline may not start immediately.

    Profile: common

    &nbsp;
  • public playFromStart() : Void

    Plays timeline from initial position in forward direction.

    Plays timeline from initial position in forward direction.

    It is equivalent to

    timeline.stop();
    timeline.rate = Math.abs(timeline.rate);
    timeline.time = 0.0s;
    timeline.play();

    Note:

  • playFromStart() is an asynchronous call, Timeline may not start immediately.

    Profile: common

    &nbsp;
  • public stop() : Void

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

    Stops the animation and resets the play head to its initial position. If the animation is not currently running, this method has no effect.

    Note:

  • stop() is an asynchronous call, timeline may not stop immediately.

    Profile: common

    &nbsp;
  • Inherited Functions