I just finished integrating JFreeChart with Tapestry. Each time you integrate a library with Tapestry you are full of praise for the framework. This is something you can seldom say about other web frameworks.

I had two usages in mind.

As a return value from an event handler.

As a component which can be used to display JFreeChart and a corresponding imagemap

To display a chart only an instance of JFreeChart is not enough, you need to know the width and height of the image too. Also depending upon the type of image format you are going to use, additional information is required e.g. in case of JPEG format quality. So we create an abstract data model to hold the information at one place.

The ChartResultProcessor delegates the chart rendering to ChartWriter.

A component to display JFreeChart and a corresponding imagemap

As different parameters are required for displaying the chart in different image formats we create an abstract class. Any abstract component class muct be placed in ${application-package}.base. The AbstractChart is implemented as

There is one hack. The imagemap is generated by ChartRenderingInfo which can only be obtained after the chart has been created. So we have to create the chart twice, once during the rendering phase to obtain the map, and other during the action phase for rendering the chart. As the output is not required during the rendering phase, we use a DummyOutputStream.