Source Code Cross Referenced for WaferMapDataset.java in  » Chart » jfreechart » org » jfree » data » general » 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.general 
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:         * WaferMapDataset.java
029:         * --------------------
030:         * (C)opyright 2003-2007, by Robert Redburn and Contributors.
031:         *
032:         * Original Author:  Robert Redburn;
033:         * Contributor(s):   David Gilbert (for Object Refinery Limited);
034:         *
035:         * $Id: WaferMapDataset.java,v 1.3.2.2 2007/02/02 15:50:44 mungady Exp $
036:         *
037:         * Changes
038:         * -------
039:         * 25-Nov-2003 : Version 1 contributed by Robert Redburn (with some 
040:         *               modifications to match style conventions) (DG);
041:         * ------------- JFREECHART 1.0.x ---------------------------------------------
042:         * 02-Feb-2007 : Removed author tags from all over JFreeChart sources (DG);
043:         * 
044:         */
045:
046:        package org.jfree.data.general;
047:
048:        import java.util.Set;
049:        import java.util.TreeSet;
050:
051:        import org.jfree.data.DefaultKeyedValues2D;
052:
053:        /**
054:         * A dataset that can be used with the {@link org.jfree.chart.plot.WaferMapPlot}
055:         * class.
056:         */
057:        public class WaferMapDataset extends AbstractDataset {
058:
059:            /** 
060:             * Storage structure for the data values (row key is chipx, column is 
061:             * chipy)
062:             */
063:            private DefaultKeyedValues2D data;
064:
065:            /** wafer x dimension */
066:            private int maxChipX;
067:
068:            /** wafer y dimension */
069:            private int maxChipY;
070:
071:            /** space to draw between chips */
072:            private double chipSpace;
073:
074:            /** maximum value in this dataset */
075:            private Double maxValue;
076:
077:            /** minimum value in this dataset */
078:            private Double minValue;
079:
080:            /** default chip spacing */
081:            private static final double DEFAULT_CHIP_SPACE = 1d;
082:
083:            /**
084:             * Creates a new dataset using the default chipspace.
085:             * 
086:             * @param maxChipX  the wafer x-dimension.
087:             * @param maxChipY  the wafer y-dimension.
088:             */
089:            public WaferMapDataset(int maxChipX, int maxChipY) {
090:                this (maxChipX, maxChipY, null);
091:            }
092:
093:            /**
094:             * Creates a new dataset.
095:             * 
096:             * @param maxChipX  the wafer x-dimension. 
097:             * @param maxChipY  the wafer y-dimension.
098:             * @param chipSpace  the space between chips.
099:             */
100:            public WaferMapDataset(int maxChipX, int maxChipY, Number chipSpace) {
101:
102:                this .maxValue = new Double(Double.NEGATIVE_INFINITY);
103:                this .minValue = new Double(Double.POSITIVE_INFINITY);
104:                this .data = new DefaultKeyedValues2D();
105:
106:                this .maxChipX = maxChipX;
107:                this .maxChipY = maxChipY;
108:                if (chipSpace == null) {
109:                    this .chipSpace = DEFAULT_CHIP_SPACE;
110:                } else {
111:                    this .chipSpace = chipSpace.doubleValue();
112:                }
113:
114:            }
115:
116:            /**
117:             * Sets a value in the dataset.
118:             * 
119:             * @param value  the value.
120:             * @param chipx  the x-index for the chip.
121:             * @param chipy  the y-index for the chip.
122:             */
123:            public void addValue(Number value, Comparable chipx,
124:                    Comparable chipy) {
125:                setValue(value, chipx, chipy);
126:            }
127:
128:            /**
129:             * Adds a value to the dataset.
130:             * 
131:             * @param v  the value.
132:             * @param x  the x-index.
133:             * @param y  the y-index.
134:             */
135:            public void addValue(int v, int x, int y) {
136:                setValue(new Double(v), new Integer(x), new Integer(y));
137:            }
138:
139:            /**
140:             * Sets a value in the dataset and updates min and max value entries.
141:             * 
142:             * @param value  the value.
143:             * @param chipx  the x-index.
144:             * @param chipy  the y-index.
145:             */
146:            public void setValue(Number value, Comparable chipx,
147:                    Comparable chipy) {
148:                this .data.setValue(value, chipx, chipy);
149:                if (isMaxValue(value)) {
150:                    this .maxValue = (Double) value;
151:                }
152:                if (isMinValue(value)) {
153:                    this .minValue = (Double) value;
154:                }
155:            }
156:
157:            /**
158:             * Returns the number of unique values.
159:             * 
160:             * @return The number of unique values.
161:             */
162:            public int getUniqueValueCount() {
163:                return getUniqueValues().size();
164:            }
165:
166:            /**
167:             * Returns the set of unique values.
168:             * 
169:             * @return The set of unique values.
170:             */
171:            public Set getUniqueValues() {
172:                Set unique = new TreeSet();
173:                //step through all the values and add them to the hash
174:                for (int r = 0; r < this .data.getRowCount(); r++) {
175:                    for (int c = 0; c < this .data.getColumnCount(); c++) {
176:                        Number value = this .data.getValue(r, c);
177:                        if (value != null) {
178:                            unique.add(value);
179:                        }
180:                    }
181:                }
182:                return unique;
183:            }
184:
185:            /**
186:             * Returns the data value for a chip.
187:             * 
188:             * @param chipx  the x-index.
189:             * @param chipy  the y-index.
190:             * 
191:             * @return The data value.
192:             */
193:            public Number getChipValue(int chipx, int chipy) {
194:                return getChipValue(new Integer(chipx), new Integer(chipy));
195:            }
196:
197:            /**
198:             * Returns the value for a given chip x and y or null.
199:             * 
200:             * @param chipx  the x-index.
201:             * @param chipy  the y-index.
202:             * 
203:             * @return The data value.
204:             */
205:            public Number getChipValue(Comparable chipx, Comparable chipy) {
206:                int rowIndex = this .data.getRowIndex(chipx);
207:                if (rowIndex < 0) {
208:                    return null;
209:                }
210:                int colIndex = this .data.getColumnIndex(chipy);
211:                if (colIndex < 0) {
212:                    return null;
213:                }
214:                return this .data.getValue(rowIndex, colIndex);
215:            }
216:
217:            /**
218:             * Tests to see if the passed value is larger than the stored maxvalue.
219:             * 
220:             * @param check  the number to check.
221:             * 
222:             * @return A boolean.
223:             */
224:            public boolean isMaxValue(Number check) {
225:                if (check.doubleValue() > this .maxValue.doubleValue()) {
226:                    return true;
227:                }
228:                return false;
229:            }
230:
231:            /**
232:             * Tests to see if the passed value is smaller than the stored minvalue.
233:             * 
234:             * @param check  the number to check.
235:             * 
236:             * @return A boolean.
237:             */
238:            public boolean isMinValue(Number check) {
239:                if (check.doubleValue() < this .minValue.doubleValue()) {
240:                    return true;
241:                }
242:                return false;
243:            }
244:
245:            /** 
246:             * Returns the maximum value stored in the dataset.
247:             * 
248:             * @return The maximum value.
249:             */
250:            public Number getMaxValue() {
251:                return this .maxValue;
252:            }
253:
254:            /** 
255:             * Returns the minimum value stored in the dataset.
256:             * 
257:             * @return The minimum value.
258:             */
259:            public Number getMinValue() {
260:                return this .minValue;
261:            }
262:
263:            /**
264:             * Returns the wafer x-dimension.
265:             * 
266:             * @return The number of chips in the x-dimension.
267:             */
268:            public int getMaxChipX() {
269:                return this .maxChipX;
270:            }
271:
272:            /**
273:             * Sets wafer x dimension.
274:             * 
275:             * @param maxChipX  the number of chips in the x-dimension.
276:             */
277:            public void setMaxChipX(int maxChipX) {
278:                this .maxChipX = maxChipX;
279:            }
280:
281:            /**
282:             * Returns the number of chips in the y-dimension.
283:             * 
284:             * @return The number of chips.
285:             */
286:            public int getMaxChipY() {
287:                return this .maxChipY;
288:            }
289:
290:            /**
291:             * Sets the number of chips in the y-dimension.
292:             * 
293:             * @param maxChipY  the number of chips.
294:             */
295:            public void setMaxChipY(int maxChipY) {
296:                this .maxChipY = maxChipY;
297:            }
298:
299:            /**
300:             * Returns the space to draw between chips.
301:             * 
302:             * @return The space.
303:             */
304:            public double getChipSpace() {
305:                return this .chipSpace;
306:            }
307:
308:            /**
309:             * Sets the space to draw between chips.
310:             * 
311:             * @param space  the space.
312:             */
313:            public void setChipSpace(double space) {
314:                this.chipSpace = space;
315:            }
316:
317:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.