findSubplot(): strange behaviour

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
uli
Posts: 24
Joined: Sat Mar 14, 2009 3:22 pm
Location: Berlin

findSubplot(): strange behaviour

Post by uli » Sun Jan 10, 2010 6:48 pm

Dear all,

I found a strange behaviour of the method findSubplot(info, point), or maybe more precise in the Method info.getPlotArea().
It seems like the maximum (internal) height of the plot area is 735.5390625. Although in fact it is larger. This leads to the fact that findSubplot(info, point) does not return the correct subplot when the point lies in the lower part of the subplot.

I'm not very familiar with the coordinates that JFreeChart uses to determine the plot area but I give here some numbers which might be useful for solving this miracle:
(points are coming from MouseDown)

Code: Select all

plot area:	java.awt.geom.Rectangle2D$Double[x=8.0,y=28.4609375,w=647.0,h=735.5390625]
point:	java.awt.Point[x=129,y=729] -> still can find the subplot
point:	java.awt.Point[x=125,y=730] -> does not find the suplot anymore
point:	java.awt.Point[x= 63,y=768] -> lower left corner of the subplot (+/-3 pixel)
Independent of the size of the plot area, if the y coordinate from MouseDown is larger than 729 the result from findSubplot(info, point) will be wrong (for the x coordinate it is something around 1000 and the maximum with of the plot area is 1008.0).

Thanks for your help!
Julia

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

Re: findSubplot(): strange behaviour

Post by david.gilbert » Mon Jan 11, 2010 11:09 pm

Hi Julia,

There are two possibilities:

(1) You've called this method passing in mouse coordinates but not taking into account that the chart may have been drawn in a different coordinate system (with the ChartPanel class, for very small or very large panels the chart is drawn at one size then scaled to fit the panel). See the getMin/MaxDrawingHeight()/Width() methods in the ChartPanel class.

(2) You did take into account the scaling that can be applied in the ChartPanel class: in this case, there is a real bug in JFreeChart and I will try to fix it.

Can you provide more information about what you've done?
David Gilbert
JFreeChart Project Leader

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

uli
Posts: 24
Joined: Sat Mar 14, 2009 3:22 pm
Location: Berlin

Re: findSubplot(): strange behaviour

Post by uli » Wed Jan 13, 2010 5:39 pm

Thank you, Dave, for your very helpful answer!
Indeed, case (1) was true.
I didn't know that the maximum draw size is limited (768 x 1024 pixel) and one has to change it.
The following lines of code now solved the problem:

Code: Select all

// get the monitor size (under Eclipse), in my case 1050 x 1680 pixel
Rectangle disp = getSite().getShell().getDisplay().getBounds(); 
// set the drawing width and height accordingly
chartPanel.setMaximumDrawHeight(disp.height);
chartPanel.setMaximumDrawWidth(disp.width);
:D
There is no bug you have to care about!

Have a nice day,
Julia

Locked