Example usage for org.jfree.chart ChartPanel removeMouseListener

List of usage examples for org.jfree.chart ChartPanel removeMouseListener

Introduction

In this page you can find the example usage for org.jfree.chart ChartPanel removeMouseListener.

Prototype

public synchronized void removeMouseListener(MouseListener l) 

Source Link

Document

Removes the specified mouse listener so that it no longer receives mouse events from this component.

Usage

From source file:org.fhcrc.cpl.viewer.gui.MRMDialog.java

/**
  * Draw a chart in a panel.  Good for precursors and daughters
  * @param parentPanel/*  ww  w  .j  av  a  2 s . c  o m*/
  * @param dataset
  * @param domainMin
  * @param domainMax
  * @param supplier
  * @param wg
  */

protected void createChartInPanel(JPanel parentPanel, XYSeriesCollection dataset, Double domainMin,
        Double domainMax, DrawingSupplier supplier, whichGraph wg) {
    if (precursorChromatogramEmpty(transitionOnPlot) && wg == whichGraph.Precursor) {
        precursorContainerContainerPanel.setVisible(false);
        if (this.getWidth() >= 100 && this.getHeight() >= 100)
            this.setPreferredSize(new Dimension(this.getWidth(), this.getHeight()));
        pack();
        return;
    }
    switch (wg) {
    case Precursor:
        clearPreviousChartJunk(oldPrecursorChart);
        oldPrecursorChart = null;
        break;
    case Daughter:
        clearPreviousChartJunk(oldProductChart);
        oldProductChart = null;
        break;
    }

    JFreeChart chart = ChartFactory.createXYLineChart(null, "seconds", null, dataset, PlotOrientation.VERTICAL,
            true, false, false);

    chart.setBackgroundPaint(new Color(220, 220, 220));
    XYPlot xyp = (XYPlot) (chart.getPlot());
    xyp.setBackgroundPaint(Color.WHITE);
    xyp.setDomainGridlinesVisible(true);
    xyp.setRangeGridlinesVisible(true);
    xyp.setDomainGridlinePaint(Color.LIGHT_GRAY);
    xyp.setRangeGridlinePaint(Color.LIGHT_GRAY);
    if (supplier != null) {
        xyp.setDrawingSupplier(supplier);
    } else {
        xyp.setDrawingSupplier(Utils.plainDrawingSupplier(Color.LIGHT_GRAY));
    }
    xyp.setSeriesRenderingOrder(SeriesRenderingOrder.REVERSE);

    CenterZoomNumberAxis axisDomain = new CenterZoomNumberAxis("seconds");
    axisDomain.setAutoRangeIncludesZero(false);
    axisDomain.setRange(Math.max(0.0, domainMin), domainMax);
    axisDomain.addChangeListener(new domainAxisZoomCoordinator(axisDomain));

    xyp.clearAnnotations();
    xyp.setDomainAxis(axisDomain);
    xyp.getDomainAxis().setAutoRange(false);
    xyp.getRangeAxis().setAutoRange(false);
    XYLineAndShapeRenderer xylsr = (XYLineAndShapeRenderer) xyp.getRenderer();
    xylsr.setLegendLine(Utils.legendThing(16, 6));

    xylsr.setShapesFilled(true);
    xylsr.setBaseShapesFilled(true);
    PanelWithChart panelWithChart = new PanelWithChart(chart);
    ChartPanel cp = panelWithChart.getChartPanel();
    cp.removeMouseListener(cp);
    cp.removeMouseMotionListener(cp);
    if (peaksTable != null) {
        MRMerMouseListener mml = new MRMerMouseListener(cp, (PeaksTableModel) peaksTable.getModel());
        cp.addMouseListener(mml);
        cp.addMouseMotionListener(mml);
    }
    cp.setPreferredSize(new Dimension(parentPanel.getWidth(), parentPanel.getHeight() - 10));
    cp.setDomainZoomable(true);
    cp.setRangeZoomable(false);
    cp.setPopupMenu(null);
    parentPanel.removeAll();
    parentPanel.add(panelWithChart);

    switch (wg) {
    case Precursor:
        createChartInPanelPrecursorTasksOnly(xyp);
        oldPrecursorChart = xyp;
        break;
    case Daughter:
        createChartInPanelDaughterTasksOnly(xyp);
        oldProductChart = xyp;
        break;
    }
    parentPanel.updateUI();
    listTransition.requestFocus();
}