Image Map Empty

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
joelwyland
Posts: 15
Joined: Wed Jun 02, 2004 10:26 pm

Image Map Empty

Post by joelwyland » Fri Jun 25, 2004 6:18 pm

I'm trying to generate an Image Map for an XYPlot. I've looked through ImageMapDemo3.java in the src distribution and I believe I'm doing it right, but my map file is still empty:

Code: Select all

<MAP NAME="chart">
</MAP>
Here is what essentially I'm doing in my chart generator (I had to change the names and stuff for NDA reasons):

Code: Select all

MyCustomXYItemRenderer r = new MyCustomXYItemRenderer();
r.setToolTipGenerator(new MyCustomToolTipGenerator());
r.setLabelGenerator(new MyCustomXYLabelGenerator());
r.setURLGenerator(new StandardXYURLGenerator("prefix"));
chart.getXYPlot().getRenderer(r);
In my servlet, I'm writing the chart out as a PNG and then writing the map out as a text file. Any thoughts?

Kenny

nova
Posts: 17
Joined: Tue Jun 08, 2004 8:02 am

Re: Image Map Empty

Post by nova » Mon Jun 28, 2004 1:51 pm

Your ToolTipGenerator is empty... try something like this:
simpleDateFormat_sdf is a formatted date i from a table (source maybe SQL DB etc...)

Code: Select all

StandardXYToolTipGenerator sXYTTG_ttg = new StandardXYToolTipGenerator(StandardXYToolTipGenerator.DEFAULT_TOOL_TIP_FORMAT, simpleDateFormat_sdf, NumberFormat.getInstance());
TimeSeriesURLGenerator urlg = new TimeSeriesURLGenerator(simpleDateFormat_sdf, "details.jsp", "value1", "value2");

Guest

Post by Guest » Mon Jun 28, 2004 3:28 pm

Are you sure? I've used this code to generate a chart in a Swing app before and I go ToolTips to show up there. I will definitely double check to make sure the tool tips are working, but I really think they are and I'm not sure why they would affect the links.

Thanks for the reply

nova
Posts: 17
Joined: Tue Jun 08, 2004 8:02 am

Post by nova » Mon Jun 28, 2004 4:18 pm

no the links was a little bit too much code, they have no effect on the tooltips...
if I create an empty ttg I get empty tooltips, maybe depending on the graph used you can use an empty constructor I'm not sure, but in my case it was exactly like your problem...

richard_atkinson
Posts: 115
Joined: Fri Mar 14, 2003 3:13 pm
Location: London, England
Contact:

Empty Image Map

Post by richard_atkinson » Mon Jun 28, 2004 7:12 pm

Here is a critical section from ImageMapDemo3 that you may have missed.

Code: Select all

            final ChartRenderingInfo info = new ChartRenderingInfo(new StandardEntityCollection());
            final File file1 = new File("xychart100.png");
            ChartUtilities.saveChartAsPNG(file1, chart, 600, 400, info);
Unless you pass ChartRenderingInfo object in when rendering your chart the ToolTip/URL will not be collected, which will result in an empty image map. Hope this helps.

Regards,
Richard...

joelwyland
Posts: 15
Joined: Wed Jun 02, 2004 10:26 pm

Re: Empty Image Map

Post by joelwyland » Mon Jun 28, 2004 9:30 pm

richard_atkinson wrote:Here is a critical section from ImageMapDemo3 that you may have missed.

Code: Select all

            final ChartRenderingInfo info = new ChartRenderingInfo(new StandardEntityCollection());
            final File file1 = new File("xychart100.png");
            ChartUtilities.saveChartAsPNG(file1, chart, 600, 400, info);
Unless you pass ChartRenderingInfo object in when rendering your chart the ToolTip/URL will not be collected, which will result in an empty image map. Hope this helps.

Regards,
Richard...
Thanks Richard, that seems to have done the trick, thank you for catching my error. So, my question is.. ist he ChartRenderingInfo something that is doing work for the rendering or is it just a data structure that is collecting that rendered info along the way? I saw that there were functions with exactly the same signature (except that it didn't require a ChartRenderingInfo object) and used those.

richard_atkinson
Posts: 115
Joined: Fri Mar 14, 2003 3:13 pm
Location: London, England
Contact:

ChartRenderingInfo

Post by richard_atkinson » Mon Jun 28, 2004 9:43 pm

Passing the ChartRenderingInfo object basically tells the Renderer to collect information relating to ToolTips and URLs. Collecting the tooltip and URL information is pretty memory / processor intensive, so if you do not need them using the shorter method signatures speeds up the rendering quite significantly.

Regards,
Richard...

Locked