KickJava   Java API By Example, From Geeks To Geeks.

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


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  * SimpleIntervalXYDataset.java
24  * ----------------------------
25  * (C) Copyright 2002, by Object Refinery Limited and Contributors.
26  *
27  * Original Author: David Gilbert (for Object Refinery Limited);
28  * Contributor(s): -;
29  *
30  * $Id: SimpleIntervalXYDataset.java,v 1.4 2003/06/30 12:14:34 mungady Exp $
31  *
32  * Changes (since 11-Oct-2002)
33  * ---------------------------
34  * 11-Oct-2002 : Fixed errors reported by Checkstyle (DG);
35  *
36  */

37
38 package org.jfree.chart.demo;
39
40 import org.jfree.data.AbstractDataset;
41 import org.jfree.data.DatasetChangeListener;
42 import org.jfree.data.IntervalXYDataset;
43
44 /**
45  * A quick and dirty sample dataset.
46  *
47  * @author David Gilbert
48  */

49 public class SimpleIntervalXYDataset extends AbstractDataset implements IntervalXYDataset {
50
51     /** The start values. */
52     private Double JavaDoc[] xStart = new Double JavaDoc[3];
53     
54     /** The end values. */
55     private Double JavaDoc[] xEnd = new Double JavaDoc[3];
56
57     /** The y values. */
58     private Double JavaDoc[] y = new Double JavaDoc[3];
59
60     /**
61      * Creates a new dataset.
62      */

63     public SimpleIntervalXYDataset() {
64
65         xStart[0] = new Double JavaDoc(0.0);
66         xStart[1] = new Double JavaDoc(2.0);
67         xStart[2] = new Double JavaDoc(3.5);
68
69         xEnd[0] = new Double JavaDoc(2.0);
70         xEnd[1] = new Double JavaDoc(3.5);
71         xEnd[2] = new Double JavaDoc(4.0);
72
73         y[0] = new Double JavaDoc(3.0);
74         y[1] = new Double JavaDoc(4.5);
75         y[2] = new Double JavaDoc(2.5);
76     }
77
78     /**
79      * Returns the number of series in the dataset.
80      *
81      * @return the number of series in the dataset.
82      */

83     public int getSeriesCount() {
84         return 1;
85     }
86
87     /**
88      * Returns the name of a series.
89      *
90      * @param series the series (zero-based index).
91      *
92      * @return the series name.
93      */

94     public String JavaDoc getSeriesName(int series) {
95         return "Series 1";
96     }
97
98     /**
99      * Returns the number of items in a series.
100      *
101      * @param series the series (zero-based index).
102      *
103      * @return the number of items within a series.
104      */

105     public int getItemCount(int series) {
106         return 3;
107     }
108
109     /**
110      * Returns the x-value for an item within a series.
111      * <P>
112      * The implementation is responsible for ensuring that the x-values are presented in ascending
113      * order.
114      *
115      * @param series the series (zero-based index).
116      * @param item the item (zero-based index).
117      *
118      * @return the x-value for an item within a series.
119      */

120     public Number JavaDoc getXValue(int series, int item) {
121         return xStart[item];
122     }
123
124     /**
125      * Returns the y-value for an item within a series.
126      *
127      * @param series the series (zero-based index).
128      * @param item the item (zero-based index).
129      *
130      * @return the y-value for an item within a series.
131      */

132     public Number JavaDoc getYValue(int series, int item) {
133         return y[item];
134     }
135
136     /**
137      * Returns the starting X value for the specified series and item.
138      *
139      * @param series the series (zero-based index).
140      * @param item the item within a series (zero-based index).
141      *
142      * @return the start x value.
143      */

144     public Number JavaDoc getStartXValue(int series, int item) {
145         return xStart[item];
146     }
147
148     /**
149      * Returns the ending X value for the specified series and item.
150      *
151      * @param series the series (zero-based index).
152      * @param item the item within a series (zero-based index).
153      *
154      * @return the end x value.
155      */

156     public Number JavaDoc getEndXValue(int series, int item) {
157         return xEnd[item];
158     }
159
160     /**
161      * Returns the starting Y value for the specified series and item.
162      *
163      * @param series the series (zero-based index).
164      * @param item the item within a series (zero-based index).
165      *
166      * @return the start y value.
167      */

168     public Number JavaDoc getStartYValue(int series, int item) {
169         return y[item];
170     }
171
172     /**
173      * Returns the ending Y value for the specified series and item.
174      *
175      * @param series the series (zero-based index).
176      * @param item the item within a series (zero-based index).
177      *
178      * @return the end y value.
179      */

180     public Number JavaDoc getEndYValue(int series, int item) {
181         return y[item];
182     }
183
184     /**
185      * Registers an object for notification of changes to the dataset.
186      *
187      * @param listener the object to register.
188      */

189     public void addChangeListener(DatasetChangeListener listener) {
190     }
191
192     /**
193      * Deregisters an object for notification of changes to the dataset.
194      *
195      * @param listener the object to deregister.
196      */

197     public void removeChangeListener(DatasetChangeListener listener) {
198     }
199
200 }
201
Popular Tags