Belongs to following categories: Graphic, ULC6.0,
Purpose
Many business applications need to display charts. This contribution shows how the free chart library
JFreeChart can be integrated into ULC applications.
The integration is entirely done on the server side. This approach has the advantage that beside the standard ULC libraries and a small extension no additional libraries have to be deployed on the client. As a drawback, since the
JFreeChart library heavily relies on Java2D, the integration will not work for server configurations without headless support.
The contribution also shows how the chart can be printed. There are two options: displaying the chart inside an HTML page or creating a PDF document that contains the chart. The latter is achieved by using the free
iText library.
Difference between JFreeChart Extension I and IIIf your goal is to create simple charts without the possibility to change their appearance or to zoom in and out on charts in an interactive way, then this contribution suits you the best. If you want to get all interactive functionalities of JFreeChart (especially the mouse event handling and zooming), then the
JFreeChart Extension II is the more appropriate solution for you.
Related to
This contribution is related to
JFreeChart Extension II.
Resources
How to use
After starting the application, a window is displayed (
screenshot). The window contains the chart and a set of text fields and controls to customize the chart (such as chart type, title, etc). By right-clicking on the chart, a popup menu shows up with menu entries for creating new random chart data and for displaying the chart inside an HTML page or a PDF document.
Resizing the window automatically adjusts the chart size.
How it is implemented
The core of the contribution are the
ULCJFreeChartComponent and the
UIJFreeChartComponent. The
ULCJFreeChartComponent provides an API to set a JFreeChart chart and register an
IJFreeChartComponentListener to receive notifications when the chart size changes. The
ULCJFreeChartComponent converts the chart into a PNG image and sends it to the
UIJFreeChartComponent. The
UIJFreeChartComponent then displays the chart image. When the user resizes the component enclosing the chart image, the new size is sent to the
ULCJFreeChartComponent which then creates a new chart image of the appropriate size and sends it back to the client.
Compatibility
The described functionality has been developed and tested using JDK 1.3.1_09, JDK 1.4.2_01, ULC 6.0.2.1, iText 1.3, and JFreeChart 1.0.0.
Author
thomas