Example usage for org.jfree.data.datasetextension DatasetSelectionExtension isSelected

List of usage examples for org.jfree.data.datasetextension DatasetSelectionExtension isSelected

Introduction

In this page you can find the example usage for org.jfree.data.datasetextension DatasetSelectionExtension isSelected.

Prototype

public boolean isSelected(DatasetCursor cursor);

Source Link

Usage

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

/**
 * Creates a chart./*www. j av a2s.co  m*/
 * 
 * @param dataset
 *            the dataset.
 * 
 * @return A chart.
 */
private static JFreeChart createChart(final MultiValueCategoryDataset dataset,
        final DatasetSelectionExtension ext) {

    ScatterRenderer r = new ScatterRenderer();
    CategoryPlot plot = new CategoryPlot(dataset, new CategoryAxis("Category"), new NumberAxis("Value"), r);
    plot.setBackgroundPaint(Color.lightGray);
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinePaint(Color.white);
    plot.setAxisOffset(new RectangleInsets(4, 4, 4, 4));
    JFreeChart chart = new JFreeChart("ScatterRendererDemo1", plot);
    ChartUtilities.applyCurrentTheme(chart);

    //register the plot
    ext.addSelectionChangeListener(plot);

    //illustrates the usage of a shape item rendering strategy
    final CategoryCursor cursor = new CategoryCursor();
    r.setShapeIRS(new DefaultShapeIRS(r) {
        public Shape getItemShape(int row, int column) {
            cursor.setPosition(dataset.getRowKey(row), dataset.getColumnKey(column));
            if (ext.isSelected(cursor)) {
                return new Rectangle2D.Double(-10.0, -10.0, 20.0, 20.0);
            } else {
                return super.getItemShape(row, column);
            }
        }
    });

    return chart;

}