January 04, 2009

BlueSG: a basic 2D Java SceneGraph library

I've been spending some of my holiday time setting up a basic 2D scenegraph library for Java. It takes Java 2D graphics and adds a layer for easily setting up complex hierarchies of assets (bitmaps, text, etc.). Here is an example:

Sofar it supports arbitrary positioning and scaling of text, shapes, bitmaps and Swing components. The Swing components don't scale in the real sense; that is, only their bounds are scaled, not their contents (due to not knowing how to get that done correctly).

There exist some similar projects, but none seemed useful to me. There is, of course, Project Scene Graph (back-end of JavaFX), which I once tested at work for doing code visualisations. The conclusion then was that its performance was abominable for anything non-trivial due to the way it handled updates of the scene graph. More interesting is PulpCore, but this is targeted at applets. I tried hacking it into Java apps, but it was too much tied to browser contexts. Processing is another tool for setting up interesting visuals, but it doesn't provide something at the level of a scenegraph. It also uses its own programming language targeted towards graphics programming, which is nice but which could confront me with a language integration problem at a later time.

I, of course, have something in mind to use it for, but that idea is still in the design stage...

2 comments:

Sam Reid said...

Have you tried piccolo2d? Its webpage is http://www.piccolo2d.org/ and it is a lightweight, high performance, open source scenegraph. It also provides some features that you mentioned were missing in your implementation, such as scaling of embedded jcomponents.

Kris said...

Hi Sam,

Thanks for the reference! It seems that I have used an older version of Piccolo2D (when it was still simply Piccolo) for implementing some basic source code (Cobol) visualisations. I don't remember much of my impressions of it, except that it was the best library for ZUIs that I could find at that time.

As for my own implementation, if you check the next post on my blog you'll see that I have solved scaling of embedded JComponents (for the most part). That's as far as I got though. I do hope to get back to it sometime later in the year (and will check out Piccolo2D as an alternative).