1 Transformations Overview
This chapter introduces transformations supported in JavaFX.
All transformations are located in the javafx.scene.transform
package and are subclasses of the Transform
class.
Introducing Transformations
A transformation changes the place of a graphical object in a coordinate system according to certain parameters. The following types of transformations are supported in JavaFX:

Translation

Rotation

Scaling

Shearing
These transformations can be applied to either a standalone node or to groups of nodes. You can apply one transformation at a time or you can combine transformations and apply several transformations to one node.
The Transform
class implements the concepts of affine transformations. The Affine
class extends the Transform
class and acts as a superclass to all transformations. Affine transformations are based on euclidean algebra, and perform a linear mapping (through the use of matrixes) from initial coordinates to other coordinates while preserving the straightness and parallelism of lines. Affine transformations can be constructed using observableArrayLists rotations, translations, scales, and shears.
Note:
Usually, do not use the Affine
class directly, but instead, use the specific Translate, Scale, Rotate, or Shear transformations.
Transformations in JavaFX can be performed along three coordinates, thus enabling users to create threedimensional (3D) objects and effects. To manage the display of objects with depth in 3D graphics, JavaFX implements zbuffering. Zbuffering ensures that the perspective is the same in the virtual world as it is in the real one: a solid object in the foreground blocks the view of one behind it. Zbuffering can be enabled by using the setDepthTest
class. You can try to disable zbuffering (setDepthTest(DepthTest.DISABLE
)) in the sample application to see the effect of the zbuffer.
To simplify transformation usage, JavaFX implements transformation constructors with the xaxis and yaxis along with the x, y, and z axes. If you want to create a twodimensional (2D) effect, you can specify only the x and y coordinates. If you want to create a 3D effect, specify all three coordinates.
To be able to see 3D objects and transformation effects in JavaFX, users must enable the perspective camera.
Though knowing the underlying concepts can help you use JavaFX more effectively, you can start using transformations by studying the example provided with this document and trying different transformation parameters. For more information about particular classes, methods, or additional features, see the API documentation.
In this document, a Xylophone application is used as a sample to illustrate all the available transformations. You can download its source code by clicking the transformations.zip link.