Example usage for org.jfree.chart.plot PiePlot setSectionOutlineStroke

List of usage examples for org.jfree.chart.plot PiePlot setSectionOutlineStroke

Introduction

In this page you can find the example usage for org.jfree.chart.plot PiePlot setSectionOutlineStroke.

Prototype

public void setSectionOutlineStroke(int section, Stroke stroke) 

Source Link

Document

Sets the stroke used to fill a section of the pie and sends a PlotChangeEvent to all registered listeners.

Usage

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

public void configure(ConfigurablePlot plot, ChartView view) {
    PiePlot piePlot = (PiePlot) plot;
    boolean outlinesSpecified = view.getOutlines() != null && !view.getOutlines().isEmpty();

    if (view.getDefaultOutlineStyle() != null && !outlinesSpecified) {
        piePlot.setBaseSectionOutlinePaint(view.getDefaultOutlineStyle().getColor());
        piePlot.setBaseSectionOutlineStroke(view.getDefaultOutlineStyle().getStroke());
        for (int seriesIndex = 0; seriesIndex < seriesCount; seriesIndex++) {
            piePlot.setSectionOutlinePaint(seriesIndex, view.getDefaultOutlineStyle().getColor());
            piePlot.setSectionOutlineStroke(seriesIndex, view.getDefaultOutlineStyle().getStroke());
        }/*from   w  w w.  j  a  va 2  s  .com*/
    } else if (outlinesSpecified) {
        final Iterator outlinesIterator = view.getOutlines().iterator();
        for (int seriesIndex = 0; seriesIndex < seriesCount; seriesIndex++) {
            if (outlinesIterator.hasNext()) {
                final LineStyle lineStyle = (LineStyle) outlinesIterator.next();
                piePlot.setSectionOutlinePaint(seriesIndex, lineStyle.getColor());
                piePlot.setSectionOutlineStroke(seriesIndex, lineStyle.getStroke());
            }
        }
    }
}

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

private void setupPieChartSelection(PiePlot plot, Chart chart) {
    if (((PieChartView) chart.getChartView()).getSelectedSector() != null) {
        final PieSectorInfo info = ((PieChartView) chart.getChartView()).getSelectedSector();
        final ChartSelection selection = chart.getChartSelection();
        final LineStyle lineStyle = selection.getLineStyle();
        Paint outlinePaint = lineStyle.getColor() != null ? lineStyle.getColor() : Color.WHITE;
        final Stroke outlineStroke = lineStyle.getStroke();
        final Paint selectionPaint = selection.getFillPaint();

        plot.setSectionOutlinePaint(info.getIndex(), outlinePaint);
        if (outlineStroke != null) {
            plot.setSectionOutlineStroke(info.getIndex(), outlineStroke);
        }/* www.j  a  v a2s.  c  o  m*/

        if (selectionPaint != null) {
            plot.setSectionPaint(info.getIndex(), selectionPaint);
        }
    }
}

From source file:net.sqs2.omr.result.export.chart.ChartImageWriter.java

private void setSectionPaint(PieDataset dataSet, PiePlot piePlot) {
    Paint outlinePaint = Color.BLACK;
    Stroke outlineStroke = new BasicStroke(1.0f);

    if (this.itemBackgroundImages != null && 0 < this.itemBackgroundImages.length) {
        int index = 0;
        for (Object key : dataSet.getKeys()) {
            int imageIndex = index % this.itemBackgroundImages.length;
            BufferedImage texture = this.itemBackgroundImages[imageIndex];
            Rectangle2D anchor = new Rectangle2D.Double(0, 0, texture.getWidth(), texture.getHeight());
            TexturePaint fillPaint = new TexturePaint(texture, anchor);
            piePlot.setSectionPaint((Comparable<?>) key, fillPaint);
            piePlot.setSectionOutlinePaint((Comparable<?>) key, outlinePaint);
            piePlot.setSectionOutlineStroke((Comparable<?>) key, outlineStroke);
            index++;//from  ww  w  . java 2  s. c  o  m
        }
    }
    piePlot.setOutlineVisible(true);
    piePlot.setOutlinePaint(outlinePaint);
    piePlot.setOutlineStroke(outlineStroke);
    piePlot.setSectionOutlinesVisible(true);
    piePlot.setBaseSectionOutlinePaint(outlinePaint);
    piePlot.setBaseSectionOutlineStroke(outlineStroke);
}

