JavaFX Node Bounds: I don’t get it

I’m happy to admit it when I don’t get something. The situation with boundsInLocal, layoutBounds, and boundsInParent in JavaFX is one of these situations. I have read a number of articles discussing this topic, and whilst I understand the differences between the three values technically, I don’t think I’ve seen an article that tells me why I need all three values, and when I should choose one over the other.

So, please, can someone out there write a blog post and/or add a comment to this post to explain to me, and to others, why I need to care about these three different values. If you do write a separate blog post, please leave a comment here so that anyone who stumbles upon this blog post in 6 months time can follow through to any other discussions elsewhere.

Most importantly, keep it simple. I know, that’s more difficult than being complex and detailed, but for the sake of JavaFX clarity the world over, please keep it simple. We want to know, simply, why and when do I care about the three different values?

Thanks in advance!

7 thoughts on “JavaFX Node Bounds: I don’t get it”

  1. Jon,

    I may not get it either, but what I think I get is:

    I think the three values depends on the situation because nodes go through so much from transformations to translation its hard to position things in relation to one another. I guess on a scene graph you need finer grain properties.

    Here are the sites I always go back to:
    Baechul Kim

    Amy Fowler


    1. @Carl Dea: Those links are good references, but like I said, they are too technical. Also, Amy’s post is for JavaFX 1.0, and things have changed a bit in relation to the three node bounds variables since then. It is no longer a reliable source for JavaFX 1.2 onwards.

      What I really want to know, as a developer using JavaFX, is should I have a bad feeling about not knowing when I should use each of these?

      The problem is that if no one gives me a good, simple explanation, that I’ll have to go into ‘hack’ mode when I start needing to do bounds calculations – I’ll simply keep hacking at code until I get the right value. It’s uninformed, slow, and clearly not ideal.

      I’m playing devils advocate a little – I don’t think it’s necessary to know this stuff in too much detail, but regardless, I would like to see if someone can simplify this for me and others. I’m certain the confusion is fairly widespread.

      — Jonathan

      1. Jon,

        Agreed.. I too want a simpler and general user guidelines when to use them and why. Looking forward to Amy Fowler’s blog entry, and many others. You should still go back and ‘hack’ it helps the mind. 😉



  2. The main problem with all the explanations is that they forget to explain what coordinate spaces they are talking about; “they are relative to the rectangle’s coordinate space”… What in the world is that???

    I understand that you have an x,y,w,h and that these values are changed due to effects, etc, but they first need to layout the foundation before explaining how the house is build.

  3. Jonathan,

    I have two sections in “JavaFX in Action”, one of which specifically deals with why there are three sets of coordinates (the shape’s own, layoutX/Y and translateX/Y), and another explaining in simple terms what the bounds do.

    Send me an email, and I’ll mail you back the relevant snippets if you want.

Comments are closed.