Scene Graph library announced at JavaPolis 2007
One of the many interesting talks I attended at the JavaPolis 2007 conference was the Swinging RIA talk. At the end of the talk Chet Haase announced the brand new Java Scene Graph library. Scene Graph gives you a new way to implement your visual output in Swing. It will replace the Jazz library that provides the Java2D stuff in the current JavaFX implementation. In the current release, the API is a little bit verbose but I expect this to change as the API is not final yet.

How does Scene Graph work? With Scene Graph, instead of subclassing a Swing component and providing your Java2D drawing instructions in a custom paint() method, you build up a data structure that declares your visual output, i.e old Java2D is the procedural approach to do graphics, whereas Scene Graph is the declarative approach.
How does this look in practice? In Scene Graph you amazingly build up a scene graph! Each scene graph is composed of nodes and each node represents a graphics operation, e.g.
- Painting a primitive
- Performing an effect
- Doing a transformation
- Playing an animation
So, for painting text, instead of
protected void paintComponent(Graphics g) {
super.paintComponent(g);
Graphics2D g2 = (Graphics2D) g.create();
g2.setFont(new Font("Arial", Font.BOLD, 128));
g2.setRenderingHint(KEY_TEXT_ANTIALIASING, VALUE_TEXT_ANTIALIAS_ON);
g2.drawString("Java2D", 50, 150);
g2.dispose();
}
you will have
SGText result = new SGText();
result.setText("Scene");
result.setFont(new Font("Arial", Font.BOLD, 128));
result.setAntialiasingHint(VALUE_TEXT_ANTIALIAS_ON);
result.setLocation(new Point(50, 180));
My impression is that a programmer familiar with Java2D is immediately productive with the Scene Graph library. Great! And as a bonus he gets good effect and animation support for free! Wow! I hope this is just a first step to:
- Powerful effect libraries
- Good animation libraries
- Visual scene graph tools
- Integrations into existing visual tools like PhotoShop
- …
Another thing that makes building good-looking Swing applications easy! Good!
