For a simple vector drawing app I am looking to implement a "Selection Box", that is a graphic representation of the layoutBounds of a Node.
Example:
example http://i61.tinypic.com/ou4p3t.png
Thanks to jewelsea and his BoundsExample, I have a good understanding now on how to get the data for the box. The part I am struggling with is actually drawing the box on the scene, in a way that correctly respects the transformations on the nodes.
Correctly in this case means the bounds logical size get scaled with a node, but the stroke of the selection box stays constant. Meaning a selection box scales with its corresponding node, but the stroke stays unscaled.
I can think of two general strategies to implement such a selection box.
As a property of my custom node The selection box could be an internal details of my custom node with its visibility bound to the nodes selected state. In that case I would need to find a way to have nodes IGNORE the parents transformations, if that is possible.
Drawing selection boxes on top of the scaled nodes on a transparent pane In that case I would bind the selection boxes to the layout bounds of the scaled nodes, after applying the transformations of a node to its bounds. This does not seem to happen in JFX (even for 'boundsInParent') as you can quickly test in the example by applying some scaling to 'group' in line ~122. Link to modified example with scaling.
Since I am fairly new to JFX I wanted to ask for advice. Hope you find this problem interesting :)
Best regards, Oliver.