Cursor tracking fails after resize

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
blueser
Posts: 23
Joined: Wed Sep 14, 2005 5:05 pm

Cursor tracking fails after resize

Post by blueser » Tue Jul 31, 2007 3:19 pm

Hi,

we're using the code provided here (thks azaza21 for providing that ;-)) to implement a "cursor tracker" (we need to show current cursor coordinates on a label). It works fine as long as the panel keeps its original size. Once it is resized scaling errors start creeping in, and displayed (x, y) coordinate doesn't correspond anymore to the cursor position on the chart. As expected, the bigger the resize the bigger the error.

Anyone could lend a hand here? This feature is expected to ship with our next production version which is already delayed, so any help will be really appreciated... ;-)

TIA

Andre

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

Post by david.gilbert » Tue Jul 31, 2007 4:06 pm

It's not a good idea to grab some code off a forum and incorporate it into the next version of your production software *without* understanding exactly what it does.

Look at MouseListenerDemo4.java for the correct way to do the data value calculation.
David Gilbert
JFreeChart Project Leader

:idea: Read my blog
:idea: Support JFree via the Github sponsorship program

blueser
Posts: 23
Joined: Wed Sep 14, 2005 5:05 pm

Post by blueser » Tue Jul 31, 2007 5:20 pm

Hi David,

I saw that one coming ;-) On my behalf I can only say we needed it really badly, and since no one complained about the code azaza21 provided, I assumed it could be ok, but of course we needed to test it -- and that's how we found the problems that led to this thread.

I'd love to get my hands on MouseListenerDemo4.java but, unfortunately, we cannot afford buying the developer guide now :-(

So, would you (or anyone else) have any hint that would put me on the right track? I understand you won't post the code here for free, but any clue might save me, like what should (or shouldn't) be on that piece of code I am using...

Regards,

Andre

blueser
Posts: 23
Joined: Wed Sep 14, 2005 5:05 pm

Post by blueser » Tue Jul 31, 2007 7:42 pm

I guess I got it: it looks like I should use:

chartPanel.getChartRenderingInfo().getPlotInfo().getDataArea()

instead of:

chartPanel.getScreenDataArea()

Does it make sense?

Andre

Locked