Example usage for org.jfree.chart.renderer.item DefaultShapeIRS DefaultShapeIRS

List of usage examples for org.jfree.chart.renderer.item DefaultShapeIRS DefaultShapeIRS

Introduction

In this page you can find the example usage for org.jfree.chart.renderer.item DefaultShapeIRS DefaultShapeIRS.

Prototype

public DefaultShapeIRS(AbstractRenderer renderer) 

Source Link

Document

Creates a new rendering strategy for the submitted renderer using its per series properties.

Usage

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

/**
 * Creates a chart./*from  www  .  j  a  v  a  2s.  c om*/
 * 
 * @param dataset  the dataset.
 * 
 * @return A chart.
 */
private static JFreeChart createChart(final MultiValueCategoryDataset dataset,
        final DatasetSelectionExtension<CategoryCursor<String, String>> ext) {

    ScatterRenderer r = new ScatterRenderer();
    CategoryPlot plot = new CategoryPlot(dataset, new CategoryAxis("Category"), new NumberAxis("Value"), r);
    plot.setBackgroundColor(Color.LIGHT_GRAY);
    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.addChangeListener(plot);

    //illustrates the usage of a shape item rendering strategy
    final CategoryCursor<String, String> cursor = new CategoryCursor<String, String>();
    r.setShapeIRS(new DefaultShapeIRS(r) {
        private static final long serialVersionUID = 1L;

        @Override
        public Shape getItemShape(int row, int column) {
            cursor.setPosition((String) dataset.getRowKey(row), (String) 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;
}