List of usage examples for org.jfree.chart.panel.selectionhandler FreePathSelectionHandler FreePathSelectionHandler
public FreePathSelectionHandler()
From source file:org.jfree.chart.demo.selection.SelectionDemo4.java
/** * Creates a panel for the demo (used by SuperDemo.java). * //ww w. j a v a 2s. c o m * @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). * // w ww. j a v a 2 s.c o m * @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; }