Example usage for org.jfree.chart.renderer.category LineAndShapeRenderer setSeriesStroke

List of usage examples for org.jfree.chart.renderer.category LineAndShapeRenderer setSeriesStroke

Introduction

In this page you can find the example usage for org.jfree.chart.renderer.category LineAndShapeRenderer setSeriesStroke.

Prototype

public void setSeriesStroke(int series, Stroke stroke, boolean notify) 

Source Link

Document

Sets the stroke for a series and, if requested, sends a RendererChangeEvent to all registered listeners.

Usage

From source file:com.rapidminer.gui.new_plotter.engine.jfreechart.ChartRendererFactory.java

private static void configureLineAndShapeRenderer(LineAndShapeRenderer renderer, ValueSource valueSource,
        PlotInstance plotInstance) {/*  w ww.j a v a  2  s . c om*/
    ValueSourceData valueSourceData = plotInstance.getPlotData().getValueSourceData(valueSource);
    int seriesCount = valueSourceData.getSeriesCount();
    SeriesFormat seriesFormat = valueSource.getSeriesFormat();
    DimensionConfig domainConfig = valueSource.getDomainConfig();
    DimensionConfig colorDimensionConfig = plotInstance.getCurrentPlotConfigurationClone()
            .getDimensionConfig(PlotDimension.COLOR);
    DimensionConfig shapeDimensionConfig = plotInstance.getCurrentPlotConfigurationClone()
            .getDimensionConfig(PlotDimension.SHAPE);

    renderer.setDefaultEntityRadius(4);

    // loop all series and set series format
    for (int seriesIdx = 0; seriesIdx < seriesCount; ++seriesIdx) {
        // configure linestyle
        if (seriesFormat.getLineStyle() != LineStyle.NONE) {
            renderer.setSeriesLinesVisible(seriesIdx, true);
            renderer.setSeriesStroke(seriesIdx, seriesFormat.getStroke(), false);
        } else {
            renderer.setSeriesLinesVisible(seriesIdx, false);
        }

        // configure series shape if necessary
        if (!SeriesFormat.calculateIndividualFormatForEachItem(domainConfig, shapeDimensionConfig)) {
            if (seriesFormat.getItemShape() != ItemShape.NONE) {
                renderer.setSeriesShapesVisible(seriesIdx, true);
                renderer.setSeriesShape(seriesIdx, seriesFormat.getItemShape().getShape());
            } else {
                renderer.setSeriesShapesVisible(seriesIdx, false);
            }
        }

        // configure series color if necessary
        if (!SeriesFormat.calculateIndividualFormatForEachItem(domainConfig, colorDimensionConfig)) {
            Color itemColor = seriesFormat.getItemColor();
            renderer.setSeriesPaint(seriesIdx, itemColor);
        }
        renderer.setSeriesOutlinePaint(seriesIdx, PlotConfiguration.DEFAULT_SERIES_OUTLINE_PAINT);
        renderer.setUseOutlinePaint(true);
    }
}