Example usage for org.jfree.chart ChartMouseListener chartMouseClicked

List of usage examples for org.jfree.chart ChartMouseListener chartMouseClicked

Introduction

In this page you can find the example usage for org.jfree.chart ChartMouseListener chartMouseClicked.

Prototype

void chartMouseClicked(ChartMouseEvent event);

Source Link

Document

Callback method for receiving notification of a mouse click on a chart.

Usage

From source file:org.gumtree.vis.awt.CompositePanel.java

@Override
public void chartMouseClicked(ChartMouseEvent event) {
    JFreeChart chart = event.getChart();
    for (IPlot plot : plotList) {
        if (plot.getChart() == chart) {
            focusedPlot = plot;//from ww  w .  ja va2s.  c  om
        }
    }
    for (ChartMouseListener listener : listeners) {
        listener.chartMouseClicked(event);
    }
}

From source file:org.tsho.dmc2.core.chart.jfree.DmcChartPanel.java

/**
 * Receives notification of mouse clicks on the panel. These are
 * translated and passed on to any registered chart mouse click listeners.
 *
 * @param event  Information about the mouse event.
 *///  w  ww  . ja  v  a2s. co m
public void mouseClicked(MouseEvent event) {

    Insets insets = getInsets();
    int x = event.getX() - insets.left;
    int y = event.getY() - insets.top;

    //"Custom" mouse click handling code. One may use it for interactive work with the plots
    //(or follow the original framework). 
    //Manager should be set with setManager(), and handleMouseClicked(), which
    //is an empty function of AbstractManager, should be overriden in the AbstractManager subclass.
    if (manager != null)
        manager.handleMouseClicked(x, y);

    // old 'handle click' code...
    chart.handleClick(x, y, this.info);

    // new entity code...
    if (this.chartMouseListeners.isEmpty()) {
        return;
    }

    ChartEntity entity = null;
    if (this.info != null) {
        EntityCollection entities = this.info.getEntityCollection();
        if (entities != null) {
            entity = entities.getEntity(x, y);
        }
    }
    ChartMouseEvent chartEvent = new ChartMouseEvent(getChart(), event, entity);

    Iterator iterator = chartMouseListeners.iterator();
    while (iterator.hasNext()) {
        ChartMouseListener listener = (ChartMouseListener) iterator.next();
        listener.chartMouseClicked(chartEvent);
    }
}