Plugins You can find out about all the publicly available Grails plugins.

J2D Plugin

  • Tags: rich client, ajax
  • Latest: 0.4.2
  • Last Updated: 23 March 2010
  • Grails version: 1.2.0 > *
  • Authors: null
0 vote
compile "org.grails.plugins:j2d:0.4.2"




You can install the plugin by typing:

grails install-plugin j2d

The plugin will be downloaded, the bulk of it mostly being the requires jars.

Requires JRE6 or newer to run



  • 23 March 2010: upgraded to GfxBuilder 0.2.4
  • 12 February 2010: upgraded to GfxBuilder 0.2.3 and Grails 1.2.0
  • 15 October 2009: upgraded to GfxBuilder 0.2.1
  • 9 July 2008: added SVG support, image caching
  • 4 June 2008: first release!


J2D plugin allows you to draw images on the fly with Java2D, using GfxBuilder under the covers . The first release supports regular image output (gif|png|svg). Please visit GfxBuilder's site to learn more about the nodes that can be used, several graphic examples are also available at and

The current version of the j2d plugin is 0.4, which was released on February 12th 2010.


The plugin works by adding a new method to all controller classes: renderImage. This method takes a Map and a Closure as parameters, the Map will specify optional properties and hints for image processing (like width, height and format), the Closure being the actual graphics instructions to be rendered. Here is a basic example that outputs two colored squares (one red, one blue) in png format (the default value)

class MyController {
  def graph = {
    renderImage(width: 100, height: 100) {
       rect(x: 0, y: 0, width: 100, height: 100, fill: 'red')
       // same graphic node but using property aliases
       rect(x: 20, y: 20, w: 60, h: 60, f: color('#00F'))


The following is a list of currently supported parameters in renderImage

widthintthe width of the image (default=1)
heightintthe height of the image (default=1)
typeStringthe output format [png,gif,svg] (default=png)
nameStringthe name of the file where the image will be saved
ttlinttime-to-live how long will the cached image will be stored (in milliseconds)