Source Code Cross Referenced for VectorSeriesCollection.java in  » Chart » jfreechart » org » jfree » data » xy » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Chart » jfreechart » org.jfree.data.xy 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /* ===========================================================
002:         * JFreeChart : a free chart library for the Java(tm) platform
003:         * ===========================================================
004:         *
005:         * (C) Copyright 2000-2007, by Object Refinery Limited and Contributors.
006:         *
007:         * Project Info:  http://www.jfree.org/jfreechart/index.html
008:         *
009:         * This library is free software; you can redistribute it and/or modify it 
010:         * under the terms of the GNU Lesser General Public License as published by 
011:         * the Free Software Foundation; either version 2.1 of the License, or 
012:         * (at your option) any later version.
013:         *
014:         * This library is distributed in the hope that it will be useful, but 
015:         * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 
016:         * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 
017:         * License for more details.
018:         *
019:         * You should have received a copy of the GNU Lesser General Public
020:         * License along with this library; if not, write to the Free Software
021:         * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, 
022:         * USA.  
023:         *
024:         * [Java is a trademark or registered trademark of Sun Microsystems, Inc. 
025:         * in the United States and other countries.]
026:         *
027:         * ---------------------------
028:         * VectorSeriesCollection.java
029:         * ---------------------------
030:         * (C) Copyright 2007, by Object Refinery Limited.
031:         *
032:         * Original Author:  David Gilbert (for Object Refinery Limited);
033:         * Contributor(s):   -;
034:         *
035:         * $Id: VectorSeriesCollection.java,v 1.1.2.1 2007/05/25 14:44:38 mungady Exp $
036:         *
037:         * Changes
038:         * -------
039:         * 30-Jan-2007 : Version 1 (DG);
040:         * 24-May-2007 : Added indexOf(), removeSeries() and removeAllSeries() 
041:         *               methods (DG);
042:         * 25-May-2007 : Moved from experimental to the main source tree (DG);
043:         *
044:         */
045:
046:        package org.jfree.data.xy;
047:
048:        import java.io.Serializable;
049:        import java.util.List;
050:
051:        import org.jfree.data.general.DatasetChangeEvent;
052:        import org.jfree.util.ObjectUtilities;
053:
054:        /**
055:         * A collection of {@link VectorSeries} objects.
056:         * 
057:         * @since 1.0.6
058:         */
059:        public class VectorSeriesCollection extends AbstractXYDataset implements 
060:                VectorXYDataset, Serializable {
061:
062:            /** Storage for the data series. */
063:            private List data;
064:
065:            /** 
066:             * Creates a new instance of <code>VectorSeriesCollection</code>. 
067:             */
068:            public VectorSeriesCollection() {
069:                this .data = new java.util.ArrayList();
070:            }
071:
072:            /**
073:             * Adds a series to the collection and sends a {@link DatasetChangeEvent} 
074:             * to all registered listeners.
075:             *
076:             * @param series  the series (<code>null</code> not permitted).
077:             */
078:            public void addSeries(VectorSeries series) {
079:                if (series == null) {
080:                    throw new IllegalArgumentException(
081:                            "Null 'series' argument.");
082:                }
083:                this .data.add(series);
084:                series.addChangeListener(this );
085:                fireDatasetChanged();
086:            }
087:
088:            /**
089:             * Removes the specified series from the collection and sends a 
090:             * {@link DatasetChangeEvent} to all registered listeners.
091:             *
092:             * @param series  the series (<code>null</code> not permitted).
093:             * 
094:             * @return A boolean indicating whether the series has actually been 
095:             *         removed.
096:             */
097:            public boolean removeSeries(VectorSeries series) {
098:                if (series == null) {
099:                    throw new IllegalArgumentException(
100:                            "Null 'series' argument.");
101:                }
102:                boolean removed = this .data.remove(series);
103:                if (removed) {
104:                    series.removeChangeListener(this );
105:                    fireDatasetChanged();
106:                }
107:                return removed;
108:            }
109:
110:            /**
111:             * Removes all the series from the collection and sends a 
112:             * {@link DatasetChangeEvent} to all registered listeners.
113:             */
114:            public void removeAllSeries() {
115:
116:                // deregister the collection as a change listener to each series in the
117:                // collection
118:                for (int i = 0; i < this .data.size(); i++) {
119:                    VectorSeries series = (VectorSeries) this .data.get(i);
120:                    series.removeChangeListener(this );
121:                }
122:
123:                // remove all the series from the collection and notify listeners.
124:                this .data.clear();
125:                fireDatasetChanged();
126:
127:            }
128:
129:            /**
130:             * Returns the number of series in the collection.
131:             *
132:             * @return The series count.
133:             */
134:            public int getSeriesCount() {
135:                return this .data.size();
136:            }
137:
138:            /**
139:             * Returns a series from the collection.
140:             *
141:             * @param series  the series index (zero-based).
142:             *
143:             * @return The series.
144:             * 
145:             * @throws IllegalArgumentException if <code>series</code> is not in the
146:             *     range <code>0</code> to <code>getSeriesCount() - 1</code>.
147:             */
148:            public VectorSeries getSeries(int series) {
149:                if ((series < 0) || (series >= getSeriesCount())) {
150:                    throw new IllegalArgumentException(
151:                            "Series index out of bounds");
152:                }
153:                return (VectorSeries) this .data.get(series);
154:            }
155:
156:            /**
157:             * Returns the key for a series.
158:             *
159:             * @param series  the series index (in the range <code>0</code> to 
160:             *     <code>getSeriesCount() - 1</code>).
161:             *
162:             * @return The key for a series.
163:             * 
164:             * @throws IllegalArgumentException if <code>series</code> is not in the
165:             *     specified range.
166:             */
167:            public Comparable getSeriesKey(int series) {
168:                // defer argument checking
169:                return getSeries(series).getKey();
170:            }
171:
172:            /**
173:             * Returns the index of the specified series, or -1 if that series is not
174:             * present in the dataset.
175:             * 
176:             * @param series  the series (<code>null</code> not permitted).
177:             * 
178:             * @return The series index.
179:             */
180:            public int indexOf(VectorSeries series) {
181:                if (series == null) {
182:                    throw new IllegalArgumentException(
183:                            "Null 'series' argument.");
184:                }
185:                return this .data.indexOf(series);
186:            }
187:
188:            /**
189:             * Returns the number of items in the specified series.
190:             *
191:             * @param series  the series (zero-based index).
192:             *
193:             * @return The item count.
194:             * 
195:             * @throws IllegalArgumentException if <code>series</code> is not in the
196:             *     range <code>0</code> to <code>getSeriesCount() - 1</code>.
197:             */
198:            public int getItemCount(int series) {
199:                // defer argument checking
200:                return getSeries(series).getItemCount();
201:            }
202:
203:            /**
204:             * Returns the x-value for an item within a series.
205:             *
206:             * @param series  the series index.
207:             * @param item  the item index.
208:             *
209:             * @return The x-value.
210:             */
211:            public double getXValue(int series, int item) {
212:                VectorSeries s = (VectorSeries) this .data.get(series);
213:                VectorDataItem di = (VectorDataItem) s.getDataItem(item);
214:                return di.getXValue();
215:            }
216:
217:            /**
218:             * Returns the x-value for an item within a series.  Note that this method
219:             * creates a new {@link Double} instance every time it is called---use
220:             * {@link #getXValue(int, int)} instead, if possible.
221:             *
222:             * @param series  the series index.
223:             * @param item  the item index.
224:             *
225:             * @return The x-value.
226:             */
227:            public Number getX(int series, int item) {
228:                return new Double(getXValue(series, item));
229:            }
230:
231:            /**
232:             * Returns the y-value for an item within a series.
233:             *
234:             * @param series  the series index.
235:             * @param item  the item index.
236:             *
237:             * @return The y-value.
238:             */
239:            public double getYValue(int series, int item) {
240:                VectorSeries s = (VectorSeries) this .data.get(series);
241:                VectorDataItem di = (VectorDataItem) s.getDataItem(item);
242:                return di.getYValue();
243:            }
244:
245:            /**
246:             * Returns the y-value for an item within a series.  Note that this method
247:             * creates a new {@link Double} instance every time it is called---use
248:             * {@link #getYValue(int, int)} instead, if possible.
249:             *
250:             * @param series  the series index.
251:             * @param item  the item index.
252:             *
253:             * @return The y-value.
254:             */
255:            public Number getY(int series, int item) {
256:                return new Double(getYValue(series, item));
257:            }
258:
259:            /**
260:             * Returns the vector for an item in a series.  
261:             * 
262:             * @param series  the series index.
263:             * @param item  the item index.
264:             * 
265:             * @return The vector (possibly <code>null</code>).
266:             */
267:            public Vector getVector(int series, int item) {
268:                VectorSeries s = (VectorSeries) this .data.get(series);
269:                VectorDataItem di = (VectorDataItem) s.getDataItem(item);
270:                return di.getVector();
271:            }
272:
273:            /**
274:             * Returns the x-component of the vector for an item in a series.
275:             * 
276:             * @param series  the series index.
277:             * @param item  the item index.
278:             * 
279:             * @return The x-component of the vector.
280:             */
281:            public double getVectorXValue(int series, int item) {
282:                VectorSeries s = (VectorSeries) this .data.get(series);
283:                VectorDataItem di = (VectorDataItem) s.getDataItem(item);
284:                return di.getVectorX();
285:            }
286:
287:            /**
288:             * Returns the y-component of the vector for an item in a series.
289:             * 
290:             * @param series  the series index.
291:             * @param item  the item index.
292:             * 
293:             * @return The y-component of the vector.
294:             */
295:            public double getVectorYValue(int series, int item) {
296:                VectorSeries s = (VectorSeries) this .data.get(series);
297:                VectorDataItem di = (VectorDataItem) s.getDataItem(item);
298:                return di.getVectorY();
299:            }
300:
301:            /**
302:             * Tests this instance for equality with an arbitrary object.
303:             *
304:             * @param obj  the object (<code>null</code> permitted).
305:             *
306:             * @return A boolean. 
307:             */
308:            public boolean equals(Object obj) {
309:                if (obj == this ) {
310:                    return true;
311:                }
312:                if (!(obj instanceof  VectorSeriesCollection)) {
313:                    return false;
314:                }
315:                VectorSeriesCollection that = (VectorSeriesCollection) obj;
316:                return ObjectUtilities.equal(this .data, that.data);
317:            }
318:
319:            /**
320:             * Returns a clone of this instance.
321:             * 
322:             * @return A clone.
323:             * 
324:             * @throws CloneNotSupportedException if there is a problem.
325:             */
326:            public Object clone() throws CloneNotSupportedException {
327:                VectorSeriesCollection clone = (VectorSeriesCollection) super 
328:                        .clone();
329:                clone.data = (List) ObjectUtilities.deepClone(this.data);
330:                return clone;
331:            }
332:
333:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.