I'm trying to intercept ChartMouseEvent in order to modify an XYSeries of a JFreeChart object created with ChartFactory.createXYLineChart method (and displayed using a JDialog).
I retrieve successfully the coordinate of the mouse event this way:
public void chartMouseMoved(ChartMouseEvent arg0) {
int x = arg0.getTrigger().getX();
int y = arg0.getTrigger().getY();
The origin of the coordinate system (0,0) is located at the red square in the picture. Now, I would like to calculate in which interval is the mouse in. In order to do this I need:
- the top-left coordinate of the grey chart (green square)
- height and width of the grey chart
How can I get this values?
A note: I'm a JFreeChart newbie. If I'm doing this wrong, and there is a better way to do achive these goals, please put me in the right direction.