From source file:org.tiefaces.components.websheet.chart.ChartHelper.java

/**
 * finalize the style for jfreechart. The default setting is different from
 * jfreechart and Excel. We try to minimize the difference.
 * /*from   w w w . jav a  2  s  .  c  om*/
 * @param chart
 *            jfreechart.
 * @param chartData
 *            contain information gathered from excel chart object.
 */

private void setupPieStyle(final JFreeChart chart, final ChartData chartData) {
    PiePlot plot = (PiePlot) chart.getPlot();
    List<ChartSeries> seriesList = chartData.getSeriesList();
    List<ParsedCell> categoryList = chartData.getCategoryList();
    BasicStroke bLine = new BasicStroke(2.0f);
    for (int i = 0; i < seriesList.size(); i++) {
        ChartSeries chartSeries = seriesList.get(i);
        List<XColor> valueColorList = chartSeries.getValueColorList();
        for (int index = 0; index < categoryList.size(); index++) {
            try {
                String sCategory = getParsedCellValue(categoryList.get(index));
                Color cColor = ColorUtility.xssfClrToClr(valueColorList.get(index).getXssfColor());
                plot.setSectionPaint(sCategory, cColor);
                plot.setSectionOutlineStroke(sCategory, bLine);
            } catch (Exception ex) {
                LOG.log(Level.FINE, "SetupPieStyle error = " + ex.getLocalizedMessage(), ex);
            }
        }

    }
    plot.setBackgroundPaint(ColorUtility.xssfClrToClr(chartData.getBgColor().getXssfColor()));

    // below are modifications for default setting in excel chart
    // to-do: need read setting from xml in future

    plot.setOutlineVisible(false);
    plot.setLegendItemShape(new Rectangle(TieConstants.DEFAULT_LEGENT_ITEM_SHAPE_WIDTH,
            TieConstants.DEFAULT_LEGENT_ITEM_SHAPE_HEIGHT));
    chart.setBackgroundPaint(Color.WHITE);
    LegendTitle legend = chart.getLegend();
    legend.setPosition(RectangleEdge.RIGHT);
    legend.setFrame(BlockBorder.NONE);

}

From source file:org.openfaces.component.chart.impl.plots.PiePlotAdapter.java

private void sectorProcessing(PiePlot plot, PieChartView chartView, PieDataset dataset,
        CategoryDataset categoryDataset) {
    List<PieSectorProperties> sectors = chartView.getSectors();
    if (sectors == null || sectors.size() == 0)
        return;//from   w  ww.j  a  v a  2  s . c o m

    for (PieSectorProperties sector : sectors) {
        DynamicPieGenerator generator = new DynamicPieGenerator(chartView, null);

        int index = -1;

        Float sectorPulled = sector.getPulled();
        if (dataset instanceof CategoryToPieDataset) {
            CategoryToPieDataset cds = (CategoryToPieDataset) dataset;
            int count = getIterationCount(cds);
            for (int q = 0; q < count; q++) {
                CategoryToPieDataset currPieDataset = new CategoryToPieDataset(categoryDataset, order, q);
                List keys = currPieDataset.getKeys();
                index = -1;
                for (int j = 0; j < keys.size(); j++) {
                    index++;

                    boolean conditionValue = generator.getConditionValue(sector, q, currPieDataset,
                            currPieDataset.getKey(j));
                    if (!conditionValue)
                        continue;

                    if (sectorPulled != null && sectorPulled > 0) {
                        plot.setExplodePercent(index, (double) sectorPulled);
                    }

                    StyleObjectModel cssSectorModel = sector.getStyleObjectModel();
                    if (cssSectorModel != null && cssSectorModel.getBorder() != null) {
                        StyleBorderModel border = cssSectorModel.getBorder();
                        Color borderColor = border.getColor();
                        if (borderColor != null) {
                            plot.setSectionOutlinePaint(index, borderColor);
                            plot.setSectionOutlineStroke(index, PropertiesConverter.toStroke(border));
                        }

                        Color sectorModelColor = cssSectorModel.getColor();
                        if (sectorModelColor != null) {
                            plot.setSectionPaint(index, sectorModelColor);
                        }
                    }
                }
            }
        } else {
            if (dataset == null || dataset.getKeys() == null)
                continue;

            for (int j = 0; j < dataset.getKeys().size(); j++) {
                index++;

                boolean conditionValue = generator.getConditionValue(sector, 0, dataset, dataset.getKey(j));
                if (!conditionValue)
                    continue;

                if (sectorPulled != null && sectorPulled > 0) {
                    plot.setExplodePercent(index, (double) sectorPulled);
                }

                StyleObjectModel cssSectorModel = sector.getStyleObjectModel();
                if (cssSectorModel != null && cssSectorModel.getBorder() != null) {
                    StyleBorderModel border = cssSectorModel.getBorder();
                    if (border.getColor() != null) {
                        plot.setSectionOutlinePaint(index, border.getColor());
                        plot.setSectionOutlineStroke(index, PropertiesConverter.toStroke(border));
                    }

                }
                if (cssSectorModel != null && cssSectorModel.getColor() != null) {
                    plot.setSectionPaint(index, cssSectorModel.getColor());
                }
            }
        }

    }

}

