List of usage examples for org.jfree.chart.plot PiePlot setBackgroundImage
public void setBackgroundImage(Image image)
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; }