JavaFX Path Transition
It allows the node to animate through a specified path over the specified duration. In JavaFX, the path is defined by instantiating the class javafx.scene.shape.Path.
The translation along this path is done by updating the x and y coordinate of the node at the regular intervals. The rotation can only be done in the case when the orientation is set to be OrientationType.ORTHOGONAL_TO_TANGENT.
In JavaFX, the class javafx.animation.PathTransition represents the path transition. We need to instantiate this class in order to create an appropriate path transition.
The properties of the class along with the setter methods are described in the following table.
||This property is an object type of the class Duration. This represents the lifespan of the transition.
||This is an object of the class Node. This represents the node onto which the transition will be applied.
||This is a object type property referenced by PathTransition.OrientationType. It represents the upright orientation of the node along the path.
||This is an object type property of the class Shape. It specified the shape through which the outline of the animated path undergoes.
There are three constructors in the class.
- public PathTransition() : Creates the instance of the Path Transition with the default parameters
- public PathTransition(Duration duration, Shape path) : Creates the instance of path transition with the specified duration and path
- public PathTransition(Duration duration, Shape path, Node node) : Creates the instance of the PathTransition with the specified duration, path and the node.
In the following example, we have created a polygon and applied the path transition on it which is simulating the path of a pendulum.