views:

128

answers:

2

I wish to get the following coordinate in JFreeChart.

I try to use

chartPanel.getScreenDataArea()

But, it is not the area I want.

The returned rectangle is outside the area I wish to have.

The coordinate I wish to have is being marked as ??? in green.

alt text

(zoom in version)

alt text

A: 

There are methods to convert chart and AWT/Swing coordinates from one to another, once you can get ahold of the Axis items for the chart.

double ValueAxis.java2DToValue(double) and double ValueAxis.valueToJava2D(double)

BobMcGee
what are you going to put for the value?
Yan Cheng CHEOK
I thought you had coordinates for the corner in one system? I'm not sure exactly what you're asking now... could you explain a little more? I think we may have a language barrier in effect here, and explaining more may help surpass it.
BobMcGee
I do have coordinate pointed by red arrow. How can I get the coordinate pointed by green arrow?
Yan Cheng CHEOK
What am I supposed to be seeing the green arrow pointing at? Some random pixel? The faint grey line? The pixel next to the corner? Is it some specified distance from another pixel? Your diagram and explanation make it impossible to tell.
BobMcGee
The corner formed by the faint grey line.
Yan Cheng CHEOK
A: 

Here is the solution to the problem.

/* Try to get correct main chart area. */
final Rectangle2D _plotArea = chartPanel.getChartRenderingInfo().getPlotInfo().getSubplotInfo(0).getDataArea();
Yan Cheng CHEOK