Additional hint for controlling bitmap caching.
Under certain circumstances, such as animating nodes that are very expensive to render, it is desirable to be able to perform transformations on the node without having to regenerate the cached bitmap. An option in such cases is to perform the transforms on the cached bitmap itself.
This technique can provide a dramatic improvement to animation
performance, though may also result in a reduction in visual quality.
The cacheHint
variable provides a hint to the system about how
and when that trade-off (visual quality for animation performance) is
acceptable.
It is possible to enable the cacheHint only at times when your node is animating. In this way, expensive nodes can appear on screen with full visual quality, yet still animate smoothly.
Example:
expensiveNode.setCache(true);
expensiveNode.setCacheHint(CacheHint.QUALITY);
...
// Do an animation
expensiveNode.setCacheHint(CacheHint.SPEED);
new Timeline(
new KeyFrame(Duration.seconds(2),
new KeyValue(expensiveNode.scaleXProperty(), 2.0),
new KeyValue(expensiveNode.scaleYProperty(), 2.0),
new KeyValue(expensiveNode.rotateProperty(), 360),
new KeyValue(expensiveNode.cacheHintProperty(), CacheHint.QUALITY)
)
).play();
Note that cacheHint
is only a hint to the system. Depending on
the details of the node or the transform, this hint may be ignored.
If Node.cache
is false, cacheHint is ignored.
Caching may be disabled for any node that has a 3D transform on itself,
any of its ancestors, or any of its descendants.
CacheHint
for this Node
cacheProperty
@defaultValue CacheHint.DEFAULT
Diagram: Node