Insertion of a clickable image ... ???

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
swperman
Posts: 4
Joined: Mon Aug 13, 2007 9:09 pm

Insertion of a clickable image ... ???

Post by swperman » Mon Aug 13, 2007 9:15 pm

I've never used JFreeChart before, it looks quite interesting and useful. I was using another plotting library and I decided to switch because it didn't meet my needs. I would like to know if it is possible to insert a clickable image with JFreeChart, from a PNG, JPG or GIF file, into the plot, relative to the graph's coordinate system. My idea is to mark and represent a specific behaviour of the graph, so the image (a small icon) would go under the x axis, between the axis itself and the numbers in the scale (the plot is a line graph). When the user clicks it, a small dialog (window) shows up with some info about that part of the graph. Anyone knows if it is possible, and more or less how?

RichardWest
Posts: 844
Joined: Fri Oct 13, 2006 9:29 pm
Location: Sunnyvale, CA

Re: Insertion of a clickable image ... ???

Post by RichardWest » Mon Aug 13, 2007 9:42 pm

swperman wrote:I would like to know if it is possible to insert a clickable image with JFreeChart, from a PNG, JPG or GIF file, into the plot, relative to the graph's coordinate system. My idea is to mark and represent a specific behaviour of the graph, so the image (a small icon) would go under the x axis, between the axis itself and the numbers in the scale (the plot is a line graph). When the user clicks it, a small dialog (window) shows up with some info about that part of the graph. Anyone knows if it is possible, and more or less how?
Depending upon how flexible you want to be and how much work you wish to invest, you can achieve various levels of your end goal. Creating the icon and adding it to the plot is quite simple if you use a XYImageAnnotation. For a first pass, simply add the annotation at y=0. This would place it on the axis instead of below it, but it is easier than modifying the axis rendering. The annotation also allows you to add tooltips and urls.

Making the annotation open a dialog box requires more investment. You will need to modify how the plot handles mouse events. I would suggest looking over the source code before attempting this.
Richard West
Design Engineer II
Advanced Micro Devices
Sunnyvale, CA

Locked