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.




2 comments:

  1. I am very enjoyed for this site. i was looking for this information. i found it on your page its really amazing. I like that information. This is really awesome post. You are really fantastic. thanks
    Tress Surgeons

    ReplyDelete
  2. Your website is a nice source of curious info! Do you mind if I pingback some of your blog entries on my personal website?

    ReplyDelete