Results 1 to 3 of 3

Thread: Identify specific datapoint within a PickListener

  1. #1
    Junior Member
    Join Date
    Dec 2008
    Posts
    4

    Identify specific datapoint within a PickListener

    Hi,

    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?

    Thanks,

    Cory

  2. #2
    Senior Member ed's Avatar
    Join Date
    Aug 2005
    Posts
    312
    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.


    The first 90% of the code accounts for the first 90% of the development time. The remaining 10% of the code accounts for the other 90% of the development time.

  3. #3
    Junior Member
    Join Date
    Dec 2008
    Posts
    4
    Ah perfect. That should work.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •