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

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

Introduction

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

Prototype

public PieSectionLabelGenerator getLabelGenerator() 

Source Link

Document

Returns the section label generator.

Usage

From source file:net.sf.jasperreports.chartthemes.spring.AegeanChartTheme.java

@Override
protected JFreeChart createPieChart() throws JRException {
    JFreeChart jfreeChart = super.createPieChart();

    PiePlot piePlot = (PiePlot) jfreeChart.getPlot();
    JRPiePlot jrPiePlot = (JRPiePlot) getPlot();
    boolean isShowLabels = jrPiePlot.getShowLabels() == null ? true : jrPiePlot.getShowLabels();

    if (isShowLabels && piePlot.getLabelGenerator() != null) {
        piePlot.setLabelBackgroundPaint(ChartThemesConstants.TRANSPARENT_PAINT);
        piePlot.setLabelShadowPaint(ChartThemesConstants.TRANSPARENT_PAINT);
        piePlot.setLabelOutlinePaint(ChartThemesConstants.TRANSPARENT_PAINT);
    }/*from  w ww . j  a v a 2  s .co  m*/
    piePlot.setShadowXOffset(0);
    piePlot.setShadowYOffset(0);
    PieDataset pieDataset = piePlot.getDataset();
    if (pieDataset != null) {
        for (int i = 0; i < pieDataset.getItemCount(); i++) {
            piePlot.setSectionOutlinePaint(pieDataset.getKey(i), ChartThemesConstants.TRANSPARENT_PAINT);

            //makes pie colors darker
            //piePlot.setSectionPaint(pieDataset.getKey(i), GRADIENT_PAINTS[i]);
        }
    }
    piePlot.setCircular(true);
    return jfreeChart;
}

From source file:net.sf.jasperreports.chartthemes.spring.EyeCandySixtiesChartTheme.java

@Override
protected JFreeChart createPieChart() throws JRException {
    JFreeChart jfreeChart = super.createPieChart();
    PiePlot piePlot = (PiePlot) jfreeChart.getPlot();
    JRPiePlot jrPiePlot = (JRPiePlot) getPlot();
    boolean isShowLabels = jrPiePlot.getShowLabels() == null ? true : jrPiePlot.getShowLabels();

    if (isShowLabels && piePlot.getLabelGenerator() != null) {
        piePlot.setLabelBackgroundPaint(ChartThemesConstants.TRANSPARENT_PAINT);
        piePlot.setLabelShadowPaint(ChartThemesConstants.TRANSPARENT_PAINT);
        piePlot.setLabelOutlinePaint(ChartThemesConstants.TRANSPARENT_PAINT);
    }//  w  w  w . j  av a2 s  . c o m
    piePlot.setShadowXOffset(5);
    piePlot.setShadowYOffset(10);
    piePlot.setShadowPaint(new GradientPaint(0, getChart().getHeight() / 2, new Color(41, 120, 162), 0,
            getChart().getHeight(), Color.white));
    PieDataset pieDataset = piePlot.getDataset();
    if (pieDataset != null) {
        for (int i = 0; i < pieDataset.getItemCount(); i++) {
            piePlot.setSectionOutlinePaint(pieDataset.getKey(i), ChartThemesConstants.TRANSPARENT_PAINT);
            //makes pie colors darker
            //piePlot.setSectionPaint(pieDataset.getKey(i), GRADIENT_PAINTS[i]);
        }
    }

    piePlot.setCircular(true);
    return jfreeChart;
}

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

@Override
public void setShowPlotValues(iPlatformComponent chartPanel, ChartDefinition cd) {
    boolean show = cd.isShowPlotLabels();
    ChartInfo info = (ChartInfo) cd.getChartHandlerInfo();

    info.setShowPointLabels(show);//from  w  w  w  . j a  v a  2s.co  m

    Plot plot = info.chart.getPlot();

    if (plot instanceof XYPlot) {
        ((XYPlot) plot).getRenderer().setBaseItemLabelsVisible(show, true);
    } else if (plot instanceof PiePlot) {
        PiePlot p = (PiePlot) plot;

        if (show) {
            p.setLabelGenerator((PieSectionLabelGenerator) info.labelGenerator);
        } else {
            info.labelGenerator = p.getLabelGenerator();
            p.setLabelGenerator(null);
        }
    }
}