KickJava   Java API By Example, From Geeks To Geeks.

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


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-2002, 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  * SampleSIgnalDataset.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: SampleSignalDataset.java,v 1.3 2003/06/12 16:54:10 mungady Exp $
31  *
32  * Changes (since 11-Oct-2002)
33  * ---------------------------
34  * 11-Oct-2002 : Added Javadocs;
35  *
36  */

37
38
39 package org.jfree.chart.demo;
40
41 import org.jfree.data.AbstractDataset;
42 import org.jfree.data.DatasetChangeListener;
43 import org.jfree.data.HighLowDataset;
44 import org.jfree.data.SignalsDataset;
45
46 /**
47  * A sample signal dataset.
48  *
49  * @author ??
50  */

51 public class SampleSignalDataset extends AbstractDataset implements SignalsDataset {
52
53     /** The data. */
54     private HighLowDataset data;
55
56     /**
57      * Default constructor.
58      */

59     public SampleSignalDataset() {
60         this.data = DemoDatasetFactory.createHighLowDataset();
61     }
62
63     /**
64      * Returns the number of items in a series.
65      *
66      * @param series the series (zero-based index).
67      *
68      * @return the number of items within the series.
69      */

70     public int getItemCount(int series) {
71         return data.getItemCount(series);
72     }
73
74     /**
75      * Returns the number of series in the dataset.
76      *
77      * @return the series count.
78      */

79     public int getSeriesCount() {
80         return data.getSeriesCount();
81     }
82
83     /**
84      * Returns the name of a series.
85      *
86      * @param series the series (zero-based index).
87      *
88      * @return the name of the series.
89      */

90     public String JavaDoc getSeriesName(int series) {
91         return data.getSeriesName(series);
92     }
93
94     /**
95      * Returns the x-value for an item within a series.
96      * <P>
97      * The implementation is responsible for ensuring that the x-values are
98      * presented in ascending order.
99      *
100      * @param series the series (zero-based index).
101      * @param item the item (zero-based index).
102      *
103      * @return the x-value.
104      */

105     public Number JavaDoc getXValue(int series, int item) {
106         return data.getXValue(series, item);
107     }
108
109     /**
110      * Returns the y-value for an item within a series.
111      *
112      * @param series the series (zero-based index).
113      * @param item the item (zero-based index).
114      *
115      * @return the y-value.
116      */

117     public Number JavaDoc getYValue(int series, int item) {
118         return data.getYValue(series, item);
119     }
120
121     /**
122      * Returns the type.
123      *
124      * @param series the series (zero-based index).
125      * @param item the item (zero-based index).
126      *
127      * @return the type.
128      */

129     public int getType(int series, int item) {
130         return SignalsDataset.ENTER_LONG;
131     }
132
133     /**
134      * Returns the level.
135      *
136      * @param series the series (zero-based index).
137      * @param item the item (zero-based index).
138      *
139      * @return the level.
140      */

141     public double getLevel(int series, int item) {
142         return getXValue(series, item).doubleValue();
143     }
144
145     /**
146      * Registers an object to receive notification of changes to the dataset.
147      *
148      * @param listener the object to register.
149      */

150     public void addChangeListener(DatasetChangeListener listener) {
151         data.addChangeListener(listener);
152     }
153
154     /**
155      * Deregisters an object so that it no longer receives notification of changes to the dataset.
156      *
157      * @param listener the object to deregister.
158      */

159     public void removeChangeListener(DatasetChangeListener listener) {
160         data.removeChangeListener(listener);
161     }
162
163 }
164
Popular Tags