JavaFX: Bounds by example

There are several misunderstandings related to bounds. (Amy Fowler tried to explain the layout mechanisms some days ago)

There are three bounds that can be used:

  • layoutBounds – represent the *logical* bounds used to layout the node
  • boundsInLocal – represent the *real* bounds used to paint the node
  • boundsInParent – the boundsInLocal transformed to the coordinates of the parent.

And now there is simple stuff you should remember:

layoutBounds are used for layouting (only). They do not have anything to do with boundsInLocal. They are just a logical concept. Sometimes they are the same as the boundsInLocal. Sometimes they are smaller, sometimes larger.

Some examples

layoutBounds == boundsInLocal

This is the case for many very simple nodes. For example a rectangle without any effects like drop shadows.

layoutBounds < boundsInLocal

This is the case for nodes that have some type of effect – for example a drop shadow. That shadow must not be included into the layout. If the layout algorithm used the boundsInLocal (including the drop shadow) the nodes would look misaligned to the human eye.

Aligned using the layoutBounds:

layoutBounds used

Aligned using the boundsInLocal:

sample-unaligned

layoutBounds > boundsInLocal

This is the case if some parts of the node are (yet) invisible, but the human eye interpolates them:

PacMan with bounds

If those Pacman like circles are aligned using the boundsInLocal this will result in: Pacmans aligned with boundsInLocal

While the human eye expects the alignment to be more like that: Pacmans aligned by layoutBounds

Disclamier:

I know that this post does not contain many (if any) new informations. It is just a little bit shorter. And therefore might be helpful for somebody.


2 Responses to “JavaFX: Bounds by example”

  • jewelry trays Says:

    very nice article, i definitely enjoy this excellent website, continue on it

  • Meettyzoorevy Says:

    The scope of pharmacy practice contains a great deal more conventional roles this kind of as compounding and dispensing medicines, and it also contains a great deal more fashionable expert services linked to well-being care, this includes clinical providers, reviewing medications for security and efficacy, online pharmacy Pharmacists, consequently, are the gurus on drug remedy and are the primary well-being experts who optimize medicine use to deliver individuals with advantageous wellness results.

Leave a Reply