Class Transition

java.lang.Object
javafx.animation.Animation
javafx.animation.Transition
Direct Known Subclasses:
FadeTransition, FillTransition, ParallelTransition, PathTransition, PauseTransition, RotateTransition, ScaleTransition, SequentialTransition, StrokeTransition, TranslateTransition

public abstract class Transition extends Animation
An abstract class that contains the basic functionalities required by all 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: