Skip to main content

scenario vs scenegraph and SG* vs FX*?

2 replies [Last post]
shahbazc
Offline
Joined: 2008-04-06
Points: 0

Hi,
In the scenario library, I'm not quite sure of the difference between *.scenegraph and *.scenegraph.fx packages. Each of them seem to share similar classes: SGNode, FXNode, etc.

According to this message: http://forums.java.net/jive/thread.jspa?threadID=39488, java developers should probably use the FX classes. However, the fx packages doesn't include lines, circles, rectangles (which are in the sg package)...and FXShape, java.awt.Shape, and SGCircle (and other primitives in sg package) are not in a linear hierarchy. FXShape seems to work with java.awt.Shape, but SGShape doesn't derive from java.awt's Line2D. The api looks a little confused.

Also, looks like SG based primitives, such as SGLine don't have constructors which take relevant arguments. It looks like I have to instantiate it, then use setter methods. Is there a reason for this?

The scenario library delivered with JavaFX 1.0 seems quite different from the one at https://scenegraph.dev.java.net. Since JavaFX is already at 1.0, doesn't it make sense to update scenegraph.dev...?

In fact, it looks like there is little reason for a developer to work with java.awt.* for java 2d related programs. JavaFX's java based infrastructure provides a cleaner starting point. Any plans to do a blog on doing java 2d, the new way?

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
steven_reynolds
Offline
Joined: 2004-11-09
Points: 0

FX* take the philosophy of wrapping a lot of functionality into a single class. These are easier for the end user to program with.

SG* take the philosophy of keeping the Single Responsibilty Principle (SRP). Each class or node does only a single thing. These are easier to extend, but more verbose for the end user to program with. The SG* and FX* play nice with each other, so you can mix and match.

If you want more background, you can look at my slides

http://www.int.com/presentations/scenegraph

I didn't work on the project so cannot comment on why other design choices were made...

shahbazc
Offline
Joined: 2008-04-06
Points: 0

Thanks, your slides are very interesting. I didn't like the comment about the scenegraph just being an implementation detail...but better to know the truth :)