View Full Version : Identify specific datapoint within a PickListener

12-10-2008, 05:22 PM

I'm using JMSL's charting api, and I've created a nice chart with some markers on it. The markers are all x,y points in a single Data object. Following the instructions in the tutorial, I've attached a PickListener, which fires the pickPerformed(PickEvent) method when I want it to (i.e. every time the user clicks on one of the markers.)

The problem is, the PickEvent.getNode() doesn't tell me WHICH marker was clicked on by the user. I can use it to find out that my Data node has been clicked on, but that's as specific as it seems to get.

Is there an API that can help me get more detailed information about a mouse click on a marker? Or even something that lets me figure out what x,y co-ordinates (in terms of swing "pixels" on screen) each marker is at, so I can back-compute the right information on my own, based on the location in the current mouse event?



12-10-2008, 06:14 PM
There are a couple examples in the demo gallery that might be of help here -- specifically under the Data Fitting examples that add points if you left-click and remove points when you right-click. There's a test to see if any data values are nearby (within some epsilon) the clicked coordinates.

As for converting between drawing window coordinates and axis values, you can use the mapDeviceToUser() and mapUserToDevice() methods in the Axis class. These are used in those examples in the demo gallery as well.

12-11-2008, 09:46 AM
Ah perfect. That should work.