Java Reference
In-Depth Information
See also
F
Chapter 2—Drawing simple shapes
F
Chapter 2—Creating complex shapes using Path
Composing animation with the
Transition API
In the recipe
Creating simple animation with the Transition API
, we explored how to animate
an object using one of the transition classes. What if, however, you want to create more
complex animation sequences composed of multiple transition steps? This recipe shows
you how to use the Transition API in order to create more elaborate animation sequences
composed of multiple transition classes.
Getting ready
In order to follow this recipe, you must know how to create shapes and animate them using the
Transition API. For an introduction on the API, refer to the recipe
Creating simple animation with
the Transition API
. Again, all of the transition classes provided by the Transition API are located
in the package
javafx.animation.transition
. For this recipe you will use the class
ParallelTransition
to compose multi-step, transition-based animation sequences.
How to do it...
The abbreviated code snippet given next shows you how to use the
ParallelTransition
class to create animation sequences. You can get the complete listing of the code from
ch03/
source-code/src/animation/trans/ParallelTransitionDemo.fx
.
def w = 400;
def h = 200;
def r = 25;
def circles = Group{
content:[
Circle {
centerX:0 centerY:(h / 2) radius:r
fill:Color.BLUE stroke:Color.WHITE
strokeWidth:3
}
Circle {
centerX:2*r centerY:(h / 2) radius:r
fill:Color.BLUE stroke:Color.WHITE






