Source Code Cross Referenced for ScatterPlotDataSet.java in  » Chart » jCharts » org » krysalis » jcharts » chartData » 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 » jCharts » org.krysalis.jcharts.chartData 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /***********************************************************************************************
002:         * File Info: $Id: ScatterPlotDataSet.java,v 1.2 2004/05/31 16:24:34 nathaniel_auvil Exp $
003:         * Copyright (C) 2002
004:         * Author: Nathaniel G. Auvil
005:         * Contributor(s):
006:         *
007:         * Copyright 2002 (C) Nathaniel G. Auvil. All Rights Reserved.
008:         *
009:         * Redistribution and use of this software and associated documentation ("Software"), with or
010:         * without modification, are permitted provided that the following conditions are met:
011:         *
012:         * 1. Redistributions of source code must retain copyright statements and notices.
013:         * 	Redistributions must also contain a copy of this document.
014:         *
015:         * 2. Redistributions in binary form must reproduce the above copyright notice, this list of
016:         * 	conditions and the following disclaimer in the documentation and/or other materials
017:         * 	provided with the distribution.
018:         *
019:         * 3. The name "jCharts" or "Nathaniel G. Auvil" must not be used to endorse or promote
020:         * 	products derived from this Software without prior written permission of Nathaniel G.
021:         * 	Auvil.  For written permission, please contact nathaniel_auvil@users.sourceforge.net
022:         *
023:         * 4. Products derived from this Software may not be called "jCharts" nor may "jCharts" appear
024:         * 	in their names without prior written permission of Nathaniel G. Auvil. jCharts is a
025:         * 	registered trademark of Nathaniel G. Auvil.
026:         *
027:         * 5. Due credit should be given to the jCharts Project (http://jcharts.sourceforge.net/).
028:         *
029:         * THIS SOFTWARE IS PROVIDED BY Nathaniel G. Auvil AND CONTRIBUTORS ``AS IS'' AND ANY
030:         * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
031:         * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL
032:         * jCharts OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
033:         * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
034:         * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
035:         * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,STRICT LIABILITY, OR TORT
036:         * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
037:         * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE
038:         ************************************************************************************************/package org.krysalis.jcharts.chartData;
039:
040:        import org.krysalis.jcharts.chartData.interfaces.IScatterPlotDataSet;
041:        import org.krysalis.jcharts.properties.ChartTypeProperties;
042:        import org.krysalis.jcharts.properties.ScatterPlotProperties;
043:        import org.krysalis.jcharts.test.HTMLGenerator;
044:        import org.krysalis.jcharts.test.HTMLTestable;
045:        import org.krysalis.jcharts.types.ChartType;
046:
047:        import java.awt.*;
048:        import java.awt.geom.Point2D;
049:        import java.util.ArrayList;
050:
051:        public class ScatterPlotDataSet implements  IScatterPlotDataSet,
052:                HTMLTestable {
053:            //---use this to clone for better performance than creating new
054:            private static Point2D.Double POINT = new Point2D.Double();
055:
056:            private ArrayList data;
057:            private ArrayList legendLabels;
058:            private ArrayList paints;
059:            private ScatterPlotProperties scatterPlotProperties;
060:
061:            private int numDataItems = -1;
062:
063:            /******************************************************************************************
064:             * Constructor
065:             *
066:             * @param scatterPlotProperties
067:             *******************************************************************************************/
068:            public ScatterPlotDataSet(
069:                    ScatterPlotProperties scatterPlotProperties) {
070:                this .data = new ArrayList();
071:                this .legendLabels = new ArrayList();
072:                this .paints = new ArrayList();
073:                this .scatterPlotProperties = scatterPlotProperties;
074:            }
075:
076:            /******************************************************************************************
077:             * Returns the type constant that this data set should be plotted as.
078:             *
079:             * @return ChartType
080:             *******************************************************************************************/
081:            public final ChartType getChartType() {
082:                return ChartType.SCATTER_PLOT;
083:            }
084:
085:            /****************************************************************************************
086:             *
087:             * @param points
088:             * @param paint
089:             * @param legendLabel
090:             ***************************************************************************************/
091:            public void addDataPoints(Point2D.Double[] points, Paint paint,
092:                    String legendLabel) {
093:                this .data.add(points);
094:                this .paints.add(paint);
095:                this .legendLabels.add(legendLabel);
096:
097:                this .numDataItems = points.length;
098:            }
099:
100:            /************************************************************************************************
101:             * Performs a limited validation of data.
102:             *
103:             * @throws ChartDataException
104:             *************************************************************************************************/
105:            public void validate() throws ChartDataException {
106:                Point2D.Double[] points;
107:                for (int i = 0; i < this .data.size(); i++) {
108:                    points = (Point2D.Double[]) this .data.get(i);
109:                    if (points.length != this .numDataItems) {
110:                        throw new ChartDataException(
111:                                "All Arrays of Point Objects must have the same length.");
112:                    }
113:
114:                    if (this .paints.get(i) == null) {
115:                        throw new ChartDataException(
116:                                "The 'Paint' implementation can not be NULL.");
117:                    }
118:                }
119:
120:                if (this .scatterPlotProperties == null) {
121:                    throw new ChartDataException(
122:                            "ScatterPlotProperties can not be NULL.");
123:                }
124:            }
125:
126:            /******************************************************************************************
127:             * Returns the value in the data set at the specified position.
128:             *
129:             * @param dataset
130:             * @param index
131:             * @return Point.Double
132:             *******************************************************************************************/
133:            public Point2D.Double getValue(int dataset, int index) {
134:                return ((Point2D.Double[]) this .data.get(dataset))[index];
135:            }
136:
137:            /******************************************************************************************
138:             * Returns the legend label for the passed index. This index corresponds to the DataSet
139:             *     for which label you want.
140:             *
141:             * @param index
142:             * @return String
143:             *******************************************************************************************/
144:            public final String getLegendLabel(int index) {
145:                if (this .legendLabels == null) {
146:                    return null;
147:                } else {
148:                    return (String) this .legendLabels.get(index);
149:                }
150:            }
151:
152:            /*********************************************************************************************
153:             * Returns the number of Legend Labels to display.  This may not be the same as the number of
154:             *  Data Items, as in AxisCharts, or Data Sets, as in Pie Charts.
155:             *
156:             * @return int
157:             **********************************************************************************************/
158:            public int getNumberOfLegendLabels() {
159:                if (this .legendLabels == null) {
160:                    return 0;
161:                } else {
162:                    return this .legendLabels.size();
163:                }
164:            }
165:
166:            /******************************************************************************************
167:             * Returns the legend label for the passed index. This index corresponds to the DataSet
168:             *     for which label you want.
169:             *
170:             * @param index
171:             * @return Paint
172:             *******************************************************************************************/
173:            public Paint getPaint(int index) {
174:                return (Paint) this .paints.get(index);
175:            }
176:
177:            /******************************************************************************************
178:             *
179:             * @return ChartTypeProperties
180:             *******************************************************************************************/
181:            public ChartTypeProperties getChartTypeProperties() {
182:                return this .scatterPlotProperties;
183:            }
184:
185:            /******************************************************************************************
186:             * Returns the number of elements in the data set.
187:             *
188:             * @return int
189:             *******************************************************************************************/
190:            public int getNumberOfDataSets() {
191:                return this .data.size();
192:            }
193:
194:            /******************************************************************************************
195:             * Returns the number of elements in the data set.
196:             *
197:             * @return int
198:             *******************************************************************************************/
199:            public int getNumberOfDataItems() {
200:                return this .numDataItems;
201:            }
202:
203:            /*****************************************************************************************
204:             * Take advantage of the face Cloning performs better than creating new for highly used
205:             * 	Objects.
206:             *
207:             * @return Point2D.Double
208:             ****************************************************************************************/
209:            public static final Point2D.Double createPoint2DDouble() {
210:                return (Point2D.Double) POINT.clone();
211:            }
212:
213:            /*********************************************************************************************
214:             * Enables the testing routines to display the contents of this Object.
215:             *
216:             * @param htmlGenerator
217:             **********************************************************************************************/
218:            public void toHTML(HTMLGenerator htmlGenerator) {
219:                htmlGenerator.propertiesTableStart(this .getClass().getName());
220:                htmlGenerator.addTableRow("data", HTMLGenerator
221:                        .arrayToString(this .data
222:                                .toArray(new Point2D.Double[this .legendLabels
223:                                        .size()])));
224:
225:                if (this .legendLabels != null) {
226:                    htmlGenerator.addTableRow("legendLabels", HTMLGenerator
227:                            .arrayToString(this .legendLabels
228:                                    .toArray(new String[this .legendLabels
229:                                            .size()])));
230:                }
231:                htmlGenerator.addTableRow("paints", HTMLGenerator
232:                        .arrayToString(this .paints
233:                                .toArray(new Paint[this.paints.size()])));
234:                htmlGenerator.propertiesTableEnd();
235:
236:                htmlGenerator.chartTableRowStart();
237:                this.scatterPlotProperties.toHTML(htmlGenerator);
238:                htmlGenerator.chartTableRowEnd();
239:            }
240:
241:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.