Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8098232

Make it possible to get correct Node.min/pref/maxWidth/Height() when not attached to Scene



      For printing there is a need to get the sizes of a Node so it can be laid out properly on the page. For instance if you are going to print one label after another or below some dynamic content.

      Since a Node that is to be printed isn't attached to a Scene this is impossible today, it only returns 0. There is a workaround to temporarily attach it to a Scene and .applyCSS() but that's not a good solution because:

      1) It can't be done in a background thread since it needs to be on the UI thread
      2) It won't work with normal layouts since they don't know this trick and just call .prefHeight/Width
      3) It is slow

      To be able to do decent printing, like printing reports, we need to be able to ask the Nodes for their different types of sizes. And this needs to work out of the box since the nice thing about having Node as the printing mechanism is that we can use the normal Pane-type layout and all support that gives. One could for instance do page templates in FXML and even use ScenBuilder to create them.

      If it is hard to do this in a completely transparent way for some architectural reason maybe one can attach it to something like PageLayoutScene or something before doing the layout.


          Issue Links



              • Assignee:
                msladecek Martin Sládeček
                mgrev Mikael Grev
              • Votes:
                1 Vote for this issue
                4 Start watching this issue


                • Created: