Example usage for org.jfree.chart.renderer.xy StackedXYAreaRenderer setAutoPopulateSeriesStroke

List of usage examples for org.jfree.chart.renderer.xy StackedXYAreaRenderer setAutoPopulateSeriesStroke

Introduction

In this page you can find the example usage for org.jfree.chart.renderer.xy StackedXYAreaRenderer setAutoPopulateSeriesStroke.

Prototype

public void setAutoPopulateSeriesStroke(boolean auto) 

Source Link

Document

Sets the flag that controls whether or not the series stroke list is automatically populated when #lookupSeriesStroke(int) is called.

Usage

From source file:org.moeaframework.analysis.plot.Plot.java

/**
 * Creates a new area plot series.  The data will be stacked with
 * any preceding calls to {@code stacked}.  The series is added to the given
 * dataset, or if {@code null} a new dataset is created.
 * /*from w  ww  . j a  v a  2s  .  com*/
 * @param label the label for the series
 * @param x the x values
 * @param y the y values
 * @param dataset the dataset, or {@code null} if a new dataset should be
 *        created
 * @return a reference to this {@code Plot} instance
 */
private Plot stacked(String label, List<? extends Number> x, List<? extends Number> y,
        DefaultTableXYDataset dataset) {
    if (dataset == null) {
        createXYPlot();

        XYPlot plot = chart.getXYPlot();

        if (plot.getDataset(currentDataset) instanceof DefaultTableXYDataset) {
            dataset = (DefaultTableXYDataset) plot.getDataset(currentDataset);
        } else {
            currentDataset++;
            dataset = new DefaultTableXYDataset();
        }
    }

    // generate the dataset
    XYSeries series = new XYSeries(label, true, false);

    for (int i = 0; i < x.size(); i++) {
        series.add(x.get(i), y.get(i));
    }

    dataset.addSeries(series);

    // add the dataset to the plot
    XYPlot plot = chart.getXYPlot();
    plot.setDataset(currentDataset, dataset);

    // setup the renderer
    Paint paint = paintHelper.get(dataset.getSeriesKey(0));
    StackedXYAreaRenderer renderer = new StackedXYAreaRenderer();
    renderer.setAutoPopulateSeriesStroke(false);

    renderer.setBaseStroke(new BasicStroke(3f, 1, 1));
    renderer.setBasePaint(paint);
    renderer.setBaseFillPaint(paint);

    plot.setRenderer(currentDataset, renderer);

    return this;
}