KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jfree > chart > demo > CompassDemo2


1 /* ======================================
2  * JFreeChart : a free Java chart library
3  * ======================================
4  *
5  * Project Info: http://www.jfree.org/jfreechart/index.html
6  * Project Lead: David Gilbert (david.gilbert@object-refinery.com);
7  *
8  * (C) Copyright 2000-2003, by Object Refinery Limited and Contributors.
9  *
10  * This library is free software; you can redistribute it and/or modify it under the terms
11  * of the GNU Lesser General Public License as published by the Free Software Foundation;
12  * either version 2.1 of the License, or (at your option) any later version.
13  *
14  * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
15  * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16  * See the GNU Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public License along with this
19  * library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
20  * Boston, MA 02111-1307, USA.
21  *
22  * -----------------
23  * CompassDemo2.java
24  * -----------------
25  * (C) Copyright 2002, 2003 by Object Refinery Limited and Contributors.
26  *
27  * Original Author: David Gilbert (for Object Refinery Limited);
28  * Contributor(s): -;
29  *
30  * $Id: CompassDemo2.java,v 1.2 2003/11/28 10:57:35 mungady Exp $
31  *
32  * Changes
33  * -------
34  * 04-Aug-2003 : Version 1 (DG);
35  *
36  */

37
38 package org.jfree.chart.demo;
39
40 import java.awt.Color JavaDoc;
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 /**
51  * A simple demonstration application showing how to...
52  *
53  * @author David Gilbert
54  */

55 public class CompassDemo2 extends ApplicationFrame {
56
57     /**
58      * Creates a new demo application.
59      *
60      * @param title the frame title.
61      */

62     public CompassDemo2(String JavaDoc title) {
63
64         super(title);
65
66         ValueDataset dataset = new DefaultValueDataset(new Double JavaDoc(45.0));
67         JFreeChart chart = createChart(dataset);
68         
69         // add the chart to a panel...
70
ChartPanel chartPanel = new ChartPanel(chart);
71         chartPanel.setPreferredSize(new java.awt.Dimension JavaDoc(500, 270));
72         chartPanel.setEnforceFileExtensions(false);
73         setContentPane(chartPanel);
74
75     }
76
77     /**
78      * Creates a chart.
79      *
80      * @param dataset the dataset.
81      *
82      * @return The chart.
83      */

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     // ****************************************************************************
96
// * COMMERCIAL SUPPORT / JFREECHART DEVELOPER GUIDE *
97
// * Please note that commercial support and documentation is available from: *
98
// * *
99
// * http://www.object-refinery.com/jfreechart/support.html *
100
// * *
101
// * This is not only a great service for developers, but is a VERY IMPORTANT *
102
// * source of funding for the JFreeChart project. Please support us so that *
103
// * we can continue developing free software. *
104
// ****************************************************************************
105

106     /**
107      * Starting point for the demonstration application.
108      *
109      * @param args ignored.
110      */

111     public static void main(String JavaDoc[] 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