translateValueToJava2D() does not consider scaling?

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
wwwclaes
Posts: 7
Joined: Mon Feb 09, 2004 3:58 pm

translateValueToJava2D() does not consider scaling?

Post by wwwclaes » Mon Feb 23, 2004 6:05 pm

Hi! I ran into a problem with a set of "rulers" I've implemented. They malfunction when the chart window is resized past DEFAULT_MAXIMUM_DRAW_WIDTH. It seems that the cause of the problem is that translateValueToJava2D() does not consider scaling. Can you confirm this?

As for now, I have circumvented the problem by setting maximumDrawWidth to Integer.MAX_VALUE. BTW, what's the reason for scaling?

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

Re: translateValueToJava2D() does not consider scaling?

Post by david.gilbert » Tue Feb 24, 2004 6:27 pm

wwwclaes wrote:Hi! I ran into a problem with a set of "rulers" I've implemented. They malfunction when the chart window is resized past DEFAULT_MAXIMUM_DRAW_WIDTH. It seems that the cause of the problem is that translateValueToJava2D() does not consider scaling. Can you confirm this?
No it doesn't take into account scaling, because the method doesn't know anything about the chart image (there may even be several chart images, all different sizes). The method just assumes that the axis lies along one edge of the Rectangle2D that you provide, then converts the data value (which is measured relative to the axis range) into Java2D coordinates (the same coordinate space as the Rectangle2D). If you want the translation to agree with what is already displayed on the screen, then you need to pass the scaled data area to the translateValueToJava2D() method.
wwwclaes wrote:BTW, what's the reason for scaling?
(1) It stops the offscreen image buffer in the chart panel from consuming too much memory. (2) Some people like it, because the title fonts etc scale up with the size of the chart.

As you've found, you can turn this feature off if you don't like it.
David Gilbert
JFreeChart Project Leader

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

Locked