Example usage for org.jfree.chart.renderer AbstractRenderer setSeriesOutlineStroke

List of usage examples for org.jfree.chart.renderer AbstractRenderer setSeriesOutlineStroke

Introduction

In this page you can find the example usage for org.jfree.chart.renderer AbstractRenderer setSeriesOutlineStroke.

Prototype

public void setSeriesOutlineStroke(int series, Stroke stroke) 

Source Link

Document

Sets the outline stroke used for a series and sends a RendererChangeEvent to all registered listeners.

Usage

From source file:org.openfaces.component.chart.impl.configuration.OutlineConfigurator.java

public void configure(ChartView view, ConfigurableRenderer configurableRenderer) {
    GridChartView chartView = (GridChartView) view;
    boolean outlinesSpecified = chartView.getOutlines() != null && !chartView.getOutlines().isEmpty();
    AbstractRenderer renderer = (AbstractRenderer) configurableRenderer;

    if (chartView.getDefaultOutlineStyle() != null || outlinesSpecified) {
        if (renderer instanceof BarRenderer) {
            ((BarRenderer) renderer).setDrawBarOutline(true);
        } else if (renderer instanceof XYBarRendererAdapter) {
            ((XYBarRendererAdapter) renderer).setDrawBarOutline(true);
        } else if (renderer instanceof LineAndShapeRenderer) {
            ((LineAndShapeRenderer) renderer).setDrawOutlines(true);
            ((LineAndShapeRenderer) renderer).setUseOutlinePaint(true);
        } else if (renderer instanceof XYRendererAdapter) {
            ((XYRendererAdapter) renderer).setDrawOutlines(true);
            ((XYRendererAdapter) renderer).setUseOutlinePaint(true);
        }//ww w.j  a va  2  s . c om
    }

    if (chartView.getDefaultOutlineStyle() != null && !outlinesSpecified) {
        renderer.setBaseOutlinePaint(chartView.getDefaultOutlineStyle().getColor());
        renderer.setBaseOutlineStroke(chartView.getDefaultOutlineStyle().getStroke());
        for (int seriesIndex = 0; seriesIndex < seriesCount; seriesIndex++) {
            renderer.setSeriesOutlinePaint(seriesIndex, chartView.getDefaultOutlineStyle().getColor());
            renderer.setSeriesOutlineStroke(seriesIndex, chartView.getDefaultOutlineStyle().getStroke());
        }
    } else if (outlinesSpecified) {
        final Iterator outlinesIterator = chartView.getOutlines().iterator();
        for (int seriesIndex = 0; seriesIndex < seriesCount; seriesIndex++) {
            if (outlinesIterator.hasNext()) {
                final LineStyle lineStyle = (LineStyle) outlinesIterator.next();
                renderer.setSeriesOutlinePaint(seriesIndex, lineStyle.getColor());
                renderer.setSeriesOutlineStroke(seriesIndex, lineStyle.getStroke());
            }
        }
    }
}

From source file:com.xpn.xwiki.plugin.charts.ChartCustomizer.java

