Class Transition
- Direct Known Subclasses:
FadeTransition
,FillTransition
,ParallelTransition
,PathTransition
,PauseTransition
,RotateTransition
,ScaleTransition
,SequentialTransition
,StrokeTransition
,TranslateTransition
Transition
based animations, such as PathTransition
and
RotateTransition
.
This class offers a simple framework to define animation. It provides all the
basic functionality defined in Animation
. Transition
requires
the implementation of a method interpolate(double)
which is the
called in each frame, while the Transition
is running.
In addition, an extending class needs to set the duration of a single cycle
with Animation.setCycleDuration(javafx.util.Duration)
. This duration
is usually set by the user via a duration property (as in
duration
) for example. But it can also be calculated
by the extending class as is done in ParallelTransition
and
FadeTransition
.
Below is a simple example. It creates a small animation that updates the
text
property of a Text
node. It starts
with an empty String
and adds gradually letter by letter until the
full String
was set when the animation finishes.
final String content = "Lorem ipsum";
final Text text = new Text(10, 20, "");
final Animation animation = new Transition() {
{
setCycleDuration(Duration.millis(2000));
}
protected void interpolate(double frac) {
final int length = content.length();
final int n = Math.round(length * (float) frac);
text.setText(content.substring(0, n));
}
};
animation.play();
- Since:
- JavaFX 2.0
- See Also:
-
Nested Class Summary
Nested classes/interfaces declared in class javafx.animation.Animation
Animation.Status
-
Property Summary
PropertiesTypePropertyDescriptionfinal ObjectProperty
<Interpolator> Controls the timing for acceleration and deceleration at eachTransition
cycle.Properties declared in class javafx.animation.Animation
autoReverse, currentRate, currentTime, cycleCount, cycleDuration, delay, onFinished, rate, status, totalDuration
-
Field Summary
Fields declared in class javafx.animation.Animation
INDEFINITE
-
Constructor Summary
ConstructorsConstructorDescriptionThe constructor ofTransition
.Transition
(double targetFramerate) The constructor ofTransition
. -
Method Summary
Modifier and TypeMethodDescriptionprotected Interpolator
Returns theInterpolator
, that was set when theTransition
was started.final Interpolator
Gets the value of theinterpolator
property.protected Node
Returns the first non-null
targetNode
in the parent hierarchy of thisTransition
, ornull
if such a node is not found.protected abstract void
interpolate
(double frac) The methodinterpolate()
has to be provided by implementations ofTransition
.final ObjectProperty
<