KickJava   Java API By Example, From Geeks To Geeks.

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


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  * YIntervalChartDemo.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: YIntervalChartDemo.java,v 1.2 2003/11/28 10:57:33 mungady Exp $
31  *
32  * Changes
33  * -------
34  * 27-Jun-2003 : Version 1 (DG);
35  *
36  */

37
38 package org.jfree.chart.demo;
39
40 import org.jfree.chart.ChartFactory;
41 import org.jfree.chart.ChartPanel;
42 import org.jfree.chart.JFreeChart;
43 import org.jfree.chart.plot.PlotOrientation;
44 import org.jfree.chart.plot.XYPlot;
45 import org.jfree.chart.renderer.YIntervalRenderer;
46 import org.jfree.data.IntervalXYDataset;
47 import org.jfree.ui.ApplicationFrame;
48 import org.jfree.ui.RefineryUtilities;
49
50 /**
51  * A simple demonstration application showing how to create a Y Interval Chart.
52  *
53  * @author David Gilbert
54  */

55 public class YIntervalChartDemo extends ApplicationFrame {
56
57     /**
58      * Constructs the demo application.
59      *
60      * @param title the frame title.
61      */

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

86     private JFreeChart createChart(IntervalXYDataset dataset) {
87     
88         JFreeChart chart = ChartFactory.createScatterPlot(
89             "Y Interval Chart Demo", // chart title
90
"X", // domain axis label
91
"Y", // range axis label
92
dataset, // data
93
PlotOrientation.VERTICAL,
94             true, // include legend
95
true,
96             false
97         );
98
99         XYPlot plot = chart.getXYPlot();
100         plot.setRenderer(new YIntervalRenderer());
101         
102         return chart;
103         
104     }
105     
106     // ****************************************************************************
107
// * COMMERCIAL SUPPORT / JFREECHART DEVELOPER GUIDE *
108
// * Please note that commercial support and documentation is available from: *
109
// * *
110
// * http://www.object-refinery.com/jfreechart/support.html *
111
// * *
112
// * This is not only a great service for developers, but is a VERY IMPORTANT *
113
// * source of funding for the JFreeChart project. Please support us so that *
114
// * we can continue developing free software. *
115
// ****************************************************************************
116

117     /**
118      * Starting point for the demonstration application.
119      *
120      * @param args ignored.
121      */

122     public static void main(String JavaDoc[] args) {
123
124         YIntervalChartDemo demo = new YIntervalChartDemo("Y Interval Chart Demo");
125         demo.pack();
126         RefineryUtilities.centerFrameOnScreen(demo);
127         demo.setVisible(true);
128
129     }
130
131 }
132
Popular Tags