Sun 17 Aug 2008
A couple of days ago there was an announcement on this blog about jSilhouette's 0.1 release, followed by a comparison between the geom, scene and jfx demos (regular Java, Project SceneGraph and JavaFx Script each).
Things have changed a bit. Jacek Furmankiewicz brought to my attention that Project SceneGraph is licensed under GPLv2 (no classpath extension) which means both jsilhouette-scene and jsilhouette-jfx must use the same licensing scheme. But jsilhouette-geom does not, in fact it has been re-licensed to ASL 2.0, this means that starting with the next release commercial use of jsilhouette-geom is no longer a problem. The commercial usefulness of the remaining modules lies in Sun's will to re-license Project SceneGraph to GPLv2 with classpath extension.
Some other updates
![[image]](http://mowser.com/img?url=http%3A%2F%2Fwww.jroller.com%2Faalmiray%2Fresource%2Fjsilhouette-demo-groovy.png)
Nice Nimbus look &feel, you may be thinking that this is the new version of the jfx demo, but it is not! this is the Groovy version (ShapesDemoGroovy.groovy)
, the green color is darker in jfx, remember? let's revisit the stats, shall we?
The Groovy version beats the JavaFx Script version in almost all categories (the source file is even shorter than the Java2D version) but these numbers do not reflect how small the code can be in each version. For example I discovered that the jfx version has some commas (,) between attribute declaration (which bump the char and file size), I was surprisewd to find out JavaFx Script was happy with them as not even a slight warning is given by the compiler, nice!; the Groovy version harnesses the power of native syntax for Lists and Maps to reduce variable declaration; defaults values are not really used that much in all versions.
I also mentioned previously that making the second and third demo was quicker once the first one was done, in this case it was no different. The jfx version was copied almost verbatim, added some Groovy sugar here and there (even had to add a MetaClass hack due to how SwingBuilder handles look&feel in the 1.5.6 version (the new one is slicker
thank @shemnon for that)). Quick comparison between how the jfx and groovy versions initialize the frame, first the jfx one
Where each
Here I'd like to take the opportunity to mention that the function signature must have
Here is the Groovy version
Where
The Groovy version requires some 'plumbing'
Yup, hypothetical is more like it (my code that is, still have to learn more about JavaFx Script) but you get the idea. Back to jSilhouette, I'd like to have proper javadocs/javafxdocs in place before releasing the next version, so it will take a couple of days more.
Feedback is always appreciated.
graphics graphicsbuilder groovy java java2d javafx jfx jsilhouette
Things have changed a bit. Jacek Furmankiewicz brought to my attention that Project SceneGraph is licensed under GPLv2 (no classpath extension) which means both jsilhouette-scene and jsilhouette-jfx must use the same licensing scheme. But jsilhouette-geom does not, in fact it has been re-licensed to ASL 2.0, this means that starting with the next release commercial use of jsilhouette-geom is no longer a problem. The commercial usefulness of the remaining modules lies in Sun's will to re-license Project SceneGraph to GPLv2 with classpath extension.
Some other updates
Donut shape has been added to all modules. Donuts may be circular or polygonal. Default values have been added to some attributes in the jfx module, alleviating the pain of setting each attribute. Groovy demo (GraphicsBuilder based) available!
Here is an screenshot on the latest demo app![[image]](http://mowser.com/img?url=http%3A%2F%2Fwww.jroller.com%2Faalmiray%2Fresource%2Fjsilhouette-demo-groovy.png)
Nice Nimbus look &feel, you may be thinking that this is the new version of the jfx demo, but it is not! this is the Groovy version (ShapesDemoGroovy.groovy)
, the green color is darker in jfx, remember? let's revisit the stats, shall we? geom scene jfx groovy
LoC 369 505 619 369
Tokens 1486 1855 2644 2194
Source file size (bytes) 16412 21000 20626 15311
Compiled code size (bytes) 104K 60K 76K 92K
The Groovy version beats the JavaFx Script version in almost all categories (the source file is even shorter than the Java2D version) but these numbers do not reflect how small the code can be in each version. For example I discovered that the jfx version has some commas (,) between attribute declaration (which bump the char and file size), I was surprisewd to find out JavaFx Script was happy with them as not even a slight warning is given by the compiler, nice!; the Groovy version harnesses the power of native syntax for Lists and Maps to reduce variable declaration; defaults values are not really used that much in all versions.
I also mentioned previously that making the second and third demo was quicker once the first one was done, in this case it was no different. The jfx version was copied almost verbatim, added some Groovy sugar here and there (even had to add a MetaClass hack due to how SwingBuilder handles look&feel in the 1.5.6 version (the new one is slicker
thank @shemnon for that)). Quick comparison between how the jfx and groovy versions initialize the frame, first the jfx oneWhere each
draw* function is of the formHere I'd like to take the opportunity to mention that the function signature must have
Void as its return type otherwise a compilation error will be thrown. If the return type is not specified then it will be the same type of the last evaluated expression, in this case Node[], SwingButton expects its action function to return Void. I'm sure a tool (like NetBeans' jfx plugin) would have drawn a red underline/popped an error/whatever under the offending code before attempting a full compile on the code by myself, but I went with the "manual" way: Vim + command line compiler, so there, had to be more careful 
Here is the Groovy version
Where
shapes is a Map initialized likeThe Groovy version requires some 'plumbing'
Fix
The native syntax for Lists and Maps comes in our aid here. Iterating each entry (String,GraphicsOperation) it is a matter of hooking up the proper values on the button's text and action. Notice that each time a button is clicked a new GraphicsOperation is created (a group) that has a 'global' property applied to all its children (borderColor: 'black') and antialias is turned on. GraphicsPanel is smart enough to know when it should repaint itself (similar to JSGPanel and Canvas). Of course some would say you may iterate over a sequence in the jfx version in order to build the buttons in a loop, sure you can. You could also create a java.util.Map that holds each label and related function, but the code is not as concise as the Groovy one. Assuming hypothetical classes javafx.util.LinkedHashMap and javafx.util.MapEntrySwingBuilder.lookAndFeel to accept a List of L&F identifiers (available in Groovy 1.6.x). Set the preferred L&F. Tell the frame where it should be located by default (locationRelativeTo: null)Yup, hypothetical is more like it (my code that is, still have to learn more about JavaFx Script) but you get the idea. Back to jSilhouette, I'd like to have proper javadocs/javafxdocs in place before releasing the next version, so it will take a couple of days more.
Feedback is always appreciated.
graphics graphicsbuilder groovy java java2d javafx jfx jsilhouette
About me











![[image]](http://mowser.com/img?url=http%3A%2F%2Fjroller.com%2Fresources%2Fa%2Faalmiray%2Fimtd4.gif)
![[image]](http://mowser.com/img?url=http%3A%2F%2Fjroller.com%2Fresources%2Fa%2Faalmiray%2Frss_weblogs.gif)
![[image]](http://mowser.com/img?url=http%3A%2F%2Fwww.blogburst.com%2FResources%2FImages%2Fblogburst_80x15.gif%3Fid%3DB8FvOsgxNdOKCYKtvrW8bRD)
![[image]](http://mowser.com/img?url=http%3A%2F%2Fwww.javablogs.com%2Fimages%2Fjavablog-small.gif)
![[image]](http://mowser.com/img?url=http%3A%2F%2Fjroller.com%2Fresources%2Fa%2Faalmiray%2Fgroovyblogs_80x15.png)






![[image]](http://mowser.com/img?url=http%3A%2F%2Fjroller.com%2Faalmiray%2Fresource%2Fjsilhouette-demo-java.png)
![[image]](http://mowser.com/img?url=http%3A%2F%2Fjroller.com%2Faalmiray%2Fresource%2Fjsilhouette-demo-jfx.png)
![[image]](http://mowser.com/img?url=http%3A%2F%2Fwww.jroller.com%2Faalmiray%2Fresource%2Fgraphicsbuilder-substance-fractalFlame.png)
![[image]](http://mowser.com/img?url=http%3A%2F%2Fwww.jroller.com%2Faalmiray%2Fresource%2Fgraphicsbuilder-substance-shapes.png)
![[image]](http://mowser.com/img?url=http%3A%2F%2Fwww.jroller.com%2Faalmiray%2Fresource%2Fgr-swf-sample.png)
This extension has put into evidence some pain points in the API that may also help in making groovy2svg (might as well finish the other side too, right?). Right now it supports transforming basic shapes and color fills, more to come later.![[image]](http://mowser.com/img?url=http%3A%2F%2Fwww.jroller.com%2Faalmiray%2Fresource%2Fgroodle3.png)
![[image]](http://mowser.com/img?url=http%3A%2F%2Fwww.jroller.com%2Faalmiray%2Fresource%2Fgb-dragtest.png)