Source Code Cross Referenced for SceneBase.java in  » 6.0-JDK-Modules » java-3d » com » db » loaders » 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 » com.db.loaders 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         *
003:         * Copyright (c) 2000-2001 Silvere Martin-Michiellot All Rights Reserved.
004:         *
005:         * Silvere Martin-Michiellot grants you ("Licensee") a non-exclusive,
006:         * royalty free, license to use, modify but not to redistribute this
007:         * software in source and binary code form,
008:         * provided that i) this copyright notice and license appear on all copies of
009:         * the software; and ii) Licensee does not utilize the software in a manner
010:         * which is disparaging to Silvere Martin-Michiellot.
011:         *
012:         * This software is provided "AS IS," without a warranty of any kind. ALL
013:         * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING ANY
014:         * IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR
015:         * NON-INFRINGEMENT, ARE HEREBY EXCLUDED. Silvere Martin-Michiellot
016:         * AND ITS LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES
017:         * SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING
018:         * OR DISTRIBUTING THE SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL
019:         * Silvere Martin-Michiellot OR ITS LICENSORS BE LIABLE
020:         * 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 Silvere Martin-Michiellot HAS BEEN
024:         * ADVISED OF THE 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:         *
032:         * @Author: Silvere Martin-Michiellot
033:         *
034:         */
035:
036:        package com.db.loaders;
037:
038:        import java.lang.Float;
039:
040:        import java.util.Hashtable;
041:        import java.util.Vector;
042:        import java.util.Enumeration;
043:
044:        import javax.media.j3d.Behavior;
045:        import javax.media.j3d.BranchGroup;
046:        import javax.media.j3d.TransformGroup;
047:        import javax.media.j3d.Light;
048:        import javax.media.j3d.Background;
049:        import javax.media.j3d.Fog;
050:        import javax.media.j3d.Sound;
051:
052:        /**
053:         * This class implements the Scene interface and extends it to incorporate
054:         * utilities that could be used by loaders.  There should be little need
055:         * for future loaders to subclass this, or to implement Scene directly,
056:         * as the functionality of a SceneBase is fairly straightforward.  This
057:         * class is responsible for both the storage and retrieval of data from
058:         * the Scene.  The storage methods (used only by Loader writers) are all
059:         * of the add* routines.  The retrieval methods (used primarily by Loader
060:         * users) are all of the get* routines.
061:         */
062:        public class SceneBase implements  Scene {
063:
064:            BranchGroup sceneGroup = null;
065:            BranchGroup behaviorGroup = null;
066:            Hashtable namedObjects = new Hashtable();
067:            String description = null;
068:
069:            Vector viewVector = new Vector();
070:            Vector hfovVector = new Vector();
071:            Vector behaviorVector = new Vector();
072:            Vector lightVector = new Vector();
073:            Vector fogVector = new Vector();
074:            Vector backgroundVector = new Vector();
075:            Vector soundVector = new Vector();
076:
077:            // Add methods
078:
079:            /**
080:             * Sets the sceneGroup to be the group that is passed in.
081:             */
082:            public void setSceneGroup(BranchGroup scene) {
083:                sceneGroup = scene;
084:            }
085:
086:            /**
087:             * Adds the given group to the list of view groups.
088:             */
089:            public void addViewGroup(TransformGroup tg) {
090:                viewVector.addElement(tg);
091:            }
092:
093:            /**
094:             * Adds the given field of view value to the list of field of view values.
095:             */
096:            public void addHorizontalFOV(float hfov) {
097:                hfovVector.addElement(new Float(hfov));
098:            }
099:
100:            /**
101:             * Adds the given behavior to a list of behaviors 
102:             */
103:            public void addBehaviorNode(Behavior b) {
104:                behaviorVector.addElement(b);
105:            }
106:
107:            /**
108:             * Adds the given Light node to the list of lights.
109:             */
110:            public void addLightNode(Light light) {
111:                lightVector.addElement(light);
112:            }
113:
114:            /**
115:             * Adds the given Background node to the list of backgrounds.
116:             */
117:            public void addBackgroundNode(Background background) {
118:                backgroundVector.addElement(background);
119:            }
120:
121:            /**
122:             * Adds the given Sound node to the list of sounds.
123:             */
124:            public void addSoundNode(Sound sound) {
125:                soundVector.addElement(sound);
126:            }
127:
128:            /**
129:             * Adds the given Fog node to the list of fog nodes.
130:             */
131:            public void addFogNode(Fog fog) {
132:                fogVector.addElement(fog);
133:            }
134:
135:            /**
136:             * Sets the text description of the scene to the passed in String.
137:             */
138:            public void addDescription(String descriptionString) {
139:                description = descriptionString;
140:            }
141:
142:            /**
143:             * Adds the given String/Object pair to the table of named objects.
144:             */
145:            public void addNamedObject(String name, Object object) {
146:                if (namedObjects.get(name) == null)
147:                    namedObjects.put(name, object);
148:                else {
149:                    // key already exists - append a unique integer to end of name
150:                    int nameIndex = 1;
151:                    boolean done = false;
152:                    while (!done) {
153:                        // Iterate starting from "[1]" until we find a unique key
154:                        String tempName = name + "[" + nameIndex + "]";
155:                        if (namedObjects.get(tempName) == null) {
156:                            namedObjects.put(tempName, object);
157:                            done = true;
158:                        }
159:                        nameIndex++;
160:                    }
161:                }
162:            }
163:
164:            /**
165:             * This method returns the BranchGroup containing the overall
166:             * scene loaded by the loader.
167:             */
168:            public BranchGroup getSceneGroup() {
169:                return sceneGroup;
170:            }
171:
172:            /**
173:             * This method returns an array of all View Groups defined in the file.
174:             * A View Group is defined as a TransformGroup which contains a
175:             * ViewPlatform.  The TransformGroup holds the position/orientation
176:             * information for the given ViewPlatform and the ViewPlatform
177:             * holds an view-specific information, such as Field of View.
178:             */
179:            public TransformGroup[] getViewGroups() {
180:                if (viewVector.isEmpty())
181:                    return null;
182:                TransformGroup[] viewGroups = new TransformGroup[viewVector
183:                        .size()];
184:                viewVector.copyInto(viewGroups);
185:                return viewGroups;
186:            }
187:
188:            /**
189:             * This method returns an array of floats that contains the horizontal
190:             * field of view values for each corresponding entry in the array of
191:             * view groups returned by the method getViewGroups. 
192:             */
193:            public float[] getHorizontalFOVs() {
194:                if (hfovVector.isEmpty())
195:                    return null;
196:
197:                int arraySize = hfovVector.size();
198:                float[] hfovs = new float[arraySize];
199:                Float[] tmpFovs = new Float[hfovVector.size()];
200:                hfovVector.copyInto(tmpFovs);
201:
202:                // copy to array of floats and delete Floats
203:                for (int i = 0; i < arraySize; i++) {
204:                    hfovs[i] = tmpFovs[i].floatValue();
205:                    tmpFovs[i] = null;
206:                }
207:                return hfovs;
208:            }
209:
210:            /**
211:             * This method returns an array of all Lights defined in the file.
212:             */
213:            public Light[] getLightNodes() {
214:                if (lightVector.isEmpty())
215:                    return null;
216:                Light[] lightNodes = new Light[lightVector.size()];
217:                lightVector.copyInto(lightNodes);
218:                return lightNodes;
219:            }
220:
221:            /**
222:             * This method returns a Hashtable which contains a list of all named
223:             * objects in the file and their associated scene graph objects.  The
224:             * naming scheme for file objects is file-type dependent, but may include
225:             * such names as the DEF names of Vrml or filenames of subjects (as
226:             * in Lightwave 3D).
227:             */
228:            public Hashtable getNamedObjects() {
229:                return namedObjects;
230:            }
231:
232:            /**
233:             * This method returns an array of all Background nodes defined in the
234:             * file.
235:             */
236:            public Background[] getBackgroundNodes() {
237:                if (backgroundVector.isEmpty())
238:                    return null;
239:                Background[] backgroundNodes = new Background[backgroundVector
240:                        .size()];
241:                backgroundVector.copyInto(backgroundNodes);
242:                return backgroundNodes;
243:            }
244:
245:            /**
246:             * This method returns an array of all Fog nodes defined in the
247:             * file.
248:             */
249:            public Fog[] getFogNodes() {
250:                if (fogVector.isEmpty())
251:                    return null;
252:                Fog[] fogNodes = new Fog[fogVector.size()];
253:                fogVector.copyInto(fogNodes);
254:                return fogNodes;
255:            }
256:
257:            /**
258:             * This method returns a group containing all of the Behavior nodes
259:             * in the scene.
260:             */
261:            public Behavior[] getBehaviorNodes() {
262:                if (behaviorVector.isEmpty())
263:                    return null;
264:                Behavior[] behaviorNodes = new Behavior[behaviorVector.size()];
265:                behaviorVector.copyInto(behaviorNodes);
266:
267:                return behaviorNodes;
268:            }
269:
270:            /**
271:             * This method returns an array of all of the Sound nodes defined
272:             * in the file.
273:             */
274:            public Sound[] getSoundNodes() {
275:                if (soundVector.isEmpty())
276:                    return null;
277:                Sound[] soundNodes = new Sound[soundVector.size()];
278:                soundVector.copyInto(soundNodes);
279:                return soundNodes;
280:            }
281:
282:            /**
283:             * This method returns the text description of the file.  If no
284:             * such description exists, this method should return null.
285:             */
286:            public String getDescription() {
287:                return description;
288:            }
289:
290:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.