Example usage for org.jfree.chart.panel.selectionhandler EntitySelectionManager setIntersectionSelection

List of usage examples for org.jfree.chart.panel.selectionhandler EntitySelectionManager setIntersectionSelection

Introduction

In this page you can find the example usage for org.jfree.chart.panel.selectionhandler EntitySelectionManager setIntersectionSelection.

Prototype

public void setIntersectionSelection(boolean on) 

Source Link

Usage

From source file:org.jfree.chart.demo.selection.SelectionDemo4.java

/**
 * Creates a panel for the demo (used by SuperDemo.java).
 * //ww  w .jav  a2  s .com
 * @return A panel.
 */
public final JPanel createDemoPanel() {
    IntervalXYDataset xydataset = createDataset();
    //extend dataset and add selection change listener for the demo
    DatasetSelectionExtension<XYCursor> datasetExtension = new XYDatasetSelectionExtension(xydataset);
    datasetExtension.addChangeListener(this);

    //standard setup
    JFreeChart chart = createChart(xydataset, datasetExtension);
    ChartPanel panel = new ChartPanel(chart);
    panel.setMouseWheelEnabled(true);

    // add a selection handler
    RegionSelectionHandler selectionHandler = new FreePathSelectionHandler();
    panel.addMouseHandler(selectionHandler);
    panel.addMouseHandler(new MouseClickSelectionHandler());
    panel.removeMouseHandler(panel.getZoomHandler());

    // add a selection manager with intersection selection
    DatasetExtensionManager dExManager = new DatasetExtensionManager();
    dExManager.registerDatasetExtension(datasetExtension);

    EntitySelectionManager selectionManager = new EntitySelectionManager(panel, new Dataset[] { xydataset },
            dExManager);
    selectionManager.setIntersectionSelection(true);
    panel.setSelectionManager(selectionManager);

    return panel;
}

From source file:org.jfree.expdemo.SelectionDemo4.java

/**
 * Creates a panel for the demo (used by SuperDemo.java).
 * //from   w w  w  .ja v a  2 s.c om
 * @return A panel.
 */
public JPanel createDemoPanel() {
    IntervalXYDataset dataset = createDataset();
    //extend dataset and add selection change listener for the demo
    DatasetSelectionExtension datasetExtension = new XYDatasetSelectionExtension(dataset);
    datasetExtension.addSelectionChangeListener(this);

    //standard setup
    JFreeChart chart = createChart(dataset, datasetExtension);
    ChartPanel panel = new ChartPanel(chart);
    panel.setMouseWheelEnabled(true);

    // add a selection handler
    RegionSelectionHandler selectionHandler = new FreePathSelectionHandler();
    panel.addMouseHandler(selectionHandler);
    panel.addMouseHandler(new MouseClickSelectionHandler());
    panel.removeMouseHandler(panel.getZoomHandler());

    // add a selection manager with intersection selection
    DatasetExtensionManager dExManager = new DatasetExtensionManager();
    dExManager.registerDatasetExtension(datasetExtension);

    EntitySelectionManager selectionManager = new EntitySelectionManager(panel, new Dataset[] { dataset },
            dExManager);
    selectionManager.setIntersectionSelection(true);
    panel.setSelectionManager(selectionManager);

    return panel;
}