Spec-Zone .ru
спецификации, руководства, описания, API
|
public abstract class Animation
extends java.lang.Object
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.
Timeline
,
Transition
Type | Property and Description |
---|---|
BooleanProperty |
autoReverse
Defines whether this
Animation reverses direction on alternating cycles. |
ReadOnlyDoubleProperty |
currentRate
Read-only variable to indicate current direction/speed at which the
Timeline is being played. |
ReadOnlyObjectProperty<Duration> |
currentTime |
IntegerProperty |
cycleCount
Defines the number of cycles in this animation.
|
ReadOnlyObjectProperty<Duration> |
cycleDuration
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). |
ObjectProperty<Duration> |
delay
Delays the start of an animation.
|
ObjectProperty<EventHandler<ActionEvent>> |
onFinished
The action to be executed at the conclusion of this
Animation . |
DoubleProperty |
rate
Defines the direction/speed at which the
Timeline is expected to
be played. |
ReadOnlyObjectProperty<Animation.Status> |
status
The status of the
Animation . |
ReadOnlyObjectProperty<Duration> |
totalDuration
Read-only variable to indicate the total duration of this
Timeline , including repeats. |
Modifier and Type | Class and Description |
---|---|
static class |
Animation.Status
The possible states for
status . |
Modifier and Type | Field and Description |
---|---|
static int |
INDEFINITE
Used to specify an animation that repeats indefinitely, until the
stop() method is called. |
Modifier | Constructor and Description |
---|---|
protected |
Animation()
The constructor of
Animation . |
protected |
Animation(double targetFramerate)
The constructor of
Animation . |
Modifier and Type | Method and Description |
---|---|
BooleanProperty |
autoReverseProperty()
Defines whether this
Animation reverses direction on alternating cycles. |
ReadOnlyDoubleProperty |
currentRateProperty()
Read-only variable to indicate current direction/speed at which the
Timeline is being played. |
ReadOnlyObjectProperty<Duration> |
currentTimeProperty() |
IntegerProperty |
cycleCountProperty()
Defines the number of cycles in this animation.
|
ReadOnlyObjectProperty<Duration> |
cycleDurationProperty()
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). |
ObjectProperty<Duration> |
delayProperty()
Delays the start of an animation.
|
ObservableMap<java.lang.String,Duration> |
getCuePoints()
The cue points can be
used to mark important positions of the
Animation . |
double |
getCurrentRate()
Read-only variable to indicate current direction/speed at which the
Timeline is being played. |
Duration |
getCurrentTime() |
int |
getCycleCount()
Defines the number of cycles in this animation.
|
Duration |
getCycleDuration()
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). |
Duration |
getDelay()
Delays the start of an animation.
|
EventHandler<ActionEvent> |
getOnFinished()
The action to be executed at the conclusion of this
Animation . |
double |
getRate()
Defines the direction/speed at which the
Timeline is expected to
be played. |
Animation.Status |
getStatus()
The status of the
Animation . |
double |
getTargetFramerate()
The target framerate is the maximum framerate at which this animation
will run, in frames per second.
|
Duration |
getTotalDuration()
Read-only variable to indicate the total duration of this
Timeline , including repeats. |
boolean |
isAutoReverse()
Defines whether this
Animation reverses direction on alternating cycles. |
void |
jumpTo(Duration time)
Jumps to a given position in this
Animation . |
void |
jumpTo(java.lang.String cuePoint)
Jumps to a predefined position in this
Animation . |
ObjectProperty<EventHandler<ActionEvent>> |
onFinishedProperty()
The action to be executed at the conclusion of this
Animation . |
void |
pause()
Pauses the animation.
|
void |
play()
Plays
Timeline from current position in the direction indicated
by rate . |
void |
playFrom(Duration time)
A convenience method to play this
Animation from a specific
position. |
void |
playFrom(java.lang.String cuePoint)
A convenience method to play this
Animation from a predefined
position. |
void |
playFromStart()
Plays timeline from initial position in forward direction.
|
DoubleProperty |
rateProperty()
Defines the direction/speed at which the
Timeline is expected to
be played. |
void |
setAutoReverse(boolean value)
Defines whether this
Animation reverses direction on alternating cycles. |
void |
setCycleCount(int value)
Defines the number of cycles in this animation.
|
protected void |
setCycleDuration(Duration value)
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). |
void |
setDelay(Duration value)
Delays the start of an animation.
|
void |
setOnFinished(EventHandler<ActionEvent> value)
The action to be executed at the conclusion of this
Animation . |
void |
setRate(double value)
Defines the direction/speed at which the
Timeline is expected to
be played. |
protected void |
setStatus(Animation.Status value)
The status of the
Animation . |
ReadOnlyObjectProperty<Animation.Status> |
statusProperty()
The status of the
Animation . |
void |
stop()
Stops the animation and resets the play head to its initial position.
|
ReadOnlyObjectProperty<Duration> |
totalDurationProperty()
Read-only variable to indicate the total duration of this
Timeline , including repeats. |
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.
getRate()
,
setRate(double)
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
getCurrentRate()
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.
getCycleDuration()
,
setCycleDuration(Duration)
Timeline
, including repeats. A Timeline with a cycleCount
of Timeline.INDEFINITE
will have a totalDuration
of
Duration.INDEFINITE
.
This is set to cycleDuration * cycleCount.
getTotalDuration()
getCurrentTime()
getDelay()
,
setDelay(Duration)
cycleCount
may be INDEFINITE
for animations that repeat indefinitely, but
must otherwise be > 0.
It is not possible to change the cycleCount
of a running
Animation
. If the value of cycleCount
is changed for a
running Animation
, the animation has to be stopped and started again to pick
up the new value.
getCycleCount()
,
setCycleCount(int)
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 start.
It is not possible to change the autoReverse
flag of a running
Animation
. If the value of autoReverse
is changed for a
running Animation
, the animation has to be stopped and started again to pick
up the new value.isAutoReverse()
,
setAutoReverse(boolean)
Animation
.
In Animation
can be in one of three states:
Animation.Status.STOPPED
, Animation.Status.PAUSED
or Animation.Status.RUNNING
.getStatus()
,
setStatus(Status)
Animation
.getOnFinished()
,
setOnFinished(EventHandler)
public static final int INDEFINITE
stop()
method is called.protected Animation(double targetFramerate)
Animation
.
This constructor allows to define a target framerate.targetFramerate
- The custom target frame rate for this Animation
getTargetFramerate()
protected Animation()
Animation
.public final void setRate(double value)
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.
public final double getRate()
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.
public final DoubleProperty rateProperty()
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.
getRate()
,
setRate(double)
public final double getCurrentRate()
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
public final ReadOnlyDoubleProperty currentRateProperty()
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
getCurrentRate()
protected final void setCycleDuration(Duration value)
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.
public final Duration getCycleDuration()
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.
public final ReadOnlyObjectProperty<Duration> cycleDurationProperty()
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.
getCycleDuration()
,
setCycleDuration(Duration)
public final Duration getTotalDuration()
Timeline
, including repeats. A Timeline with a cycleCount
of Timeline.INDEFINITE
will have a totalDuration
of
Duration.INDEFINITE
.
This is set to cycleDuration * cycleCount.
public final ReadOnlyObjectProperty<Duration> totalDurationProperty()
Timeline
, including repeats. A Timeline with a cycleCount
of Timeline.INDEFINITE
will have a totalDuration
of
Duration.INDEFINITE
.
This is set to cycleDuration * cycleCount.
getTotalDuration()
public final Duration getCurrentTime()
public final ReadOnlyObjectProperty<Duration> currentTimeProperty()
getCurrentTime()
public final void setDelay(Duration value)
public final Duration getDelay()
public final ObjectProperty<Duration> delayProperty()
getDelay()
,
setDelay(Duration)
public final void setCycleCount(int value)
cycleCount
may be INDEFINITE
for animations that repeat indefinitely, but
must otherwise be > 0.
It is not possible to change the cycleCount
of a running
Animation
. If the value of cycleCount
is changed for a
running Animation
, the animation has to be stopped and started again to pick
up the new value.
public final int getCycleCount()
cycleCount
may be INDEFINITE
for animations that repeat indefinitely, but
must otherwise be > 0.
It is not possible to change the cycleCount
of a running
Animation
. If the value of cycleCount
is changed for a
running Animation
, the animation has to be stopped and started again to pick
up the new value.
public final IntegerProperty cycleCountProperty()
cycleCount
may be INDEFINITE
for animations that repeat indefinitely, but
must otherwise be > 0.
It is not possible to change the cycleCount
of a running
Animation
. If the value of cycleCount
is changed for a
running Animation
, the animation has to be stopped and started again to pick
up the new value.
getCycleCount()
,
setCycleCount(int)
public final void setAutoReverse(boolean value)
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 start.
It is not possible to change the autoReverse
flag of a running
Animation
. If the value of autoReverse
is changed for a
running Animation
, the animation has to be stopped and started again to pick
up the new value.public final boolean isAutoReverse()
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 start.
It is not possible to change the autoReverse
flag of a running
Animation
. If the value of autoReverse
is changed for a
running Animation
, the animation has to be stopped and started again to pick
up the new value.public final BooleanProperty autoReverseProperty()
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 start.
It is not possible to change the autoReverse
flag of a running
Animation
. If the value of autoReverse
is changed for a
running Animation
, the animation has to be stopped and started again to pick
up the new value.isAutoReverse()
,
setAutoReverse(boolean)
protected final void setStatus(Animation.Status value)
Animation
.
In Animation
can be in one of three states:
Animation.Status.STOPPED
, Animation.Status.PAUSED
or Animation.Status.RUNNING
.public final Animation.Status getStatus()
Animation
.
In Animation
can be in one of three states:
Animation.Status.STOPPED
, Animation.Status.PAUSED
or Animation.Status.RUNNING
.public final ReadOnlyObjectProperty<Animation.Status> statusProperty()
Animation
.
In Animation
can be in one of three states:
Animation.Status.STOPPED
, Animation.Status.PAUSED
or Animation.Status.RUNNING
.getStatus()
,
setStatus(Status)
public final double getTargetFramerate()
public final void setOnFinished(EventHandler<ActionEvent> value)
Animation
.public final EventHandler<ActionEvent> getOnFinished()
Animation
.public final ObjectProperty<EventHandler<ActionEvent>> onFinishedProperty()
Animation
.getOnFinished()
,
setOnFinished(EventHandler)
public final ObservableMap<java.lang.String,Duration> getCuePoints()
Animation
. Once a cue
point was defined, it can be used as an argument of
jumpTo()
and playFrom()
to move to the associated position quickly.
Every Animation
has two predefined cue points "start"
and
"end"
, which are set at the start respectively the end of the
Animation
. The predefined cuepoints do not appear in the map,
attempts to override them have no effect.
Another option to define a cue point in a Timeline
is to set the
KeyFrame.name
property of a KeyFrame
.
ObservableMap
of cue pointspublic void jumpTo(Duration time)
Animation
.
If the given time is less than Duration.ZERO
, this method will
jump to the start of the animation. If the given time is larger than the
duration of this Animation
, this method will jump to the end.time
- the new positionjava.lang.NullPointerException
- if time
is null
java.lang.IllegalArgumentException
- if time
is Duration.UNKNOWN
public void jumpTo(java.lang.String cuePoint)
Animation
. This method
looks for an entry in cue points and jumps to the associated
position, if it finds one.
If the cue point is behind the end of this Animation
, calling
jumpTo
will result in a jump to the end. If the cue point has a
negative Duration
it will result in a jump to the
beginning. If the cue point has a value of
Duration.UNKNOWN
calling jumpTo
will have no
effect for this cue point.
There are two predefined cue points "start"
and "end"
which are defined to be at the start respectively the end of this
Animation
.
cuePoint
- the name of the cue pointjava.lang.NullPointerException
- if cuePoint
is null
getCuePoints()
public void playFrom(java.lang.String cuePoint)
Animation
from a predefined
position. The position has to be predefined in cue points.
Calling this method is equivalent to
animation.jumpTo(cuePoint);
animation.play();
Note that unlike playFromStart()
calling this method will not
change the playing direction of this Animation
.cuePoint
- name of the cue pointjava.lang.NullPointerException
- if cuePoint
is null
getCuePoints()
public void playFrom(Duration time)
Animation
from a specific
position. Calling this method is equivalent to
animation.jumpTo(time);
animation.play();
Note that unlike playFromStart()
calling this method will not
change the playing direction of this Animation
.time
- position where to play fromjava.lang.NullPointerException
- if time
is null
java.lang.IllegalArgumentException
- if time
is Duration.UNKNOWN
public void play()
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 cycleCount
> 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. public void playFromStart()
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. public void stop()
Note:
stop()
is an asynchronous call, timeline may not stop
immediately. public void pause()
Note:
pause()
is an asynchronous call, timeline may not pause
immediately. Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved. Use is subject to