1 37 38 package org.jfree.chart.demo; 39 40 import java.awt.Color ; 41 import java.awt.Font ; 42 43 import org.jfree.chart.ChartFactory; 44 import org.jfree.chart.ChartPanel; 45 import org.jfree.chart.JFreeChart; 46 import org.jfree.chart.plot.PiePlot; 47 import org.jfree.data.DefaultPieDataset; 48 import org.jfree.ui.ApplicationFrame; 49 import org.jfree.ui.RefineryUtilities; 50 51 56 public class PieChartDemo3 extends ApplicationFrame { 57 58 63 public PieChartDemo3(String title) { 64 65 super(title); 66 67 DefaultPieDataset data = new DefaultPieDataset(); 69 70 JFreeChart chart = ChartFactory.createPieChart("Pie Chart Demo 3", data, true, true, 75 false 76 ); 77 78 PiePlot plot = (PiePlot) chart.getPlot(); 79 plot.setNoDataMessage("No data available"); 80 plot.setNoDataMessageFont(new Font ("Serif", Font.ITALIC, 10)); 81 plot.setNoDataMessagePaint(Color.red); 82 83 ChartPanel chartPanel = new ChartPanel(chart); 85 chartPanel.setPreferredSize(new java.awt.Dimension (500, 270)); 86 setContentPane(chartPanel); 87 88 } 89 90 101 106 public static void main(String [] args) { 107 108 PieChartDemo3 demo = new PieChartDemo3("Pie Chart Demo 3"); 109 demo.pack(); 110 RefineryUtilities.centerFrameOnScreen(demo); 111 demo.setVisible(true); 112 113 } 114 115 } 116 | Popular Tags |