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

Request for interoperatiblity between retained and immediate rendering modes

    Details

      Description

      Scenegraph nodes that can include methods created with Java2D for immediate rendering would be very beneficial. These dual mode nodes would allow for a combination of retained and immediate rendering, using whichever mode is most suitable for the objective of the node, as well as helping to reduce the memory footprint of having many nodes in a scenegraph when building a complex scene like a musical score. Using Java2D it is possible to create nodes that can not be achieved otherwise, examples of fire and plasma nodes are provided below.

      For my application which features full scores of music notation symbols Java2D also provides what standard nodes can not do. For instance, a music symbol such as a chord has notes which each have associated parts including a stem, accidental, dots and expression marks, etc. All these associated symbol parts have variations as well and using Java2D to draw a font glyph for the notehead and accidental and methods like drawline to draw the stem and so on is the most lightweight, practical and efficient solution. On the contrary using a separate node for each composite part of a music symbol is more involved, unnecessarily memory extensive plus the immediate mode of Java2D with its exposed paint method is simply the right tool to use for rendering complex composite graphics such as music symbols dynamically.

      At this time there exists a prototype solution to this issue but the immediate mode rendering is done outside of nodes altogether. The solution (which now works in the JavaFX common profile) is called the Painter's Canvas and it defines Java Painter objects which have an exposed paint method and do the Java2D rendering of any complexity. Once rendered the product of a Painter is converted to a image and inserted into a JavaFX node. The node then can be translated to the desired position in the scene and further provides hit detection facilities and effects that can be applied to the node.

      The node then encloses the complete music symbol and the composite parts of the symbol are provided by Painters and/or other JavaFX nodes as is required. The Painter/s providing rendered images to the node have a paint method that can then be called by the developers code to dynamically reset the parts of a symbol when required and the scenegraphs internal paint method is called automatically by the JavaFX runtime cycle.

      There has been recent and also ongoing discussion about this issue for sometime. The following links provide more detail, first recent activity on the Oracle Mix Forum where I opened up in a progressive dialog on the issue ending with a description of the present workaround solution, followed by links to the Painter's Canvas solution which show its evolution over several generations:

      https://mix.oracle.com/ideas/131892-what-sort-of-framework-classes-would-you-like-to-see-in-javafx
      http://www.javaworld.com/community/node/2754
      http://javajeff.mb.ca/cgi-bin/mp.cgi?/java/javafx/articles/ppc

      Before JavaFX I was using the Piccolo scenegraph, which supported creating nodes in several ways including creating nodes with the full power of Java2D. Examples of how nodes can be created in Piccolo can be found at the following link:

      http://www.javadocexamples.com/java_source/edu/umd/cs/piccolo/examples/NodeExample.java.html

      The way in which I'd like to use JavaFX nodes together with immediate Java2D rendering (in order to produce performant and superb music notation and an exceptional user experience) is like this. Have a cache of Painter objects, each is factory responsible for producing specific music symbol parts. Have a cache of symbol nodes (a standard UI virtualization scheme for JavaFX nodes used in a scene is also needed), each is reusable to show only the music from my data model that is currently on screen. Then when music data needs to be represented on the scene I feed data to the right Painter and have it render the correct image/s. These images are then assigned to a symbol node and the symbol node is then translated to where it should be in the scene.

      Without such a system of Painter and node caches performance will be poor and memory usage will be extensive when rendering a full musical score. It would be like talking a walk and for each step (node used) the next step will be twice as heavy. The accumulative result is that you (the scene) will sink into the ground before you ever get to where you are going!

      While JavaFX has simpler nodes that designers can also use there is still a need for complex lightweight rendering within JavaFX. My company Superstring Media (we are JavaFX Partners) has recently been funded by investors who are investing in order to develop my innovative interactive music composition application. JavaFX is my recommendation for the graphic and RIA aspects of our production. We along with JavaFX can achieve a mutual success however, the issue I have described here needs to be resolved properly in order to make success happen.

        Attachments

          Activity

            People

            • Assignee:
              kcr Kevin Rushforth
              Reporter:
              duke J. Duke (Inactive)
            • Votes:
              1 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Imported: