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. Timeline with indefinite duration, defined as a Timeline has repeatCount = INDEFINITE or a Timeline contains such sub timeline, runs forever, until explicit stop() is called, which will stop the running Timeline and reset its playhead to initial position.

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

Timeline's playhead can be randomly positioned, no matter it is running or not. If the Timeline is running, the playhead 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

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-initframerateNumber

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

publicINDEFINITEInteger

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

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

 
publictimeDuration0.0ms

Defines Timeline's play head position.

Defines 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;
...
}

Changes time to sub timelines are ignored.

0.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.
  • It has no effect on sub timelines.

    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 playhead 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.
  • It has no effect on sub timelines.

    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.
  • It has no effect on sub timelines.

    Profile: common

    &nbsp;
  • public stop() : Void

    Stops the animation and resets playhead to initial position.

    Stops the animation and resets playhead to 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.
  • It has no effect on sub timelines.

    Profile: common

    &nbsp;
  • Inherited Functions




    Spec-Zone.ru - all specs in one place