0

I need to use following method to get screen coordinates.but I am not able.Because when I call this function, ChartPanel is not added its parent Java Form.So it does not know coordinates. how can I force Chartpanel to draw yourself.

chartPanel.getChartRenderingInfo().getPlotInfo().getSubplotInfo(0).getDataArea();
user725455
  • 465
  • 10
  • 36
  • Please edit your question to include an [sscce](http://sscce.org/) that exhibits the problem you describe. – trashgod Feb 19 '12 at 04:47
  • Why do you need `ChartPanel` coordinates? Why not use a `ChartMouseListener`. – trashgod Feb 19 '12 at 04:55
  • I want to draw XYLineannotation to graph.I want these coordinates – user725455 Feb 19 '12 at 07:35
  • to specify end location for line.To calculate end point I must know to pixel point of first time tick unit in graph, the I will add some pixel, then I must convert last pixel value to Time Value in graph.I will show this line when chart is displayed, it will not drawn after an mouse event occurs.So I do not use ChartMouseListener.Do you think that I must addChartMouseListener to ChartPanel to get screen coordinate – user725455 Feb 19 '12 at 07:39
  • Cross-posted [here](http://www.jfree.org/forum/viewtopic.php?f=3&t=24933). – trashgod Feb 19 '12 at 18:31
  • I understand problem.When I try to get screen data area , it returns null values, because ChartPanel is not be drawn yet, it is not added parent Swing Form.So coordinates are not calculated.I have to force ChartPanel to draw yourself – user725455 Feb 21 '12 at 08:06

1 Answers1

1

Adding a ChartMouseListener to your ChartPanel is one way to get a ChartMouseEvent and the corresponding java.awt.event.MouseEvent.

Addendum: You might look at the annotation examples here and here.

Addendum: Absent a complete sscce that exhibits the exception you describe, it's difficult to suggest how to debug unseen code; at a guess, I'd examine the problem subplot, as shown here.

Community
  • 1
  • 1
trashgod
  • 203,806
  • 29
  • 246
  • 1,045
  • But I do not want to have ChartMouseEvent.I just want to convert data space value to coordinate pixel value without any mouse event – user725455 Feb 19 '12 at 08:39
  • Sorry, I still have no idea what you're trying to accomplish; I've added links to related examples above. – trashgod Feb 19 '12 at 08:54
  • Sorry, These links does not describe my problem.I updated the problem description.Please read – user725455 Feb 19 '12 at 09:21