The Source for Java Technology Collaboration
User: Password:



Joshua Marinacci

Joshua Marinacci's Blog

Our new Java Scene Graph is open sourced

Posted by joshy on December 11, 2007 at 11:18 AM | Comments (23)

Today Sun announced the open sourcing (GPL) of the new Java scene graph that underlies JavaFX script. And I'm very, very excited about it.

What is a Scene Graph?

First, you may be wondering: What is a scene graph? It's a retained mode API. This means that you pass shapes and other graphics objects to the library and let it draw them on screen whenever a refresh happens. The API retains the graphics objects. This is different than Java2D which is an immediate mode API. This means that your code is called whenever the screen must be refreshed and you must invoke graphics drawing operations which draw to the screen immediately.

So why is one better than the other? Well, a scene graph saves you the headache of caching, dealing with repaints, worrying about clipping rectangles, and many other annoying details of writing graphics code. It lets you focus on what your code should do, not how it does it. This makes writing graphically rich applications much easier. The scene graph also has built in support for filters like blurs, glows, and shadows. And it works seamlessly with Swing components.

And finally, because so much of the graphics is abstracted away, the implementation can perform many interesting optimizations in the future, like preloading textures and primitives up to the graphics card. In short, it's a higher level of abstraction, just like going from assembly to C. You can still get down to the assembly level when you need to, but most of time you work at the higher levels.

Why this is good?

First of all, Java has needed a scene graph for a while. There have been several open source ones but not of them were terribly fast, and none of the could take advantage of pipeline hooks for hardware acceleration. Project Scene Graph, on the other hand, is built by the guys who work on Java2D, and we have the potential for all sorts of great acceleration (think pixel shaders). Since this scene graph supports the new JavaFX runtime, and my job is writing tools for JavaFX, I'm happy that it will be as fast as possible. You don't have to use JavaFX Script, though.

