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

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

Introduction

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

Prototype

public void setBackgroundImage(Image image) 

Source Link

Document

Sets the background image for the plot and sends a PlotChangeEvent to all registered listeners.

Usage

From source file:org.jfree.chart.demo.JFreeChartDemoBase.java

/**
 * Creates and returns a sample pie chart.
 *
 * @return a sample pie chart.//from ww w .  ja v a2s. c o  m
 */
public JFreeChart createPieChartTwo() {

    // create a default chart based on some sample data...
    final String title = this.resources.getString("pie.pie2.title");
    final CategoryDataset data = DemoDatasetFactory.createCategoryDataset();
    final Comparable category = (Comparable) data.getColumnKeys().get(1);
    final PieDataset extracted = DatasetUtilities.createPieDatasetForColumn(data, category);
    final JFreeChart chart = ChartFactory.createPieChart(title, extracted, true, true, false);

    // then customise it a little...
    chart.setBackgroundPaint(Color.lightGray);
    final PiePlot pie = (PiePlot) chart.getPlot();
    pie.setLabelGenerator(new StandardPieItemLabelGenerator("{0} = {2}", NumberFormat.getNumberInstance(),
            NumberFormat.getPercentInstance()));
    pie.setBackgroundImage(JFreeChart.INFO.getLogo());
    pie.setBackgroundPaint(Color.white);
    pie.setBackgroundAlpha(0.6f);
    pie.setForegroundAlpha(0.75f);
    return chart;

}