From source file:org.openfaces.component.chart.impl.plots.PiePlot3DAdapter.java

private void sectorProcessing(PiePlot plot, PieChartView chartView, PieDataset dataset,
        CategoryDataset categoryDataset) {
    java.util.List<PieSectorProperties> sectors = chartView.getSectors();
    if (sectors == null || sectors.size() == 0)
        return;/*from   ww  w .  j  a va  2s  .  com*/

    for (PieSectorProperties sector : sectors) {
        DynamicPieGenerator generator = new DynamicPieGenerator(chartView, null);

        int index = -1;

        Float sectorPulled = sector.getPulled();
        if (dataset instanceof CategoryToPieDataset) {
            CategoryToPieDataset cds = (CategoryToPieDataset) dataset;
            int count = getIterationCount(cds);
            for (int q = 0; q < count; q++) {
                CategoryToPieDataset currPieDataset = new CategoryToPieDataset(categoryDataset, order, q);
                java.util.List keys = currPieDataset.getKeys();
                index = -1;
                for (int j = 0; j < keys.size(); j++) {
                    index++;

                    boolean conditionValue = generator.getConditionValue(sector, q, currPieDataset,
                            currPieDataset.getKey(j));
                    if (!conditionValue)
                        continue;

                    if (sectorPulled != null && sectorPulled > 0) {
                        plot.setExplodePercent(index, (double) sectorPulled);
                    }

                    StyleObjectModel cssSectorModel = sector.getStyleObjectModel();
                    if (cssSectorModel != null && cssSectorModel.getBorder() != null) {
                        StyleBorderModel border = cssSectorModel.getBorder();
                        Color borderColor = border.getColor();
                        if (borderColor != null) {
                            plot.setSectionOutlinePaint(index, borderColor);
                            plot.setSectionOutlineStroke(index, PropertiesConverter.toStroke(border));
                        }

                        Color sectorModelColor = cssSectorModel.getColor();
                        if (sectorModelColor != null) {
                            plot.setSectionPaint(index, sectorModelColor);
                        }
                    }
                }
            }
        } else {
            if (dataset == null || dataset.getKeys() == null)
                continue;

            for (int j = 0; j < dataset.getKeys().size(); j++) {
                index++;

                boolean conditionValue = generator.getConditionValue(sector, 0, dataset, dataset.getKey(j));
                if (!conditionValue)
                    continue;

                if (sectorPulled != null && sectorPulled > 0) {
                    plot.setExplodePercent(index, (double) sectorPulled);
                }

                StyleObjectModel cssSectorModel = sector.getStyleObjectModel();
                if (cssSectorModel != null && cssSectorModel.getBorder() != null) {
                    StyleBorderModel border = cssSectorModel.getBorder();
                    if (border.getColor() != null) {
                        plot.setSectionOutlinePaint(index, border.getColor());
                        plot.setSectionOutlineStroke(index, PropertiesConverter.toStroke(border));
                    }

                }
                if (cssSectorModel != null && cssSectorModel.getColor() != null) {
                    plot.setSectionPaint(index, cssSectorModel.getColor());
                }
            }
        }

    }

}