KickJava   Java API By Example, From Geeks To Geeks.

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


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  * WindChartDemo.java
24  * ------------------
25  * (C) Copyright 2003 by Object Refinery Limited and Contributors.
26  *
27  * Original Author: David Gilbert (for Object Refinery Limited);
28  * Contributor(s): -;
29  *
30  * $Id: WindChartDemo.java,v 1.2 2003/11/28 10:57:36 mungady Exp $
31  *
32  * Changes
33  * -------
34  * 30-Jun-2003 : Version 1 (DG);
35  *
36  */

37
38 package org.jfree.chart.demo;
39
40 import java.awt.Color JavaDoc;
41 import java.awt.GradientPaint JavaDoc;
42
43 import org.jfree.chart.ChartFactory;
44 import org.jfree.chart.ChartPanel;
45 import org.jfree.chart.JFreeChart;
46 import org.jfree.data.WindDataset;
47 import org.jfree.ui.ApplicationFrame;
48 import org.jfree.ui.RefineryUtilities;
49
50 /**
51  * A simple demonstration application showing how to create a wind chart.
52  *
53  * @author David Gilbert
54  */

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

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

85     private JFreeChart createChart(WindDataset dataset) {
86         
87         JFreeChart chart = ChartFactory.createWindPlot(
88             "Wind Chart Demo",
89             "Date",
90             "Direction / Force",
91             dataset,
92             true,
93             false,
94             false
95         );
96
97         // then customise it a little...
98
chart.setBackgroundPaint(new GradientPaint JavaDoc(0, 0, Color.white, 1000, 0, Color.green));
99         return chart;
100         
101     }
102
103     // ****************************************************************************
104
// * COMMERCIAL SUPPORT / JFREECHART DEVELOPER GUIDE *
105
// * Please note that commercial support and documentation is available from: *
106
// * *
107
// * http://www.object-refinery.com/jfreechart/support.html *
108
// * *
109
// * This is not only a great service for developers, but is a VERY IMPORTANT *
110
// * source of funding for the JFreeChart project. Please support us so that *
111
// * we can continue developing free software. *
112
// ****************************************************************************
113

114     /**
115      * Starting point for the demonstration application.
116      *
117      * @param args ignored.
118      */

119     public static void main(String JavaDoc[] args) {
120
121         WindChartDemo demo = new WindChartDemo("Wind Chart Demo");
122         demo.pack();
123         RefineryUtilities.centerFrameOnScreen(demo);
124         demo.setVisible(true);
125
126     }
127
128 }
129
Popular Tags