use of javafx.scene.SnapshotParameters in project jgnash by ccavanaugh.
the class ChartUtilities method takeSnapshot.
private static WritableImage takeSnapshot(final Pane pane) {
Map<Chart, Boolean> animationMap = new HashMap<>();
// Need to disable chart animations for printing
pane.getChildren().stream().filter(node -> node instanceof Chart).forEach(node -> {
animationMap.put((Chart) node, ((Chart) node).getAnimated());
((Chart) node).setAnimated(false);
});
final SnapshotParameters snapshotParameters = new SnapshotParameters();
snapshotParameters.setTransform(new Scale(SNAPSHOT_SCALE_FACTOR, SNAPSHOT_SCALE_FACTOR));
final WritableImage image = pane.snapshot(snapshotParameters, null);
// Restore animation
for (Map.Entry<Chart, Boolean> entry : animationMap.entrySet()) {
entry.getKey().setAnimated(entry.getValue());
}
return image;
}
Aggregations