1 37 38 package org.jfree.chart.demo; 39 40 import java.awt.Color ; 41 42 import org.jfree.chart.ChartPanel; 43 import org.jfree.chart.JFreeChart; 44 import org.jfree.chart.plot.CompassPlot; 45 import org.jfree.data.DefaultValueDataset; 46 import org.jfree.data.ValueDataset; 47 import org.jfree.ui.ApplicationFrame; 48 import org.jfree.ui.RefineryUtilities; 49 50 55 public class CompassDemo2 extends ApplicationFrame { 56 57 62 public CompassDemo2(String title) { 63 64 super(title); 65 66 ValueDataset dataset = new DefaultValueDataset(new Double (45.0)); 67 JFreeChart chart = createChart(dataset); 68 69 ChartPanel chartPanel = new ChartPanel(chart); 71 chartPanel.setPreferredSize(new java.awt.Dimension (500, 270)); 72 chartPanel.setEnforceFileExtensions(false); 73 setContentPane(chartPanel); 74 75 } 76 77 84 private JFreeChart createChart(ValueDataset dataset) { 85 86 CompassPlot plot = new CompassPlot(dataset); 87 plot.setSeriesNeedle(7); 88 plot.setSeriesPaint(0, Color.red); 89 plot.setSeriesOutlinePaint(0, Color.red); 90 JFreeChart chart = new JFreeChart(plot); 91 return chart; 92 93 } 94 95 106 111 public static void main(String [] args) { 112 113 CompassDemo2 demo = new CompassDemo2("Compass Demo 2"); 114 demo.pack(); 115 RefineryUtilities.centerFrameOnScreen(demo); 116 demo.setVisible(true); 117 118 } 119 120 } 121 | Popular Tags |