public static void customizeRenderer(AbstractRenderer renderer, ChartParams params) {
    if (params.get(ChartParams.RENDERER_COLOR) != null) {
        renderer.setPaint(params.getColor(ChartParams.RENDERER_COLOR));
    }//from   w w  w.java2 s  .c  o m
    if (params.get(ChartParams.RENDERER_STROKE) != null) {
        renderer.setStroke(params.getStroke(ChartParams.RENDERER_STROKE));
    }
    if (params.get(ChartParams.RENDERER_SHAPE) != null) {
        renderer.setShape(params.getShape(ChartParams.RENDERER_SHAPE));
    }
    if (params.get(ChartParams.RENDERER_FILL_COLOR) != null) {
        renderer.setFillPaint(params.getColor(ChartParams.RENDERER_FILL_COLOR));
    }
    if (params.get(ChartParams.RENDERER_OUTLINE_COLOR) != null) {
        renderer.setOutlinePaint(params.getColor(ChartParams.RENDERER_OUTLINE_COLOR));
    }
    if (params.get(ChartParams.RENDERER_OUTLINE_STROKE) != null) {
        renderer.setOutlineStroke(params.getStroke(ChartParams.RENDERER_OUTLINE_STROKE));
    }
    if (params.get(ChartParams.RENDERER_ITEM_LABEL_VISIBLE) != null) {
        if (params.getBoolean(ChartParams.RENDERER_ITEM_LABEL_VISIBLE).booleanValue()) {
            renderer.setItemLabelsVisible(true);
            if (params.get(ChartParams.RENDERER_ITEM_LABEL_COLOR) != null) {
                renderer.setItemLabelPaint(params.getColor(ChartParams.RENDERER_ITEM_LABEL_COLOR));
            }
            if (params.get(ChartParams.RENDERER_ITEM_LABEL_FONT) != null) {
                renderer.setItemLabelFont(params.getFont(ChartParams.RENDERER_ITEM_LABEL_FONT));
            }
        } else {
            renderer.setItemLabelsVisible(false);
        }
    }
    if (params.get(ChartParams.RENDERER_SERIES_VISIBLE) != null) {
        renderer.setSeriesVisible(params.getBoolean(ChartParams.RENDERER_SERIES_VISIBLE));
    }
    if (params.get(ChartParams.RENDERER_SERIES_VISIBLE_IN_LEGEND) != null) {
        renderer.setSeriesVisibleInLegend(params.getBoolean(ChartParams.RENDERER_SERIES_VISIBLE_IN_LEGEND));
    }

    // series
    if (params.get(ChartParams.RENDERER_SERIES_COLORS) != null) {
        List list = params.getList(ChartParams.RENDERER_SERIES_COLORS);
        for (int i = 0; i < list.size(); i++) {
            renderer.setSeriesPaint(i, (Color) list.get(i));
        }
        // TODO: how the f*** do we get rid of the default values -- we don't! :(
        // for (int i = list.size(); renderer.getSeriesPaint(i) != null; i++) {
        // renderer.setSeriesPaint(i, null);
        // }
    }

    if (params.get(ChartParams.RENDERER_SERIES_STROKES) != null) {
        List list = params.getList(ChartParams.RENDERER_SERIES_STROKES);
        for (int i = 0; i < list.size(); i++) {
            renderer.setSeriesStroke(i, (Stroke) list.get(i));
        }
    }

    if (params.get(ChartParams.RENDERER_SERIES_SHAPES) != null) {
        List list = params.getList(ChartParams.RENDERER_SERIES_SHAPES);
        for (int i = 0; i < list.size(); i++) {
            renderer.setSeriesShape(i, (Shape) list.get(i));
        }
    }

    if (params.get(ChartParams.RENDERER_SERIES_FILL_COLORS) != null) {
        List list = params.getList(ChartParams.RENDERER_SERIES_FILL_COLORS);
        for (int i = 0; i < list.size(); i++) {
            renderer.setSeriesFillPaint(i, (Color) list.get(i));
        }
    }

    if (params.get(ChartParams.RENDERER_SERIES_OUTLINE_COLORS) != null) {
        List list = params.getList(ChartParams.RENDERER_SERIES_OUTLINE_COLORS);
        for (int i = 0; i < list.size(); i++) {
            renderer.setSeriesOutlinePaint(i, (Color) list.get(i));
        }
    }

    if (params.get(ChartParams.RENDERER_SERIES_OUTLINE_STROKES) != null) {
        List list = params.getList(ChartParams.RENDERER_SERIES_OUTLINE_STROKES);
        for (int i = 0; i < list.size(); i++) {
            renderer.setSeriesOutlineStroke(i, (Stroke) list.get(i));
        }
    }

    if (params.get(ChartParams.RENDERER_SERIES_ITEM_LABEL_VISIBLES) != null) {
        List list = params.getList(ChartParams.RENDERER_SERIES_ITEM_LABEL_VISIBLES);
        for (int i = 0; i < list.size(); i++) {
            renderer.setSeriesItemLabelsVisible(i, (Boolean) list.get(i));
        }
    }

    if (params.get(ChartParams.RENDERER_SERIES_ITEM_LABEL_COLORS) != null) {
        List list = params.getList(ChartParams.RENDERER_SERIES_ITEM_LABEL_COLORS);
        for (int i = 0; i < list.size(); i++) {
            renderer.setSeriesItemLabelPaint(i, (Color) list.get(i));
        }
    }

    if (params.get(ChartParams.RENDERER_SERIES_ITEM_LABEL_FONTS) != null) {
        List list = params.getList(ChartParams.RENDERER_SERIES_ITEM_LABEL_FONTS);
        for (int i = 0; i < list.size(); i++) {
            renderer.setSeriesItemLabelFont(i, (Font) list.get(i));
        }
    }
}

From source file:com.appnativa.rare.ui.chart.jfreechart.ChartHandler.java

