I have a use case where I need to draw a component consisting of around 100 lines and up to 1000 other elements (rectangles and text, mostly).
The content of the component should resize when the Parent node changes its size (e.g. when the application window changes its size).
I can think of two approaches how to deal with this:
- Use JavaFX Line, Text, Rectange etc. Nodes and bind the widths and heights to the parent Node.
- As in 1. but, instead of binding, develop a Pane which layouts the elements accordingly
- Use the Canvas node and draw everything like with Graphics2D in Swing.
Which approach would be faster? How large is the impact of using bindings to change the size of this number of Nodes?
Is it possible to ensure, using the Node+Binding approach, that the lines are crisp? AFAIK the lines need to be drawn subpixel to be crisp, so adding 0.5px to the position is necessary. But is it possible to do this conditionally in a Binding? I already tested adding 20 Lines to the Pane and Binding their y-position to the height of the Parent, but some are drawn crisp and some are blurry.
If creating a new container which layouts its children (like VBox and so on) is the best option, how complex would be the task?