KickJava   Java API By Example, From Geeks To Geeks.

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


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  * XYSeriesDemo.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: XYSeriesDemo.java,v 1.8 2003/11/28 10:57:36 mungady Exp $
31  *
32  * Changes
33  * -------
34  * 08-Apr-2002 : Version 1 (DG);
35  * 11-Jun-2002 : Inserted value out of order to see that it works (DG);
36  * 11-Oct-2002 : Fixed issues reported by Checkstyle (DG);
37  *
38  */

39
40 package org.jfree.chart.demo;
41
42 import org.jfree.chart.ChartFactory;
43 import org.jfree.chart.ChartPanel;
44 import org.jfree.chart.JFreeChart;
45 import org.jfree.chart.plot.PlotOrientation;
46 import org.jfree.data.XYSeries;
47 import org.jfree.data.XYSeriesCollection;
48 import org.jfree.ui.ApplicationFrame;
49 import org.jfree.ui.RefineryUtilities;
50
51 /**
52  * A simple demo showing a dataset created using the {@link XYSeriesCollection} class.
53  *
54  * @author David Gilbert
55  */

56 public class XYSeriesDemo extends ApplicationFrame {
57
58     /**
59      * A demonstration application showing an XY series containing a null value.
60      *
61      * @param title the frame title.
62      */

63     public XYSeriesDemo(String JavaDoc title) {
64
65         super(title);
66         XYSeries series = new XYSeries("Random Data");
67         series.add(1.0, 500.2);
68         series.add(5.0, 694.1);
69         series.add(4.0, 100.0);
70         series.add(12.5, 734.4);
71         series.add(17.3, 453.2);
72         series.add(21.2, 500.2);
73         series.add(21.9, null);
74         series.add(25.6, 734.4);
75         series.add(30.0, 453.2);
76         XYSeriesCollection data = new XYSeriesCollection(series);
77         JFreeChart chart = ChartFactory.createXYLineChart(
78             "XY Series Demo",
79             "X",
80             "Y",
81             data,
82             PlotOrientation.VERTICAL,
83             true,
84             true,
85             false
86         );
87
88         ChartPanel chartPanel = new ChartPanel(chart);
89         chartPanel.setPreferredSize(new java.awt.Dimension JavaDoc(500, 270));
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         XYSeriesDemo demo = new XYSeriesDemo("XY Series Demo");
113         demo.pack();
114         RefineryUtilities.centerFrameOnScreen(demo);
115         demo.setVisible(true);
116
117     }
118
119 }
120
Popular Tags