protected void customizeSeriesAttributes(ChartPanel chartPanel, ChartDefinition cd, Plot plot,
        boolean multiset) {
    List<RenderableDataItem> rows = cd.getSeries();
    ChartInfo ci = (ChartInfo) cd.getChartHandlerInfo();
    List<SeriesData> seriesData = ci.seriesData;
    int len = (seriesData == null) ? 0 : seriesData.size();

    if (len == 0) {
        return;//  w  ww.  j av  a 2  s  .  c  om
    }

    ChartDataItem di;
    Paint p = null;
    iPainter painter;
    BasicStroke stroke = null;
    BasicStroke ostroke = null;
    RareBarPainter barPainter = null;
    AbstractRenderer r;
    Object o;
    UIColor c;
    PlotInformation pi = cd.getPlotInformation();

    if (pi != null) {
        float lt = pi.getLineThickness();
        float ot = pi.getOutlineThickness();

        if (lt > 1) {
            stroke = new BasicStroke(lt);
        }

        if (ot > 1) {
            ostroke = (ot == lt) ? stroke : new BasicStroke(ot);
        }
    }

    int n = 0;

    for (int i = 0; i < len; i++) {
        SeriesData data = seriesData.get(i);

        di = (ChartDataItem) rows.get(data.seriesIndex);

        if ((di == null) || di.isEmpty()) {
            continue;
        }

        p = null;
        o = ((XYPlot) plot).getRenderer(multiset ? i : 0);

        if (!(o instanceof AbstractRenderer)) {
            continue;
        }

        UIColor fc = data.fillColor;
        UIColor oc = data.outlineColor;

        r = (AbstractRenderer) o;
        painter = di.getComponentPainter();

        if (painter == null) {
            c = di.getBackground();

            if (c instanceof UIColorShade) {
                painter = ((UIColorShade) c).getBackgroundPainter();

                if (painter instanceof UISimpleBackgroundPainter) {
                    p = painter.getBackgroundColor();
                    painter = null;
                }
            } else {
                p = c;
            }
        }

        if ((painter == null) && (p == null)) {
            painter = cd.getRangeAxis().getComponentPainter();

            if (painter == null) {
                c = cd.getRangeAxis().getBackground();

                if (c instanceof UIColorShade) {
                    painter = ((UIColorShade) c).getBackgroundPainter();

                    if (painter instanceof UISimpleBackgroundPainter) {
                        p = painter.getBackgroundColor();
                        painter = null;
                    }
                } else {
                    p = c;
                }
            }
        }

        if (painter != null) {
            if (r instanceof XYBarRenderer) {
                if (barPainter == null) {
                    barPainter = new RareBarPainter(chartPanel);
                }

                XYBarRenderer xr = (XYBarRenderer) r;

                xr.setBarPainter(barPainter);
                p = ChartHelper.getPaint(painter);
            } else if (r instanceof BarRenderer) {
                if (barPainter == null) {
                    barPainter = new RareBarPainter(chartPanel);
                }

                BarRenderer xr = (BarRenderer) r;

                xr.setItemMargin(0);
                xr.setBarPainter(barPainter);
                p = ChartHelper.getPaint(painter);
            } else {
                iPlatformPaint pp = painter.getPaint(50, 50);

                p = (pp == null) ? null : pp.getPaint();
            }
        }

        if (p == null) {
            p = di.getBackground();
        }

        if (p == null) {
            p = getDefaultColor(i);
        }

        n = multiset ? 0 : i;
        r.setSeriesPaint(n, p);

        if (r instanceof XYAreaSplineRendererEx) {
            r.setSeriesFillPaint(n, p);
        }

        float lt = getSeriesLineThickness(di, -1);

        if (lt != -1) {
            r.setSeriesStroke(n, new BasicStroke(lt));
        } else if (stroke != null) {
            r.setSeriesStroke(n, stroke);
        }

        lt = getSeriesOutlineLineThickness(di, -1);

        if (lt != -1) {
            r.setSeriesOutlineStroke(n, ostroke);
        } else if (ostroke != null) {
            r.setSeriesOutlineStroke(n, ostroke);
        }

        if (r instanceof XYLineAndShapeRenderer) {
            ShapeStyle ss = getSeriesShapeStyle(pi, di);
            XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) r;

            switch (ss) {
            case FILLED:
                renderer.setBaseShapesVisible(true);
                renderer.setBaseShapesFilled(true);
                renderer.setUseFillPaint(true);
                renderer.setSeriesFillPaint(n, (fc == null) ? p : fc.getPaint());

                break;

            case OUTLINED:
                renderer.setBaseShapesVisible(true);
                renderer.setUseOutlinePaint(true);
                renderer.setDrawOutlines(true);
                renderer.setSeriesOutlinePaint(n, (oc == null) ? p : oc.getPaint());

                break;

            case FILLED_AND_OUTLINED:
                renderer.setSeriesOutlinePaint(n, (oc == null) ? p : oc.getPaint());
                renderer.setSeriesFillPaint(n, (fc == null) ? UIColor.WHITE.getPaint() : fc.getPaint());
                renderer.setBaseShapesVisible(true);
                renderer.setDrawOutlines(true);
                renderer.setBaseShapesFilled(true);
                renderer.setUseFillPaint(true);
                renderer.setUseOutlinePaint(true);

                break;

            default:
                renderer.setBaseShapesVisible(false);

                break;
            }

            if (renderer.getBaseShapesVisible()) {
                renderer.setSeriesShape(n, getDefaultShape(i));
            }
        }
    }
}