Second, I'm very excited that we are open sourcing this code right from the start. It hasn't been included in a shipping version of Java yet, but instead of waiting (sometimes for years) we are open sourcing it before it ships. This is huge, and another example of Sun (my employer) doing open source right. (A fact that I'm thrilled about, as you can imagine).

Third, this is a Java API. While it's initial purpose was to support JavaFX Script you can (and I have) code directly in Java. This means the API is useful not only from JavaFX and Java applications, but also from Groovy, Python, Ruby, and any other JVM based language.

Zeroth of all, scene graphs are awesome. I've been wanting one for ages. They are a great way to build up interactive graphics. They let you focus on what your app does and let the API do the heavy lifting. I've been playing with it for a while and I'm positive we are going to see some really cool apps coming out of this. In fact, I've got a few cool demos up my sleeve which you'll see soon.

So go to scenegraph.dev.java.net and check it out. Also read the PDF presentation from JavaPolis,

BTW, this announcement has nothing to do with the secret I told you about last week. You've still got to wait a few more days for that.


Bookmark blog post: del.icio.us del.icio.us Digg Digg DZone DZone Furl Furl Reddit Reddit
Comments
Comments are listed in date ascending order (oldest first) | Post Comment

  • Very nice library! I see it is released with the GPL. With classpath exception?

    Kees.

    Posted by: keeskuip on December 11, 2007 at 11:36 AM

  • Excellent! Did you work with the community experts to outline the API?

    Posted by: mikaelgrev on December 11, 2007 at 12:44 PM

  • The API was guided by the existing Jazz and Piccolo open source apis. We have open sourced the code base and API early so that we can get more feedback from community experts. We expect the API to change as we get more community feedback and real-world application experience. So dig in!

    Posted by: joshy on December 11, 2007 at 12:56 PM

  • Hi Josh, why is the package name com.sun.scenario rather than some org.jdesktop.scenario or some such? I am guessing though, this package naming would still undergo some changes in the future as the library gets further developed, and integrated.

    Posted by: mikeazzi on December 11, 2007 at 01:39 PM

  • mikeazzi yes. I think the packages will change over time, as will the api.

    Posted by: joshy on December 11, 2007 at 01:49 PM

  • I couldn't find any licensing information on the sight. From "GPL", I assume I can't use it in any commercial project?

    Posted by: samkass on December 11, 2007 at 02:20 PM

  • Are any of the demos available (as identified in the JavaPolis presentation slides)? I'm particularly interested in the animation one. The slides were somewhat thin on content (you probably talked a lot). Next time maybe record an MP3 as well? How would you rate the applicability of JSG to more dedidcated graphics/animation usage, for example games or visualization? Or is is much more GUI-focused? Thanks!

    Posted by: gerryg on December 11, 2007 at 03:56 PM

  • I think I may have confused people. I was not on stage at JavaPolis. I'm home in Oregon watching on the sidelines just like the rest of you. I wanted to blog about it to let non-attendees get involved. I believe that Chet Haas presented the demos. I recommend posting to the scene graph mailing list to ask for the demos.

    Posted by: joshy on December 11, 2007 at 05:09 PM

  • Oh, and I would say that the scene graph is definitely good for games and visualization. In fact, if what you need is just a plain GUI (like a forms app) then you are much better off using straight Swing with the GUI builder in NetBeans 6.

    Posted by: joshy on December 11, 2007 at 05:10 PM

  • update: the code is currently released under GPL v2 without a classpath exception.

    Posted by: joshy on December 11, 2007 at 05:15 PM

  • Josh, I have one question for you: Painters. Can painters take advantage of this nice library? Might we one day then see this emerging as the preferred way of developing such painters suites for swing components? Or even maybe entire LnF?

    Posted by: mikeazzi on December 11, 2007 at 07:18 PM

  • Yep, Chet presented the demos and they were pretty cool. Now, licensing issues apart (I believe the lack of the CPE is temporary), we're going to have a pretty interesting bunch of libraries (SwingLabs, TimingFramework, AnimationFramework, SceneGraph) that we need to understand better in their relationships (and I'm also thinking of NetBeans RCP). And this morning I saw a pretty neat demo with JavaFX by Angela Caicedo. Will be an interesting 2008, but with some points to address.

    Posted by: fabriziogiudici on December 12, 2007 at 03:13 AM

  • Scene Graph is great api, I can imagine how easy things will be.

    The only other thing we need is visual designer for generating complex Scene Graph's. Developing complex UI's and Animations without visual editor is not an easy task,(no matter how flexible the API is).

    SUN must be making a Visual Editor for these things.
    But will it be opensourced project ?
    I am thinking of making a Timelined Animation editor. If SUN already doing that I dont want to spend time on it.


    Even better if there is also a SVG-to-Scene Graph code generator :)

    Kishore

    Posted by: kishoresjava on December 12, 2007 at 04:09 AM

  • I am thinking of making a Timelined Animation editor.

    I was thinking the exact same thing. Sort of like a Java based (Macromedia/Adobe) Director clone.

    SVG-to-Scene Graph code generator

    Well there is SVG-to-Java2D and SVG-to-JavaFX converters. All thats left is to convert any animation information in SVG to the scene graph API. Does SVG support animation or is that just a flash thing?

    Posted by: aberrant on December 12, 2007 at 05:50 AM

  • +1 for the latest two posts. I'd be fine with a new product, but I think that for marketing reasons it would be better something that integrates with Macromedia products. After all the graphic people belong to that world and I don't think you'd make easily their mind about a tool switch.

    Posted by: fabriziogiudici on December 12, 2007 at 07:50 AM

  • SVG-to-Java2D is not complete. but it works , still some font support is needed .I tried my hand, but not able to complete it.

    I have used this SVG-to-Java2D code converter in my applet.
    http://www.gyanlabs.com/java/java.html

    some kind of editor we anyway want it, for JavaFx or Scene graph.

    And about Animation support in SVG : SVG supports javascript based animations. but that is limited.i believe not for complex animations.

    Posted by: kishoresjava on December 12, 2007 at 12:00 PM

  • The project http://graph.netbeans.org/ also has an scenegraph which is also created by a sun employee "David Kaspar". (I must say he is a fantastic projectleader)

    It also has animations. It also is a ZUI (Although it doesn't scale swing components the way Jazz did). It has Layoutmechanisme's!

    As both projects originated from sun why didn't you join forces? There is a LOT of overlap.

    Posted by: keeskuip on December 12, 2007 at 12:29 PM

  • Excuse my ignorance since I don't do anything 3D, but isn't Java3D scene graph as well? Why did we need another one?

    I'm a neophyte so please go easy on me if this is a dumb question.

    Posted by: mas7871 on December 12, 2007 at 01:12 PM

  • Whats so great about this JavaFX stuff? The code looks like your worst nighmare. Looks like Linux kiddie code.
    I don't hope JavaFX will kill Swing, else I turn my back on Java on the desktop.
    Please do something about the syntax.

    Posted by: carmello on December 12, 2007 at 01:28 PM

  • Secret Revealed?

    Posted by: nicolaken on December 12, 2007 at 01:49 PM

  • Easier access i believe ...

    Posted by: liquid on December 12, 2007 at 11:47 PM

  • >Excuse my ignorance since I don't do anything 3D, but isn't Java3D scene graph as well? Why did we need another one? ...

    ...because it is a 2D SceneGraph for Java2D (-> Swing). Java3D has a 3D SceneGraph. It does not make sense to use a 3D SceneGraph for 2D graphics because they are very different in implementation.

    Posted by: mbien on December 13, 2007 at 07:20 AM

  • as a longtime user of Jazz (and indirectly piccolo), i'd be interested in a concise summary of the benefits of this over Jazz.

    Is it faster? do you have perf figures?

    is it more complete? does it handle embedded swing widgets better? i'm looking for details.

    i know that Jazz hasn't been worked on for a while, but it still rocks. i want to know whether it's worth moving my (extensive) codebase over.

    Andrew

    Posted by: andrewmcveigh on December 14, 2007 at 02:33 AM



Only logged in users may post comments. Login Here.


Powered by
Movable Type 3.01D
 Feed java.net RSS Feeds