Java 2D and Groovy, A Perfect Match

Andres Almiray gave a presentation on Java 2D and Groovy at Silicon Valley Codecamp 2008. Andres started the session by highlighting some key benefits of Groovy’s language features. For example, in Groovy setters and getters are explicitly created for you by simply defining a property, semicolons are optional and the return keyword are optional. Parenthesis are optional in many cases. Groovy strings are sexier, known, as GString short for Groovy Strings, and provide string interpolation familiar to Rubyist and Perl programmers. Even return types are optional in many cases and to this Andres said, “the def keyword is like var keyword in JavaScript.” Another highlight of Groovy’s features are closures. Andres said, “We don’t know if we have closures in Java 7, Groovy has closures right now!” After highlighting Groovy language features we where reminded of Groovy’s mantra: Groovy is Java, Java is Groovy.

After introducing Groovy to the audience, Andres demoed GraphicsBuilder. GraphicsBuilder is to Java2D what SwingBuilder is to Swing. The builder pattern is commonly used with great effect in Groovy due to the languages dynamic and reflective nature. GraphicsBuilder can be used to draw basic shapes, those included in Java 2D which is not much, and many more shapes like stars, triangles, balloons, crosses, arrows, donuts, etc. GraphicsBuilder has import and export to SVG via Batik and has partial experimental export to Flash’s SWF format. Andres recreated JavaFX demos simply using Groovy and GraphicsBuilder.

Technorati Tags: , , , , , , , , ,

Related posts:

  1. Groovy On The JVM
  2. Groovy Closures
  3. Common Groovy Errors
  4. Gnarly Custom Groovy Closures
  5. COM Scripting With Groovy
  6. Embedding Groovy


Leave a Reply