Reputation: 661
How to modify mouseDragged event of ChartPanel such that I want to do some processing before/after the zooming is done? I have the following chartPanel,
JFreeChart chart = new JFreeChart(
"Demo", JFreeChart.DEFAULT_TITLE_FONT,plot, true);
ChartPanel chartPanel = new ChartPanel(chart);
Whenever the mouse is dragged, I want to call my function before/ after the mouseDragged() is called. How to do this ?
chartPanel.addMouseMotionListener(new MouseMotionListener() {
@Override
public void mouseDragged(MouseEvent e) {
// TODO Auto-generated method stub
}
i am unable to see super.mouseDragged(e)
.
how to invoke my function after the chart is zoomed. Basically what i want to do is after the chart is zoomed, I want to get the range of x and y coordinates and add a suitable XYAnnotation
. How can I do this ?
Upvotes: 2
Views: 1764
Reputation: 205785
You can override mouseDragged()
in org.jfree.chart.ChartPanel
and do your processing before or after super.mouseDragged(e)
.
Addendum: MouseMotionAdapter
may be a convenient alternative:
chartPanel.addMouseMotionListener(new MouseMotionAdapter() {
@Override
public void mouseDragged(MouseEvent e) {
// process before
super.mouseDragged(e);
// process after
}
});
Upvotes: 3