Transformations
JavaFX API supports basic transformations for every Node
(and Shape,
which extends Node
).
Three basic transformations can be used through Node
methods:
setRotate
(double angle): Rotates around the center of theNode
setTranslateX
(double pixels),setTranslateY
(double pixels): Shifts theNode
by a set amount of pixelssetScaleX
(double scale),setScaleY
(double scale): Increases (or decreases) theNode
by multiplying its horizontal or vertical dimensions by scale
For more complex transformations, the Transform
class can be used. It allows us to work precisely with every parameter of the transformation. For example, you can concatenate two transformations into one combined and use two different nodes to save.
Note that through Transform
, there are usually more options available. For example, the setRotate()
method always uses the center of the shape as a pivot point, whereas for the rotate transformation you can set a deliberate pivot point inside the shape:
Rotate rotateTransform...