JFreeChart and Orson

When programming charting applications in Java I have had some success with JFreeChart. In order to use it easily in NetBeans you can use it in combination with Orson from the same supplier.

So far so good, but where’s the drawback? Well there are version issues between these packages and also some restrictions in functionality. Here I outline the installation process for JFreeChart and Orson. I’ll cover the functionality in a later post. JCommon is also required here since it contains code used by both JFreeChart and Orson.

  1. Get JFreeChart, JCommon and Orson from http://www.jfree.org/. At the time of writing the latest versions are jfreechart-1.0.13, jcommon-1.0.16 and orson-0.5.0.
  2. Unpack these to locations of your choice. Here I’ll use…
    • <jfreechart> to mean the root of the corresponding unpacked zip file (this contains the folders: ant, checkstyle, docfiles and so on),
    • <jcommon> to mean the root of the corresponding unpacked zip file (containing the folders: ant, checkstyle, javadoc etc.); and
    • <orson> to mean the root of the corresponding unpacked zip file (containing the folders: ant, docs and images folders etc.)
  3. If you don’t have Ant you’ll need the following…
    • Get WinAnt from http://code.google.com/p/winant/. Here I’m working on Windows (latest version winant-install-v5.exe). Ant is likely to be installed already on a Linux system. Not sure about Macintosh, but I guess you can probably find it.
    • Install WinAnt. This installs the ANT_HOME environment variable for you and also modified your PATH. You (probably) need to restart the computer.
    • Make sure your JAVA_HOME environment variable points to the root of Java JDK not the bin directory.
  4. Copy <jfreechart>\lib\jfreechart-1.0.13.jar and <jfreechart>\lib\jcommon-1.0.16.jar to the <orson>\lib folder.
  5. Delete the copies of jfreechart-#.#.##.jar and jcommon-#.#.##.jar previously in the <orson>\lib folder.
  6. Open <orson>\ant\build.xml in a text editor. I use Notepad++.
  7. Change (line 11 in my version)
    <property name="jcommon.version" value="1.0.10" />
    <property name="jcommon.version" value="1.0.16" />
    or whichever version of the jcommon.jar you copied in step 4 above.
  8. Change (line 12 in my version)
    <property name="jfreechart.version" value="1.0.6" />
    <property name="jfreechart.version" value="1.0.13" />
    or whichever version of the jfreechart.jar you copied in step 4 above.
  9. Save this modified build.xml file.
  10. Using a Command Prompt navigate to the <orson>\ant folder and run ‘ant’ (without quotes) to rebuild the Orson-0.5.0.jar using the new JFreeChart and JCommon JARs.

Installing these packages in Netbeans…

  1. Add JFreeChart, JCommon and Orson to your Libraries section in NetBeans. Instructions for this are given in the JFreeChart installation PDF (currently jfreechart-1.0.13-install.pdf) in Appendix 2. Note that you can find the jfreechart-x.x.xx.jar and jcommon-x.x.xx.jar files in the <jfreechart>\lib folder. Also you can download the javadoc files from Sourceforge currently: jfreechart-1.0.13-javadocs.zip.
  2. From the Tools menu select Palette then Swing/AWT Components.
  3. Click ‘New Category’.
  4. Enter a name, for example ‘Orson’.
  5. Click ‘Add from Library…’
  6. Select Orson from the list of available libraries. Click Next.
  7. Select all the components you require (all?). Click Next.
  8. Select Orson from the palette category list and click Finish.

Now you have the JFreeChart charting components available through Netbeans where they can be added to JInternalFrame components just like any other Bean.