Gfx doodles - No Fluff Just Stuff

Gfx doodles

Posted by: Andres Almiray on February 11, 2008

Joshy recently posted a JavaFX example dubbed JavaFX Doodles: Doodle #1, though I would like to avoid a direct comparison between JavaFX and GraphicsBuilder/SwingBuilder it is a topic that arises repeatedly. So here is my take on the first of Joshy's doodles in the interest of pointing out the similarities and differences between the two approaches, without further ado I give you: Groodles



Here is the script with GraphicsBuilder 0.4.5

The interesting bits happen from line 18 through 37, the code resembles the JavaFX a lot until you define the animation and the mouse trigger. Though both examples have the same behavior there is a slight difference on how the animations are defined and triggered. JavaFX uses the dur keyword along with the linear parameter to define an animation on an attribute (red) which happens to be bound. GraphicsBuilder on the other hand defines the animation once per cell using the animate() but has the problem of exposing the internals of animations in order to trigger said animations. In GraphicsBuilder, animations are defined by a set of bindings, if the animation does not start by default the bindings are not bound per se. You'll have to check if the animation is bound the first time and call bind() to trigger it, then call for subsequent triggers. But who will remember that right? animations should have start, stop, pause constructs that should take care of the internals workings and bound state for you.

This example shows that JavaFX has a more compact way of defining quick animations, and now that dur will be taking a step back to give way to keyframe and timeline based animations GraphicsBuilder will have to step up.

Another minor inconvenience that starts to bother me is having to register each of GraphicsBuilder's extensions (even though the script code is autogenerated by graphicsPad), GraphicsRenderer already takes care of that for you, I guess there should be a shortcut for GraphicsBuilder too. Rest assured that the next version will solve these problems.

Keep on Groovying!
Andres Almiray

About Andres Almiray

Andres is a Java/Groovy developer and a Java Champion with more than 20 years of experience in software design and development. He has been involved in web and desktop application development since the early days of Java. Andres is a true believer in open source and has participated on popular projects like Groovy, Griffon, and DbUnit, as well as starting his own projects (Json-lib, EZMorph, GraphicsBuilder, JideBuilder). Founding member of the Griffon framework and Hackergarten community event. https://ch.linkedin.com/in/aalmiray

Why Attend the NFJS Tour?

  • » Cutting-Edge Technologies
  • » Agile Practices
  • » Peer Exchange

Current Topics:

  • Languages on the JVM: Scala, Groovy, Clojure
  • Enterprise Java
  • Core Java, Java 8
  • Agility
  • Testing: Geb, Spock, Easyb
  • REST
  • NoSQL: MongoDB, Cassandra
  • Hadoop
  • Spring 4
  • Cloud
  • Automation Tools: Gradle, Git, Jenkins, Sonar
  • HTML5, CSS3, AngularJS, jQuery, Usability
  • Mobile Apps - iPhone and Android
  • More...
Learn More »