We have a set of scenes for which the intent is to - at a certain point after it is "safe" to do so - save them to image files. "Safe" here means "after some backend work done and also after the scenes are fully painted/rendered."
The single-threaded nature of the FxApplication thread needs to be taken into account : all gui related work needs to happen on the FxApplication thread. So then it is not clear to me how to do arbitrary gui-related operations that require access to the Graphics Context.
the
javafx.application.Platform.runLater(runnable)
is intended for short-lived operations. In fact that is how we launch the separate scenes: one scene for each invocation ofrunLater
. That works fine.the
Task
which is specifically intended for longer running operations. But how should the Task interoperate with the FxApplication thread? There does not seems to be any "queueing mechanism" for the Task to put work back into the FxApplication eventing loop.We should likely not attempt to perform GUI related ops from the Task - that would violate the FxApplication thread's responsibilities -and lead to race conditions.
Note the following question Platform.runLater and Task in JavaFX does not address this case because the GUI operation shown:
bar.setProgress(counter/1000000.0);
is a "builtin". We need to do arbitrary gui operations.
..
So an outline of how to properly sequence the work would be appreciated.