Building an animated application

Let's combine several animations in a small application that shows how Earth rotates around the Sun (very roughly):

The first transition which we'll need is a PathTransition for Earth's orbit:

// chapter5/app/PlanetDemo.java// preparing space, Sun and Earth    Pane root = new Pane();Scene scene = new Scene(root, 300, 300, Color.BLACK);Circle sun = new Circle(150,150, 40, Color.YELLOW);Circle earth = new Circle(25, Color.BLUE);// orbit and path transitionEllipse orbit = new Ellipse(150, 150, 125, 50);PathTransition pt = new PathTransition(Duration.seconds(5), orbit, earth);pt.setInterpolator(Interpolator.LINEAR); ...

Get Mastering JavaFX 10 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.