Source Code Cross Referenced for ProtoInstance.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: ProtoInstance.java,v $
003:         *
004:         *      @(#)ProtoInstance.java 1.15 99/03/24 15:33:33
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:         *
032:         * $Revision: 1.2 $
033:         * $Date: 2005/02/03 23:07:00 $
034:         * $State: Exp $
035:         */
036:        /*
037:         * @Author: Rick Goldberg
038:         * @Author: Doug Gehringer
039:         */
040:        package org.jdesktop.j3d.loaders.vrml97.impl;
041:
042:        import java.util.Enumeration;
043:        import java.util.Hashtable;
044:        import java.util.Vector;
045:
046:        /**  Description of the Class */
047:        public class ProtoInstance extends Node implements  Namespace {
048:
049:            String name;
050:            Proto proto;
051:            Hashtable defTable = new Hashtable();
052:            BaseNode instanceNode;
053:            Vector routes;
054:            Hashtable fieldMapping = new Hashtable();
055:            Hashtable nodeMapping = new Hashtable();
056:            // need to get the updateParent() correct
057:            boolean containsSensor = false;
058:            Vector sensors;
059:
060:            /**
061:             *Constructor for the ProtoInstance object
062:             *
063:             *@param  loader Description of the Parameter
064:             *@param  name Description of the Parameter
065:             *@param  proto Description of the Parameter
066:             */
067:            ProtoInstance(Loader loader, String name, Proto proto) {
068:                super (loader);
069:                this .name = name;
070:                this .proto = proto;
071:                this .routes = proto.routes;
072:            }
073:
074:            /**
075:             *  Adds a feature to the Field attribute of the ProtoInstance object
076:             *
077:             *@param  field The feature to be added to the Field attribute
078:             *@return  Description of the Return Value
079:             */
080:            Field addField(Field field) {
081:                Field newField;
082:                if (!fieldMapping.containsKey(field)) {
083:                    newField = (Field) field.clone();
084:                    fieldMapping.put(field, newField);
085:                    newField.init(this , FieldSpec, field.fieldType,
086:                            field.fieldName);
087:                } else {
088:                    newField = (Field) fieldMapping.get(field);
089:                }
090:                return newField;
091:            }
092:
093:            /**  Description of the Method */
094:            void initFields() {
095:                // clone the Proto's fields and event mappings
096:                // handle the fields first
097:                for (Enumeration e = proto.FieldSpec.keys(); e
098:                        .hasMoreElements();) {
099:                    String fieldName = (String) e.nextElement();
100:                    Field field = (Field) proto.FieldSpec.get(fieldName);
101:                    //System.err.println("ProtoInstance.initFields(): got field " +
102:                    //  "named " + fieldName + " with value " + field);
103:                    Field newField;
104:                    if ((field instanceof  ConstField)) {
105:                        newField = addField(((ConstField) field).ownerField);
106:                        FieldSpec.put(fieldName, newField.constify());
107:                    } else {
108:                        newField = addField(field);
109:                        FieldSpec.put(fieldName, newField);
110:                    }
111:                }
112:            }
113:
114:            /**
115:             *  Description of the Method
116:             *
117:             *@param  defName Description of the Parameter
118:             *@param  node Description of the Parameter
119:             */
120:            public void define(String defName, BaseNode node) {
121:                //System.out.println("ProtoInstance.define() name: " + defName +
122:                //	"value: " + node);
123:                defTable.put(defName, node);
124:            }
125:
126:            /**
127:             *  Description of the Method
128:             *
129:             *@param  defName Description of the Parameter
130:             *@return  Description of the Return Value
131:             */
132:            public BaseNode use(String defName) {
133:                BaseNode retval = (BaseNode) defTable.get(defName);
134:                //System.out.println("ProtoInstance.use(" + defName + ") " +
135:                //	" returned " + " node " + retval.toStringId());
136:                retval.registerUse(loader.scene);
137:                return retval;
138:            }
139:
140:            /**
141:             *  Description of the Method
142:             *
143:             *@param  node Description of the Parameter
144:             *@return  Description of the Return Value
145:             */
146:            BaseNode updateNode(BaseNode node) {
147:                BaseNode retval;
148:                if (node == null) {
149:                    return this ;
150:                }
151:                retval = (BaseNode) nodeMapping.get(node);
152:                //System.out.println("some strange method called updateNode "+node);
153:                //System.out.println("mapped to "+retval);
154:                if (retval == null) {
155:                    System.err.println("ProtoInstance: Unable to update node "
156:                            + "reference: " + node.toStringId());
157:                }
158:                return retval;
159:            }
160:
161:            /**  Description of the Method */
162:            void applyRoutes() {
163:                // apply the routes, updating the nodes
164:                //System.out.println("ProtoInstance: applying routes:");
165:                for (Enumeration e = routes.elements(); e.hasMoreElements();) {
166:                    Route route = (Route) e.nextElement();
167:                    BaseNode fromNode;
168:                    BaseNode toNode;
169:                    fromNode = updateNode(route.fromNode);
170:                    toNode = updateNode(route.toNode);
171:                    //System.out.println("Add route: " + fromNode + " . " +
172:                    //route.fromField + "\n   to " + toNode + " . " + route.toField);
173:
174:                    // bug: after fixing 4221802 the multinoded protodef somehow
175:                    // a "?" field was trying to get addRouted
176:                    if (!route.fromField.equals("?")
177:                            && !route.toField.equals("?")) {
178:                        loader.connect(fromNode, route.fromField, toNode,
179:                                route.toField, false);
180:                    }
181:                }
182:            }
183:
184:            /**
185:             *  Description of the Method
186:             *
187:             *@return  Description of the Return Value
188:             */
189:            BaseNode instanceNode() {
190:                return instanceNode;
191:            }
192:
193:            /**
194:             *  Gets the implNode attribute of the ProtoInstance object
195:             *
196:             *@return  The implNode value
197:             */
198:            public javax.media.j3d.Node getImplNode() {
199:                return instanceNode.getImplNode();
200:            }
201:
202:            // dummy methods to satisfy BaseNode interface
203:            /**
204:             *  Description of the Method
205:             *
206:             *@param  eventInName Description of the Parameter
207:             *@param  time Description of the Parameter
208:             */
209:            public void notifyMethod(String eventInName, double time) {
210:            }
211:
212:            /**
213:             *  Gets the type attribute of the ProtoInstance object
214:             *
215:             *@return  The type value
216:             */
217:            public String getType() {
218:                return name;
219:            }
220:
221:            /**
222:             *  Description of the Method
223:             *
224:             *@return  Description of the Return Value
225:             */
226:            public Object clone() {
227:                System.err.println("Warning: clone called on a ProtoInstance!");
228:                return null;
229:            }
230:
231:            /**
232:             *  Description of the Method
233:             *
234:             *@return  Description of the Return Value
235:             */
236:            public String toStringBody() {
237:                return "PROTO " + name + " {\n" + /* TODO: fields here */"}\n";
238:            }
239:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.