Lots of wonderful things are happening for Java desktop apps. Enter the new SceneGraph API for Java. What is a SceneGraph? Java2D is an immediate mode API, which means that your code is executed when the screen must be refreshed/painted, and your code draws to the screen immediately. SceneGraph in contrast is a retained mode API, which means that you declare what you want to happen and when. But the API figures out the caching, dealing with repaints, clipping, and lots of other low level details that you normally have to deal with – which makes it easier to use!
This initial release is in it’s very early stages, and there are lots of powerful and useful features planned for the future. Check out this presentation for more details. The good news with this API is that it’s not only JavaFX compatible, but you can use it with your Swing apps right now. You can make it easier to write Swing apps that use animations, and transparency, and all kinds of other cool effects, without having to spend inordinate amounts of time writing low level code to make it happen. Using a declarative model make it so much easier! This API is not complete though. Currently there’s support for composites that let you change the transparency, and you can do animations to move components (leveraging the TimingFramework), scale and rotate components. You can also apply composite filters. Currently there’s support for just a few things – Image, Shape, Text, and Component (Swing). In the future, there are plans to support:
Download and demo
This is how simple it is to use this API, you can create a SceneGraph group and add it to the SGPanel class, which is a Swing panel:
Then you can add nodes to the SGPanel’s root node, eg, a simple text node with some attributes:
Once your node is created, you can apply filters to it, and even define animation clips for it, all declaratively! Eg:
Once you’ve written the declarative code, you don’t have to do anything to render it, since it already knows how to draw itself!
The power and utility of this approach will become apparent when more SG components are available (3D components, HTML content, video, etc). By the way, this API can not only be accessed from Java as well as JavaFX, but also from scripting languages like Groovy, Python, Ruby, and any other language that can run in the Java VM.
|« Microsoft Sync Vehicle Telematics||Happy Christmas, Chanukah, Eid, Kwanza, Festivus! »|