I am using JFreeChart in Java to draw an XYLineChart containing 50+ x, y points. The chart is in a ChartPanel which is in 1 of the JPanels of my JFrame.
I know JFreeChart already has zoom functionality built-in whereby on a mouse click and drag, it zooms in/ out and displays the points under the selected "dragged" area.
I want to know if there is any way to have it return the x, y co-ordinates of the points if we zoom while pressing the CTRL, ALT or SHIFT key, i.e., if a user clicks a point on the chart and then drags the mouse, it should zoom as usual. But if the user clicks on a point and drags while pressing either SHIFT or ALT or CTRL keys, we should get a list of all the points selected on the Chart [the points underneath the dragged area]. Is this possible ? Kindly let me know how to go about it.
I did try to add a simple MouseListener to the ChartPanel to detect when the mouse is pressed & released but the x, y position values returned by the Mouse event correspond to the location of the Click on screen & not to the actual x, y co-ordinates of the points on the chart. I need the actual co-ordinates of all points that the user clicks and drags the mouse over, so as to calculate before which point was the mouse pressed and dragged & where the mouse was released and use that information to select multiple points underneath the dragged area.
If anyone has any idea about this, please let me know.
This is the answer I gave in the JFreeChart forum: