KickJava   Java API By Example, From Geeks To Geeks.

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


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

37
38 package org.jfree.chart.demo;
39
40 import org.jfree.chart.ChartPanel;
41 import org.jfree.chart.JFreeChart;
42 import org.jfree.chart.axis.NumberAxis;
43 import org.jfree.chart.plot.PlotOrientation;
44 import org.jfree.chart.plot.XYPlot;
45 import org.jfree.chart.renderer.StandardXYItemRenderer;
46 import org.jfree.chart.renderer.XYItemRenderer;
47 import org.jfree.data.XYDataset;
48 import org.jfree.data.XYSeries;
49 import org.jfree.data.XYSeriesCollection;
50 import org.jfree.ui.ApplicationFrame;
51 import org.jfree.ui.RefineryUtilities;
52
53 /**
54  * This demo shows the use of the {@link ReverseXYItemRenderer} to plot water temperature at
55  * various depths.
56  *
57  * @author David Gilbert
58  */

59 public class WaterTemperatureDemo extends ApplicationFrame {
60
61     /**
62      * A demonstration application showing an XY series containing a null value.
63      *
64      * @param title the frame title.
65      */

66     public WaterTemperatureDemo(String JavaDoc title) {
67
68         super(title);
69         XYDataset dataset = createDataset();
70
71         NumberAxis rangeAxis = new NumberAxis("Temperature");
72         rangeAxis.setRange(-0.55, -0.15);
73
74         NumberAxis domainAxis = new NumberAxis("Depth");
75         domainAxis.setInverted(true);
76         domainAxis.setRange(0.0, 35.0);
77         domainAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
78
79         XYItemRenderer renderer = new StandardXYItemRenderer();
80
81         XYPlot plot = new XYPlot(dataset, domainAxis, rangeAxis, renderer);
82         plot.setOrientation(PlotOrientation.HORIZONTAL);
83         JFreeChart chart = new JFreeChart("Water Temperature By Depth", plot);
84
85         ChartPanel chartPanel = new ChartPanel(chart);
86         chartPanel.setPreferredSize(new java.awt.Dimension JavaDoc(500, 270));
87         setContentPane(chartPanel);
88
89     }
90
91     /**
92      * Creates a sample dataset.
93      *
94      * @return The dataset.
95      */

96     private XYDataset createDataset() {
97
98         XYSeries series = new XYSeries("Zone 1");
99         series.add(1.0, -0.5);
100         series.add(5.0, -0.5);
101         series.add(10.0, -0.4);
102         series.add(15.0, -0.4);
103         series.add(20.0, -0.3);
104         series.add(25.0, -0.3);
105         series.add(30.0, -0.2);
106         series.add(35.0, -0.2);
107
108         return new XYSeriesCollection(series);
109
110     }
111
112     // ****************************************************************************
113
// * COMMERCIAL SUPPORT / JFREECHART DEVELOPER GUIDE *
114
// * Please note that commercial support and documentation is available from: *
115
// * *
116
// * http://www.object-refinery.com/jfreechart/support.html *
117
// * *
118
// * This is not only a great service for developers, but is a VERY IMPORTANT *
119
// * source of funding for the JFreeChart project. Please support us so that *
120
// * we can continue developing free software. *
121
// ****************************************************************************
122

123     /**
124      * Starting point for the demonstration application.
125      *
126      * @param args ignored.
127      */

128     public static void main(String JavaDoc[] args) {
129
130         WaterTemperatureDemo demo = new WaterTemperatureDemo("Water Temperature Demo");
131         demo.pack();
132         RefineryUtilities.centerFrameOnScreen(demo);
133         demo.setVisible(true);
134
135     }
136
137 }
138
Popular Tags