Sunday, January 13, 2013

JavaFX Tree Visualization Part 2

In this blog post I'll post a follow up on my post about painting random generated trees.

My intention was first to improve the code a bit and use a more functional way to express the recursion, now I'm using case classes and more pattern matching to build up the tree. I think now it is far more understandable what is going on.



Moreover I've added logic for 'growing' the trees, albeit it doesn't look very natural how they grow ;-)

What I've discovered however is that by using timelines you can parallelize animations - if you look at the video you'll see that more than one tree grows without disturbing the others doing their thing. I don't know if it is the "correct" way to do stuff like this in JavaFX, but it seems to work.

Still I'm amazed how easy and intuitive it is to create such graphic stuff, and my processor doesn't seem to bother much that I'm painting thousands of Nodes in this little program.

Here is the source code, full source available as a standalone maven project.




No comments:

Post a Comment