ShadowGenerator and Tooltips

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Post Reply
matinh
Posts: 483
Joined: Fri Aug 11, 2006 10:08 am
Location: Austria

ShadowGenerator and Tooltips

Post by matinh » Mon Oct 10, 2011 5:08 pm

Hi!

In revision 2207 a new feature was added to some plots: a shadow generator. Unfortunately with shadows turned on, tooltips are not rendered for the correct position (tested with XYPlot). The problem is, that in the draw() method a copy of g2 and dataArea is created, which is needed later on. However, most modifications to g2/dataArea are only executed on the copies and not on the originals, which leads to different images and thus, wrong positions for the tooltips.

The following patch fixes the behaviour for a simple XYPlot without annotations, markers, etc.

Code: Select all

Index: XYPlot.java
===================================================================
--- XYPlot.java	(revision 4790)
+++ XYPlot.java	(working copy)
@@ -3359,6 +3359,7 @@
             for (int i = 0; i < getDatasetCount(); i++) {
                 foundData = render(g2, dataArea, i, info, crosshairState)
                     || foundData;
+                render(savedG2, savedDataArea, i, info, crosshairState);
             }
 
             // draw foreground annotations
@@ -3393,6 +3394,7 @@
             for (int i = getDatasetCount() - 1; i >= 0; i--) {
                 foundData = render(g2, dataArea, i, info, crosshairState)
                     || foundData;
+                render(savedG2, savedDataArea, i, info, crosshairState);
             }
 
             // draw foreground annotations
The provided code is just a prove of concept to show where the bug exists. It is NOT a solution! So far I don't understand 100% of what the code does :(

David, you did commit this changes. Could you have a look or suggest some kind of solution for it?

hth,
- martin

mkrauskopf
Posts: 31
Joined: Thu May 27, 2010 4:23 pm
antibot: No, of course not.

Re: ShadowGenerator and Tooltips

Post by mkrauskopf » Mon Oct 10, 2011 10:21 pm

It is actually filed as a bug: https://sourceforge.net/tracker/?func=d ... tid=115494 which I've hit few months ago. So I it might be closed if/after the patch is applied.

matinh
Posts: 483
Joined: Fri Aug 11, 2006 10:08 am
Location: Austria

Re: ShadowGenerator and Tooltips

Post by matinh » Tue Oct 11, 2011 7:05 am

Ah, thanks. I hadn't seen this bug report before.

Which patch are you talking about? Is there already a fix for it? There is no patch attached to the bug report and I can't find any in your git repo.

- martin

mkrauskopf
Posts: 31
Joined: Thu May 27, 2010 4:23 pm
antibot: No, of course not.

Re: ShadowGenerator and Tooltips

Post by mkrauskopf » Tue Oct 11, 2011 7:09 am

...the patch...
I've talked about your patch :) Just wanted to point out the issue in the tracker. I do not have any patch for this issue.

matinh
Posts: 483
Joined: Fri Aug 11, 2006 10:08 am
Location: Austria

Re: ShadowGenerator and Tooltips

Post by matinh » Tue Oct 11, 2011 7:27 am

Oh... :)
I don't have a patch now. Maxbe later this day/week ;-)

david.gilbert
JFreeChart Project Leader
Posts: 11666
Joined: Fri Mar 14, 2003 10:29 am
antibot: No, of course not.
Contact:

Re: ShadowGenerator and Tooltips

Post by david.gilbert » Fri Oct 14, 2011 6:05 am

I have it on my todo list to look at this bug as well, but I'm getting killed at work at the moment.
David Gilbert
JFreeChart Project Leader

:idea: Read my blog
:idea: Ask your company to buy the JFreeChart Developer Guide
:idea: Check out other products sold by my company Object Refinery Limited

Post Reply