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

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

Introduction

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

Prototype

public void setBaseSectionPaint(Paint paint) 

Source Link

Document

Sets the base section paint and sends a PlotChangeEvent to all registered listeners.

Usage

From source file:fr.inria.soctrace.framesoc.ui.piechart.view.StatisticsPieChartView.java

/**
 * Creates the chart./* w  ww . ja v  a  2  s  .co m*/
 * 
 * @param dataset
 *            the dataset.
 * @param loader
 *            the pie chart loader
 * @param dataRequested
 *            flag indicating if the data have been requested for the current loader and the
 *            current interval
 * @return the pie chart
 */
private JFreeChart createChart(PieDataset dataset, String title, IPieChartLoader loader,
        boolean dataRequested) {

    JFreeChart chart = ChartFactory.createPieChart(title, dataset, HAS_LEGEND, HAS_TOOLTIPS, HAS_URLS);

    // legend
    if (HAS_LEGEND) {
        LegendTitle legend = chart.getLegend();
        legend.setPosition(RectangleEdge.LEFT);
    }

    // plot
    PiePlot plot = (PiePlot) chart.getPlot();
    plot.setSectionOutlinesVisible(false);
    plot.setLabelFont(new Font("SansSerif", Font.PLAIN, 12));
    plot.setNoDataMessage(
            "No data available " + (dataRequested ? "in this time interval" : "yet. Press the Load button."));
    plot.setCircular(true);
    plot.setLabelGenerator(null); // hide labels
    plot.setBackgroundPaint(Color.WHITE);
    plot.setOutlineVisible(false);
    plot.setShadowPaint(Color.WHITE);
    plot.setBaseSectionPaint(Color.WHITE);
    StandardPieToolTipGenerator g = (StandardPieToolTipGenerator) plot.getToolTipGenerator();
    NumberFormat format = ValueLabelProvider.getActualFormat(loader.getFormat(), getTimeUnit());
    StandardPieToolTipGenerator sg = new StandardPieToolTipGenerator(g.getLabelFormat(), format,
            g.getPercentFormat());
    plot.setToolTipGenerator(sg);

    for (Object o : dataset.getKeys()) {
        String key = (String) o;
        plot.setSectionPaint(key, loader.getColor(key).getAwtColor());
    }
    return chart;
}