Concatenating transforms to scale positions but not objects (the original question)

Mark Raynsford org.openjdk at
Sat Aug 17 11:53:18 UTC 2019

On 2019-08-15T12:17:06 -0400
Scott Palmer <swpalmer at> wrote:

> "It's almost as if the code responsible for doing the layout is not taking the transforms into account ..."
> See the bottom of this:
> <>
> “Visual Bounds vs. Layout Bounds”

Thanks! I was aware that visual bounds didn't necessarily equal layout
bounds, but I didn't make the connection here.

My thinking is that I need to, for the "internal" pane, determine the
bounds of the external pane in the coordinate system of the component
that contains the outermost group that applies the transform.

In other words, given a hierarchy like this:

  Pane [x]
    + Group [transform]
      + Pane [externalA]
        + Pane [internalA]
          + Button
      + Pane [externalB]
        + Pane [internalB]
          + Button
      + Pane [externalC]
        + Pane [internalC]
          + Button

The "transform" group applies my translation and scale so that, given
a set of bounds in the composition coordinate space, the bounds and
position are transformed to JavaFX scene pixels. A listener is added
to the external panes (externalA, externalB, etc) that sets the
preferred size of the internal panes (internalA, internalB, etc) to the
size of the external panes but in scene pixels. In other words:

objectExternalPane.layoutBoundsProperty().addListener((observable, oldValue, newValue) -> {
  final var sceneBounds = objectExternalPane.localToScene(newValue);
  objectInternalPane.setPrefSize(sceneBounds.getWidth(), sceneBounds.getHeight());

This appears to work correctly, although I'm not sure that
localToScene() is actually what I want. What I want is "what size would
this be in the coordinate space of x", not "what size would this be in
the coordinate space of the scene". In this case, both x and the scene
are using equivalent coordinate spaces, but I imagine this isn't
guaranteed to be the case.

Mark Raynsford |

More information about the openjfx-discuss mailing list