Source Code Cross Referenced for MFInt32.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: MFInt32.java,v $
003:         *
004:         *      @(#)MFInt32.java 1.22 98/11/05 20:34:40
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:57 $
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:        /**  Description of the Class */
043:        public class MFInt32 extends MField {
044:
045:            int size;// number of elements actually used
046:            int[] value;// .length is alloc'd size
047:            // initial value, to allow reset()
048:            int initSize;
049:            int[] initValue;
050:
051:            /**  Sets the init attribute of the MFInt32 object */
052:            private void setInit() {
053:                initSize = size;
054:                if (size > 0) {
055:                    initValue = new int[size];
056:                    System.arraycopy(value, 0, initValue, 0, size);
057:                } else {
058:                    initValue = null;
059:                }
060:            }
061:
062:            /**Constructor for the MFInt32 object */
063:            public MFInt32() {
064:                size = 0;
065:            }
066:
067:            /**
068:             *Constructor for the MFInt32 object
069:             *
070:             *@param  setVal Description of the Parameter
071:             */
072:            public MFInt32(int[] setVal) {
073:                setValue(setVal);
074:                setInit();
075:            }
076:
077:            /**  Description of the Method */
078:            public void reset() {
079:                size = initSize;
080:                if (initSize > 0) {
081:                    setValue(initValue);
082:                }
083:            }
084:
085:            /**
086:             *  Gets the value attribute of the MFInt32 object
087:             *
088:             *@param  getVal Description of the Parameter
089:             */
090:            public void getValue(int[] getVal) {
091:                System.arraycopy(value, 0, getVal, 0, size);
092:            }
093:
094:            /**
095:             *  Sets the value attribute of the MFInt32 object
096:             *
097:             *@param  setVal The new value value
098:             */
099:            public void setValue(int[] setVal) {
100:                setValue(setVal.length, setVal);
101:            }
102:
103:            /**
104:             *  Sets the value attribute of the MFInt32 object
105:             *
106:             *@param  setSize The new value value
107:             *@param  setVal The new value value
108:             */
109:            public void setValue(int setSize, int[] setVal) {
110:                checkSize(setSize, false);
111:                size = setSize;
112:                if (size > 0) {
113:                    System.arraycopy(setVal, 0, value, 0, size);
114:                }
115:                route();
116:            }
117:
118:            /**
119:             *  Sets the value attribute of the MFInt32 object
120:             *
121:             *@param  value The new value value
122:             */
123:            public void setValue(MFInt32 value) {
124:                setValue(value.value);
125:            }
126:
127:            /**
128:             *  Sets the value attribute of the MFInt32 object
129:             *
130:             *@param  value The new value value
131:             */
132:            public void setValue(ConstMFInt32 value) {
133:                setValue((MFInt32) value.ownerField);
134:            }
135:
136:            /**
137:             *  Description of the Method
138:             *
139:             *@param  index Description of the Parameter
140:             *@return  Description of the Return Value
141:             */
142:            public int get1Value(int index) {
143:                if (index >= size) {
144:                    throw new ArrayIndexOutOfBoundsException();
145:                }
146:                return (value[index]);
147:            }
148:
149:            /**
150:             *  Description of the Method
151:             *
152:             *@param  needed Description of the Parameter
153:             *@param  preserveValue Description of the Parameter
154:             */
155:            void checkSize(int needed, boolean preserveValue) {
156:                if ((value == null) && (needed > 0)) {
157:                    value = new int[needed];
158:                } else if (needed > value.length) {
159:                    int newSize = value.length;
160:                    if (newSize == 0) {
161:                        newSize = needed;
162:                    }
163:                    while (needed > newSize) {
164:                        newSize <<= 1;
165:                    }
166:                    int[] prevValue = value;
167:                    value = new int[newSize];
168:                    if (preserveValue) {
169:                        System.arraycopy(prevValue, 0, value, 0, size);
170:                    }
171:                }
172:            }
173:
174:            /**
175:             *  Description of the Method
176:             *
177:             *@return  Description of the Return Value
178:             */
179:            int primCount() {
180:                int count = 0;
181:                for (int i = 0; i < size; i++) {
182:                    if (value[i] == -1) {
183:                        count++;
184:                    }
185:                }
186:                // handle non-terminated final prim
187:                if (value[size - 1] != -1) {
188:                    count++;
189:                }
190:                return count;
191:            }
192:
193:            /**
194:             *  Description of the Method
195:             *
196:             *@return  Description of the Return Value
197:             */
198:            int indexCount() {
199:                int count = 0;
200:                for (int i = 0; i < size; i++) {
201:                    if (value[i] != -1) {
202:                        count++;
203:                    }
204:                }
205:                return count;
206:            }
207:
208:            /**
209:             * Fill the implSize array with the size of each prim and
210:             * the implIndex array with the indices for the prims
211:             *
212:             *@param  implSize Description of the Parameter
213:             *@param  implIndex Description of the Parameter
214:             */
215:            void fillImplArrays(int[] implSize, int[] implIndex) {
216:                int curPrim = 0;
217:                int curSize = 0;
218:                int curIndex = 0;
219:                ;
220:                boolean lastValue = false;
221:                for (int i = 0; i < size; i++) {
222:                    if (value[i] == -1) {
223:                        implSize[curPrim++] = curSize;
224:                        curSize = 0;
225:                        lastValue = false;
226:                    } else {
227:                        implIndex[curIndex++] = value[i];
228:                        curSize++;
229:                        lastValue = true;
230:                    }
231:                }
232:                if (lastValue) {
233:                    // finish off the last face
234:                    implSize[curPrim++] = curSize;
235:                }
236:            }
237:
238:            /**
239:             * Fill a "subordinate" implIndex array.  Use the implSize array
240:             * from the coord index parse.  If the current face size does not
241:             * match the impl face size, try to manage as best we can.  Return
242:             * true if the face sizes matched, false if the data looked screwy
243:             *
244:             *@param  implSize Description of the Parameter
245:             *@param  implIndex Description of the Parameter
246:             *@return  Description of the Return Value
247:             */
248:            boolean fillImplArraysTest(int[] implSize, int[] implIndex) {
249:                int curPrim = 0;
250:                int curSize = 0;
251:                int inIndex = 0;
252:                int outIndex = 0;
253:                boolean dataOK = true;
254:                int useValue;
255:                while (outIndex < implIndex.length) {
256:                    if (inIndex >= size) {
257:                        useValue = value[size - 1];
258:                        dataOK = false;
259:                    } else {
260:                        useValue = value[inIndex];
261:                    }
262:                    if (useValue == -1) {
263:                        if (implSize[curPrim] != curSize) {
264:                            ;
265:                            dataOK = false;
266:                        }
267:                        curPrim++;
268:                        if (curPrim >= implSize.length) {
269:                            dataOK = false;
270:                            curPrim--;
271:                        }
272:                        curSize = 0;
273:                    } else {
274:                        implIndex[outIndex++] = useValue;
275:                        if (curSize++ > implSize[curPrim]) {
276:                            dataOK = false;
277:                        }
278:                    }
279:                    inIndex++;
280:                }
281:                return dataOK;
282:            }
283:
284:            /**
285:             *  Description of the Method
286:             *
287:             *@param  index Description of the Parameter
288:             *@param  f Description of the Parameter
289:             */
290:            public void set1Value(int index, int f) {
291:                if (index >= size) {
292:                    throw new ArrayIndexOutOfBoundsException();
293:                }
294:                value[index] = f;
295:                route();
296:            }
297:
298:            /**
299:             *  Description of the Method
300:             *
301:             *@param  index Description of the Parameter
302:             *@param  f Description of the Parameter
303:             */
304:            public void set1Value(int index, ConstSFInt32 f) {
305:                set1Value(index, (SFInt32) f.ownerField);
306:            }
307:
308:            /**
309:             *  Description of the Method
310:             *
311:             *@param  index Description of the Parameter
312:             *@param  f Description of the Parameter
313:             */
314:            public void set1Value(int index, SFInt32 f) {
315:                set1Value(index, f.value);
316:            }
317:
318:            /**
319:             *  Adds a feature to the Value attribute of the MFInt32 object
320:             *
321:             *@param  f The feature to be added to the Value attribute
322:             */
323:            public void addValue(int f) {
324:                checkSize(size + 1, true);
325:                value[size++] = f;
326:                route();
327:            }
328:
329:            /**
330:             *  Adds a feature to the Value attribute of the MFInt32 object
331:             *
332:             *@param  f The feature to be added to the Value attribute
333:             */
334:            public void addValue(ConstSFInt32 f) {
335:                addValue((SFInt32) f.ownerField);
336:            }
337:
338:            /**
339:             *  Adds a feature to the Value attribute of the MFInt32 object
340:             *
341:             *@param  f The feature to be added to the Value attribute
342:             */
343:            public void addValue(SFInt32 f) {
344:                addValue(f.value);
345:            }
346:
347:            /**
348:             *  Description of the Method
349:             *
350:             *@param  index Description of the Parameter
351:             *@param  f Description of the Parameter
352:             */
353:            public void insertValue(int index, int f) {
354:                if (index >= size) {
355:                    throw new ArrayIndexOutOfBoundsException();
356:                }
357:                checkSize(size + 1, true);
358:                // move the later elements up one index
359:                System.arraycopy(value, index, value, index + 1, size - index);
360:                value[index] = f;
361:                route();
362:            }
363:
364:            /**
365:             *  Description of the Method
366:             *
367:             *@param  index Description of the Parameter
368:             *@param  f Description of the Parameter
369:             */
370:            public void insertValue(int index, ConstSFInt32 f) {
371:                insertValue(index, (SFInt32) f.ownerField);
372:            }
373:
374:            /**
375:             *  Description of the Method
376:             *
377:             *@param  index Description of the Parameter
378:             *@param  f Description of the Parameter
379:             */
380:            public void insertValue(int index, SFInt32 f) {
381:                insertValue(index, f.value);
382:            }
383:
384:            /**
385:             *  Description of the Method
386:             *
387:             *@param  field Description of the Parameter
388:             */
389:            public void update(Field field) {
390:                setValue((MFInt32) field);
391:            }
392:
393:            /**
394:             *  Description of the Method
395:             *
396:             *@return  Description of the Return Value
397:             */
398:            public Object clone() {
399:                MFInt32 ref = new MFInt32();
400:                ref.size = size;
401:                if (size == 0) {
402:                    ref.value = null;
403:                } else {
404:                    ref.value = new int[size];
405:                    System.arraycopy(value, 0, ref.value, 0, size);
406:                }
407:                return ref;
408:            }
409:
410:            /**
411:             *  Description of the Method
412:             *
413:             *@return  Description of the Return Value
414:             */
415:            public synchronized ConstField constify() {
416:                if (constField == null) {
417:                    constField = new ConstMFInt32(this );
418:                }
419:                return constField;
420:            }
421:
422:            /**
423:             *  Gets the size attribute of the MFInt32 object
424:             *
425:             *@return  The size value
426:             */
427:            public int getSize() {
428:                return size;
429:            }
430:
431:            /**  Description of the Method */
432:            public void clear() {
433:                size = 0;
434:            }
435:
436:            /**
437:             *  Description of the Method
438:             *
439:             *@param  index Description of the Parameter
440:             */
441:            public void delete(int index) {
442:                if (index >= size) {
443:                    throw new ArrayIndexOutOfBoundsException();
444:                }
445:                System.arraycopy(value, index + 1, value, index, size - index);
446:                size--;
447:            }
448:
449:            /**
450:             *  Description of the Method
451:             *
452:             *@return  Description of the Return Value
453:             */
454:            public vrml.Field wrap() {
455:                return new vrml.field.MFInt32(this );
456:            }
457:
458:            /**
459:             *  Description of the Method
460:             *
461:             *@return  Description of the Return Value
462:             */
463:            public String toString() {
464:                String retval = "[\n   ";
465:                for (int i = 0; i < size; i++) {
466:                    retval += value[i] + " ";
467:                    // TODO: if MFInt32 used for non-index, find another
468:                    // line break mode.
469:                    if (value[i] == -1) {
470:                        retval += "\n   ";
471:                    }
472:                }
473:                retval += "\n]\n";
474:                return retval;
475:            }
476:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.