1

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 http://sites.google.com/site/yanchengcheok/Home/coordinate-problem-small.png

(zoom in version)

alt text http://sites.google.com/site/yanchengcheok/Home/coordinate-problem-big.png

Cheok Yan Cheng
  • 47,586
  • 132
  • 466
  • 875

2 Answers2

1

Here is the solution to the problem.

/* Try to get correct main chart area. */
final Rectangle2D _plotArea = chartPanel.getChartRenderingInfo().getPlotInfo().getSubplotInfo(0).getDataArea();
Cheok Yan Cheng
  • 47,586
  • 132
  • 466
  • 875
0

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
  • 19,824
  • 10
  • 45
  • 57
  • what are you going to put for the value? – Cheok Yan Cheng Feb 02 '10 at 06:23
  • 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 Feb 02 '10 at 17:01
  • I do have coordinate pointed by red arrow. How can I get the coordinate pointed by green arrow? – Cheok Yan Cheng Feb 05 '10 at 00:55
  • 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 Feb 05 '10 at 02:37
  • The corner formed by the faint grey line. – Cheok Yan Cheng Feb 07 '10 at 10:16