KickJava   Java API By Example, From Geeks To Geeks.

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


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  * ThermometerDemo2.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: ThermometerDemo2.java,v 1.3 2003/11/28 10:57:35 mungady Exp $
31  *
32  * Changes
33  * -------
34  * 17-Sep-2002 : Version 1 (DG);
35  * 11-Oct-2002 : Fixed errors reported by Checkstyle (DG);
36  *
37  */

38
39 package org.jfree.chart.demo;
40
41 import java.awt.BasicStroke JavaDoc;
42 import java.awt.Color JavaDoc;
43 import java.awt.Insets JavaDoc;
44
45 import org.jfree.chart.ChartPanel;
46 import org.jfree.chart.JFreeChart;
47 import org.jfree.chart.plot.ThermometerPlot;
48 import org.jfree.data.DefaultValueDataset;
49 import org.jfree.ui.ApplicationFrame;
50
51 /**
52  * A simple demonstration application showing how to create a thermometer.
53  *
54  * @author David Gilbert
55  */

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

63     public ThermometerDemo2(String JavaDoc title) {
64
65         super(title);
66
67         // create a dataset...
68
DefaultValueDataset dataset = new DefaultValueDataset(new Double JavaDoc(43.0));
69
70         // create the chart...
71
ThermometerPlot plot = new ThermometerPlot(dataset);
72         JFreeChart chart = new JFreeChart("Thermometer Demo 2", // chart title
73
JFreeChart.DEFAULT_TITLE_FONT,
74                                           plot, // plot
75
false); // include legend
76

77
78         // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART...
79
plot.setInsets(new Insets JavaDoc(5, 5, 5, 5));
80         //plot.setRangeInfo(ThermometerPlot.NORMAL, 0.0, 55.0, 0.0, 100.0);
81
//plot.setRangeInfo(ThermometerPlot.WARNING, 55.0, 75.0, 0.0, 100.0);
82
//plot.setRangeInfo(ThermometerPlot.CRITICAL, 75.0, 100.0, 0.0, 100.0);
83

84         plot.setThermometerStroke(new BasicStroke JavaDoc(2.0f));
85         plot.setThermometerPaint(Color.lightGray);
86         // OPTIONAL CUSTOMISATION COMPLETED.
87

88         // add the chart to a panel...
89
ChartPanel chartPanel = new ChartPanel(chart);
90         setContentPane(chartPanel);
91
92     }
93
94     // ****************************************************************************
95
// * COMMERCIAL SUPPORT / JFREECHART DEVELOPER GUIDE *
96
// * Please note that commercial support and documentation is available from: *
97
// * *
98
// * http://www.object-refinery.com/jfreechart/support.html *
99
// * *
100
// * This is not only a great service for developers, but is a VERY IMPORTANT *
101
// * source of funding for the JFreeChart project. Please support us so that *
102
// * we can continue developing free software. *
103
// ****************************************************************************
104

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

110     public static void main(String JavaDoc[] args) {
111
112         ThermometerDemo2 demo = new ThermometerDemo2("Thermometer Demo 2");
113         demo.pack();
114         demo.setVisible(true);
115
116     }
117
118 }
119
Popular Tags