Is it possible to do a screenshot ? #516
Replies: 2 comments 1 reply
-
This is probably due to the rendering not being completed at the time you request the screenshot. Because we potentially e.g. rescale the axes during rendering it can take multiple rendering passes to get to the right result. This is of course not optimal, but it is what we have now. For one of our internal projects, I have a small helper function, which recusively relayouts all chart components in a scene, which I run in a separate /**
* Force relayout of all child nodes in the "de.gsi" package to force e.g. axis range updates.
* @param root Root node of the scene for which to force relayouting of all child nodes
*/
private static void requestChildrenLayout(final Parent root) {
root.getChildrenUnmodifiable().forEach(n -> {
if (n instanceof Parent) {
if (n.getClass().getPackage().getName().startsWith("de.gsi")) {
((Parent) n).requestLayout();
}
requestChildrenLayout((Parent) n);
}
});
} This probably does more than it would have to, but it fixes a lot of issues for me. Clearly ChartFx is designed for interactive use, but probably the interactive usecase would also gain performance benefits from improving this in general, but this is nothing that can be fixed quickly, so at the moment we'll need to have some workarounds. Also your scene does not have to be added to a As you noticed correctly, the ScreenshotPlugin is mainly providing a UI for JavaFX's snapshot function, so for your use-case I would also prefer the latter. Out of couriosity and to better understand your usecase: What platform are you on? By headless, do you mean javafx's |
Beta Was this translation helpful? Give feedback.
-
Thank you for your answer @wirew0rm ! That's a solution to avoid the defined Here, I tried with a stage. For the moment I have a JavaFX application, but I want to run an application without any display which can generate a specific chart with some data I already have. |
Beta Was this translation helpful? Give feedback.
-
I'm trying, with the screenshot plugin, or just with the JavaFX snapshot function to get a screenshot of my chart, in "headless mode".
Everything is displaying, except the main line of the chart. I tried to display only a few seconds the chart (by doing a sleep() on the thread) and to capture during this time, it works, but that's not a good solution... Do you know how can I capture a screenshot of my chart properly ?
Beta Was this translation helpful? Give feedback.
All reactions