I am new to JavaFX
, sorry if this question has been answered before. But to the best of my knowlage it has not :)
I am making a grid based simulation of a swarm intelligence system. For each time tick i am storing the current state of the simulation, and calculating the next one. The simulation can potentially take quite some time to finish.
I want to be able to display the current state of the simulation, as it occurs, using JavaFX
. I would also like to do a "playback" of the entire simulation after it is complete.
Now as i have understood it large portions of work should be done in a Task
as to not freeze up the JavaFX Application thread
. But i am not able to see how i can achieve the desired functionality using the updateValue()
and the return statement of the call()
function in Task
.
In addition i would like to throttle both the "live" display of the simulation and the playback, as to display each tick in a suitable speed.
What I imagen would work is to have some kind of observable result queue that the background Task
could populate with states, and the JavaFX Application thread
could pop states of and display as needed. But this i don't know how to do.
Thanks in advance :)