0

I'm using JChart2D for trace a values of a double array. I'm using ZoomableChart and I want get coordinates (x, y) of cursor when this stay over ZoomableChart in my code to show them in a JLabel and draw a vertical line.

  • How can I get the coordinates of the cursor?
  • How can I draw this line?
Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433
Sofia
  • 11
  • 2

1 Answers1

3

To get a point is easy. Add a MouseMotionListener to the ZoomableChart.

I'm guessing you want this information to represent a point in the data in the chart, rather than in the potentially zoomed ZoomableChart component itself. For that you'll need to look to something like (trawling through the docs for a class I heard of 'today'..) Chart2D.getPointFinder(), the finder apparently offers getNearestPoint(MouseEvent,Chart2D) to map a MouseEvent back to the underlying structure.

Go for it! :)

Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433
  • Do you want to link to the JavaDocs for the method in question, or is hitting Google merely part of the 'fun' of helping you? Also, I asked you a question in a comment. Since this is not a help desk, and I am not your paid servant, could you pretend like this is a technical site and *answer* my question? Also, feel free to drop the leading upside down '?' for sentences. It is not used in English. (I admire people's efforts to communicate with me in the only language I know, but it helps if they use the common way of writing it.) – Andrew Thompson Feb 28 '12 at 12:26