Source Code Cross Referenced for MFVec3f.java in  » 6.0-JDK-Modules » java-3d » org » jdesktop » j3d » loaders » vrml97 » impl » 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 » 6.0 JDK Modules » java 3d » org.jdesktop.j3d.loaders.vrml97.impl 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * $RCSfile: MFVec3f.java,v $
003:         *
004:         *      @(#)MFVec3f.java 1.18 99/02/03 19:05:34
005:         *
006:         * Copyright (c) 1996-1998 Sun Microsystems, Inc. All Rights Reserved.
007:         *
008:         * Sun grants you ("Licensee") a non-exclusive, royalty free, license to use,
009:         * modify and redistribute this software in source and binary code form,
010:         * provided that i) this copyright notice and license appear on all copies of
011:         * the software; and ii) Licensee does not utilize the software in a manner
012:         * which is disparaging to Sun.
013:         *
014:         * This software is provided "AS IS," without a warranty of any kind. ALL
015:         * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING ANY
016:         * IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR
017:         * NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN AND ITS LICENSORS SHALL NOT BE
018:         * LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING
019:         * OR DISTRIBUTING THE SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR ITS
020:         * LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT,
021:         * INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER
022:         * CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF
023:         * OR INABILITY TO USE SOFTWARE, EVEN IF SUN HAS BEEN ADVISED OF THE
024:         * POSSIBILITY OF SUCH DAMAGES.
025:         *
026:         * This software is not designed or intended for use in on-line control of
027:         * aircraft, air traffic, aircraft navigation or aircraft communications; or in
028:         * the design, construction, operation or maintenance of any nuclear
029:         * facility. Licensee represents and warrants that it will not use or
030:         * redistribute the Software for such purposes.
031:         * $Revision: 1.2 $
032:         * $Date: 2005/02/03 23:06:58 $
033:         * $State: Exp $
034:         */
035:        /*
036:         * @Author: Rick Goldberg
037:         * @Author: Doug Gehringer
038:         *
039:         */
040:        package org.jdesktop.j3d.loaders.vrml97.impl;
041:
042:        import java.lang.Double;
043:        import javax.media.j3d.BoundingBox;
044:        import javax.vecmath.Point3d;
045:
046:        /**  Description of the Class */
047:        public class MFVec3f extends MField {
048:
049:            int size;// number of float elements actually used
050:            float[] value;// .length is alloc'd size
051:            // initial value, to allow reset()
052:            int initSize;
053:            float[] initValue;
054:
055:            /**  Sets the init attribute of the MFVec3f object */
056:            private void setInit() {
057:                initSize = size;
058:                if (size > 0) {
059:                    initValue = new float[size];
060:                    System.arraycopy(value, 0, initValue, 0, size);
061:                } else {
062:                    initValue = null;
063:                }
064:            }
065:
066:            /**Constructor for the MFVec3f object */
067:            public MFVec3f() {
068:                size = 0;
069:                setInit();
070:            }
071:
072:            /**
073:             *Constructor for the MFVec3f object
074:             *
075:             *@param  setVal Description of the Parameter
076:             */
077:            public MFVec3f(float[][] setVal) {
078:                setValue(setVal);
079:                setInit();
080:            }
081:
082:            /**
083:             *Constructor for the MFVec3f object
084:             *
085:             *@param  size Description of the Parameter
086:             *@param  setVal Description of the Parameter
087:             */
088:            public MFVec3f(int size, float[] setVal) {
089:                size *= 3;
090:                setValue(size, setVal);
091:                setInit();
092:            }
093:
094:            /**
095:             *Constructor for the MFVec3f object
096:             *
097:             *@param  setVal Description of the Parameter
098:             */
099:            public MFVec3f(float[] setVal) {
100:                setValue(setVal);
101:                setInit();
102:            }
103:
104:            /**  Description of the Method */
105:            public void reset() {
106:                size = initSize;
107:                if (initSize > 0) {
108:                    setValue(initValue);
109:                }
110:            }
111:
112:            /**
113:             *  Gets the value attribute of the MFVec3f object
114:             *
115:             *@param  getVal Description of the Parameter
116:             */
117:            public void getValue(float[][] getVal) {
118:                int numVecs = size / 3;
119:                for (int i = 0; i < numVecs; i++) {
120:                    System.arraycopy(value, i * 3, getVal[i], 0, 3);
121:                }
122:            }
123:
124:            /**
125:             *  Gets the value attribute of the MFVec3f object
126:             *
127:             *@param  getVal Description of the Parameter
128:             */
129:            public void getValue(float[] getVal) {
130:                System.arraycopy(value, 0, getVal, 0, size);
131:            }
132:
133:            /**
134:             *  Description of the Method
135:             *
136:             *@param  index Description of the Parameter
137:             *@param  getVal Description of the Parameter
138:             */
139:            public void get1Value(int index, float[] getVal) {
140:                if (index >= size) {
141:                    throw new ArrayIndexOutOfBoundsException();
142:                }
143:                System.arraycopy(value, index * 3, getVal, 0, 3);
144:            }
145:
146:            /**
147:             *  Description of the Method
148:             *
149:             *@param  index Description of the Parameter
150:             *@param  getVal Description of the Parameter
151:             */
152:            public void get1Value(int index, SFVec3f getVal) {
153:                if (index >= size) {
154:                    throw new ArrayIndexOutOfBoundsException();
155:                }
156:                getVal.setValue(value[index], value[index + 1],
157:                        value[index + 2]);
158:            }
159:
160:            /**
161:             *  Description of the Method
162:             *
163:             *@param  needed Description of the Parameter
164:             *@param  preserveValue Description of the Parameter
165:             */
166:            void checkSize(int needed, boolean preserveValue) {
167:                if ((value == null) && (needed > 0)) {
168:                    value = new float[needed];
169:                } else if (needed > value.length) {
170:                    int newSize = value.length;
171:                    if (newSize == 0) {
172:                        newSize = needed;
173:                    }
174:                    while (needed > newSize) {
175:                        newSize <<= 1;
176:                    }
177:                    float[] prevValue = value;
178:                    value = new float[newSize];
179:                    if (preserveValue) {
180:                        System.arraycopy(prevValue, 0, value, 0, size);
181:                    }
182:                }
183:            }
184:
185:            /**
186:             *  Sets the value attribute of the MFVec3f object
187:             *
188:             *@param  setVal The new value value
189:             */
190:            public void setValue(float[][] setVal) {
191:                checkSize(setVal.length * 3, false);
192:                size = setVal.length * 3;
193:                for (int i = 0; i < setVal.length; i++) {
194:                    System.arraycopy(setVal, 0, value, i * 3, i * 3 + 3);
195:                }
196:                route();
197:
198:            }
199:
200:            /**
201:             *  Sets the value attribute of the MFVec3f object
202:             *
203:             *@param  setVal The new value value
204:             */
205:            public void setValue(float[] setVal) {
206:                setValue(setVal.length, setVal);
207:            }
208:
209:            /**
210:             *  Sets the value attribute of the MFVec3f object
211:             *
212:             *@param  setSize The new value value
213:             *@param  setVal The new value value
214:             */
215:            public void setValue(int setSize, float[] setVal) {
216:                checkSize(setSize, false);
217:                size = setSize;
218:                if (size > 0) {
219:                    System.arraycopy(setVal, 0, value, 0, size);
220:                }
221:                route();
222:            }
223:
224:            /**
225:             *  Sets the value attribute of the MFVec3f object
226:             *
227:             *@param  field The new value value
228:             */
229:            public void setValue(MFVec3f field) {
230:                setValue(field.value);
231:            }
232:
233:            /**
234:             *  Sets the value attribute of the MFVec3f object
235:             *
236:             *@param  field The new value value
237:             */
238:            public void setValue(ConstMFVec3f field) {
239:                setValue(((MFVec3f) field.ownerField).value);
240:            }
241:
242:            /**
243:             *  Description of the Method
244:             *
245:             *@param  index Description of the Parameter
246:             *@param  constvec Description of the Parameter
247:             */
248:            public void set1Value(int index, ConstSFVec3f constvec) {
249:                set1Value(index, (SFVec3f) (constvec.ownerField));
250:            }
251:
252:            /**
253:             *  Description of the Method
254:             *
255:             *@param  index Description of the Parameter
256:             *@param  vec Description of the Parameter
257:             */
258:            public void set1Value(int index, SFVec3f vec) {
259:                set1Value(index, vec.value[0], vec.value[1], vec.value[2]);
260:            }
261:
262:            /**
263:             *  Description of the Method
264:             *
265:             *@param  index Description of the Parameter
266:             *@param  x Description of the Parameter
267:             *@param  y Description of the Parameter
268:             *@param  z Description of the Parameter
269:             */
270:            public void set1Value(int index, float x, float y, float z) {
271:                index *= 3;
272:                if (index >= size) {
273:                    throw new ArrayIndexOutOfBoundsException();
274:                }
275:                value[index + 0] = x;
276:                value[index + 1] = y;
277:                value[index + 2] = z;
278:                route();
279:            }
280:
281:            /**
282:             *  Description of the Method
283:             *
284:             *@param  index Description of the Parameter
285:             *@param  constvec Description of the Parameter
286:             */
287:            public void insertValue(int index, ConstSFVec3f constvec) {
288:                insertValue(index, (SFVec3f) constvec.ownerField);
289:            }
290:
291:            /**
292:             *  Description of the Method
293:             *
294:             *@param  index Description of the Parameter
295:             *@param  vec Description of the Parameter
296:             */
297:            public void insertValue(int index, SFVec3f vec) {
298:                insertValue(index, vec.value[0], vec.value[1], vec.value[2]);
299:            }
300:
301:            /**
302:             *  Description of the Method
303:             *
304:             *@param  index Description of the Parameter
305:             *@param  x Description of the Parameter
306:             *@param  y Description of the Parameter
307:             *@param  z Description of the Parameter
308:             */
309:            public void insertValue(int index, float x, float y, float z) {
310:                int i;
311:                index *= 3;
312:                if (index >= size) {
313:                    throw new ArrayIndexOutOfBoundsException();
314:                }
315:                checkSize(size + 3, true);
316:
317:                // move the values after the inserted value up by 3,
318:                System.arraycopy(value, index, value, index + 3, size - index);
319:
320:                // write the value
321:                value[index] = x;
322:                value[index + 1] = y;
323:                value[index + 2] = y;
324:                size += 3;
325:                route();
326:            }
327:
328:            /**
329:             *  Description of the Method
330:             *
331:             *@param  field Description of the Parameter
332:             */
333:            public void update(Field field) {
334:                setValue((MFVec3f) field);
335:            }
336:
337:            /**
338:             *  Description of the Method
339:             *
340:             *@return  Description of the Return Value
341:             */
342:            public Object clone() {// the copy is only as large as it needs to be
343:                MFVec3f ref = new MFVec3f();
344:                ref.size = size;
345:                if (size == 0) {
346:                    ref.value = null;
347:                } else {
348:                    ref.value = new float[size];
349:                    System.arraycopy(value, 0, ref.value, 0, size);
350:                }
351:                return ref;
352:            }
353:
354:            /**
355:             *  Description of the Method
356:             *
357:             *@return  Description of the Return Value
358:             */
359:            public ConstField constify() {
360:                if (constField == null) {
361:                    constField = new ConstMFVec3f(this );
362:                }
363:                return constField;
364:            }
365:
366:            /**
367:             *  Gets the size attribute of the MFVec3f object
368:             *
369:             *@return  The size value
370:             */
371:            public int getSize() {
372:                return size / 3;
373:            }
374:
375:            /**  Description of the Method */
376:            public void clear() {
377:                size = 0;
378:                route();
379:            }
380:
381:            /**
382:             *  Description of the Method
383:             *
384:             *@param  index Description of the Parameter
385:             */
386:            public void delete(int index) {
387:                int i;
388:                index *= 3;
389:                if (index >= size) {
390:                    throw new ArrayIndexOutOfBoundsException();
391:                }
392:                System.arraycopy(value, index + 3, value, index, size - index);
393:                size -= 3;
394:                route();
395:            }
396:
397:            /**
398:             *  Description of the Method
399:             *
400:             *@return  Description of the Return Value
401:             */
402:            public vrml.Field wrap() {
403:                return new vrml.field.MFVec3f(this );
404:            }
405:
406:            /**
407:             *  Description of the Method
408:             *
409:             *@return  Description of the Return Value
410:             */
411:            public String toString() {
412:                String retval = "[";
413:                for (int i = 0; i < size; i += 3) {
414:                    for (int j = 0; j < 3; j++) {
415:                        retval += value[i + j];
416:                        retval += " ";
417:                    }
418:                    retval += "\n  ";
419:                }
420:                retval += "\n]\n";
421:                return retval;
422:            }
423:
424:            /**
425:             *  Gets the boundingBox attribute of the MFVec3f object
426:             *
427:             *@return  The boundingBox value
428:             */
429:            BoundingBox getBoundingBox() {
430:                Point3d min = new Point3d(Double.MAX_VALUE, Double.MAX_VALUE,
431:                        Double.MAX_VALUE);
432:                Point3d max = new Point3d(Double.MIN_VALUE, Double.MIN_VALUE,
433:                        Double.MIN_VALUE);
434:                for (int i = 0; i < size; i += 3) {
435:                    if (value[i] > max.x) {
436:                        max.x = value[i];
437:                    }
438:                    if (value[i] < min.x) {
439:                        min.x = value[i];
440:                    }
441:                    if (value[i + 1] > max.y) {
442:                        max.y = value[i + 1];
443:                    }
444:                    if (value[i + 1] < min.y) {
445:                        min.y = value[i + 1];
446:                    }
447:                    if (value[i + 2] > max.z) {
448:                        max.z = value[i + 2];
449:                    }
450:                    if (value[i + 2] < min.z) {
451:                        min.z = value[i + 2];
452:                    }
453:                }
454:                return new BoundingBox(min, max);
455:            }
456:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.