Source Code Cross Referenced for GroupBase.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: GroupBase.java,v $
003:         *
004:         *      @(#)GroupBase.java 1.30 99/03/24 15:32:53
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:06:56 $
034:         * $State: Exp $
035:         */
036:        /*
037:         * @Author: Rick Goldberg
038:         * @Author: Doug Gehringer
039:         *
040:         */
041:        package org.jdesktop.j3d.loaders.vrml97.impl;
042:
043:        import java.util.*;
044:
045:        /**  Description of the Class */
046:        public abstract class GroupBase extends NonSharedNode {
047:
048:            // eventIn
049:            MFNode addChildren;// to comply with the spec, these are really
050:            MFNode removeChildren;// supposed to only be write only.
051:
052:            // exposedField
053:            MFNode children;
054:
055:            // field
056:            SFVec3f bboxCenter;
057:            SFVec3f bboxSize;
058:
059:            javax.media.j3d.Group implGroup;
060:
061:            /**
062:             *Constructor for the GroupBase object
063:             *
064:             *@param  loader Description of the Parameter
065:             */
066:            public GroupBase(Loader loader) {
067:                super (loader);
068:                children = new MFNode();
069:                bboxCenter = new SFVec3f();
070:                bboxSize = new SFVec3f(-1.0f, -1.0f, -1.0f);
071:                addChildren = new MFNode();
072:                removeChildren = new MFNode();
073:                initGroupBaseFields();
074:            }
075:
076:            /**
077:             *Constructor for the GroupBase object
078:             *
079:             *@param  loader Description of the Parameter
080:             *@param  children Description of the Parameter
081:             *@param  bboxCenter Description of the Parameter
082:             *@param  bboxSize Description of the Parameter
083:             */
084:            GroupBase(Loader loader, MFNode children, SFVec3f bboxCenter,
085:                    SFVec3f bboxSize) {
086:                super (loader);
087:                this .children = children;
088:                this .bboxCenter = bboxCenter;
089:                this .bboxSize = bboxSize;
090:                addChildren = new MFNode();
091:                removeChildren = new MFNode();
092:                initGroupBaseFields();
093:            }
094:
095:            /**
096:             *  Description of the Method
097:             *
098:             *@param  eventInName Description of the Parameter
099:             *@param  time Description of the Parameter
100:             */
101:            public void notifyMethod(String eventInName, double time) {
102:                if (eventInName.equals("addChildren")) {
103:                    MFNode newKids = (MFNode) FieldSpec.get(eventInName);
104:                    doAddChildren(newKids);
105:                } else if (eventInName.equals("removeChildren")) {
106:                    MFNode badKids = (MFNode) FieldSpec.get(eventInName);
107:                    doRemoveChildren(badKids);
108:                } else if (eventInName.equals("children")) {
109:                    replaceChildren();
110:                } else if (eventInName.equals("route_children")) {
111:                    implGroup
112:                            .setCapability(javax.media.j3d.Group.ALLOW_CHILDREN_READ);
113:                    implGroup
114:                            .setCapability(javax.media.j3d.Group.ALLOW_CHILDREN_WRITE);
115:                    implGroup
116:                            .setCapability(javax.media.j3d.Group.ALLOW_CHILDREN_EXTEND);
117:                } else {
118:                    System.out.println("GroupBase: unknown eventInName: "
119:                            + eventInName);
120:                }
121:
122:            }
123:
124:            // the children field has been updated. Remove any nodes on the implGroup
125:            // and add the current list to the implGroup
126:            /**  Description of the Method */
127:            void replaceChildren() {
128:                int numChildren;
129:                if ((numChildren = implGroup.numChildren()) != 0) {
130:                    for (int i = 0; i < numChildren; i++) {
131:                        implGroup.removeChild(0);// should shift the rest down...
132:                    }
133:                }
134:                for (int i = 0; i < children.nodes.length; i++) {
135:                    BaseNode child = children.nodes[i];
136:
137:                    child.updateParent(implGroup);
138:                    // let the new child know this is their vrml parent
139:                    child.parent = this ;
140:                    boolean doit = false;
141:                    if (child instanceof  VrmlSensor) {
142:                        doit = true;
143:                    }
144:                    if (child instanceof  ProtoInstance) {
145:                        if (((ProtoInstance) child).containsSensor) {
146:                            Enumeration e = (((ProtoInstance) child).sensors)
147:                                    .elements();
148:                            while (e.hasMoreElements()) {
149:                                BaseNode vs = (BaseNode) (e.nextElement());
150:                                vs.updateParent(implGroup);
151:                            }
152:                            doit = true;
153:                        }
154:                    }
155:                    if (doit) {
156:                        implGroup
157:                                .setCapability(javax.media.j3d.Group.ENABLE_PICK_REPORTING);
158:                        implGroup
159:                                .setCapability(javax.media.j3d.Group.ALLOW_BOUNDS_READ);
160:                        implGroup
161:                                .setCapability(javax.media.j3d.Group.ALLOW_AUTO_COMPUTE_BOUNDS_READ);
162:                        implGroup
163:                                .setCapability(javax.media.j3d.Group.ALLOW_LOCAL_TO_VWORLD_READ);
164:                        implGroup.setPickable(true);
165:                    }
166:
167:                    // add the child's impl to the j3d group
168:                    javax.media.j3d.Node implNode = child.getImplNode();
169:                    if (loader.debug) {
170:                        System.out.println(this .toStringId() + ":  index = "
171:                                + i + " child node type is " + child.getType()
172:                                + " " + child.toStringId()
173:                                + " gets implNoded to " + implNode);
174:                    }
175:                    if (implNode != null) {
176:                        if (implNode.getParent() == null) {
177:                            implGroup.addChild(implNode);
178:                        } else {
179:                            implGroup.addChild(implNode.cloneNode(true));
180:                        }
181:                        if (child instanceof  DirectionalLight) {
182:                            DirectionalLight dirLight = (DirectionalLight) child;
183:                            dirLight.setScope(implGroup);
184:                        }
185:                    }
186:                }
187:            }
188:
189:            /**
190:             *  Gets the numTris attribute of the GroupBase object
191:             *
192:             *@return  The numTris value
193:             */
194:            public int getNumTris() {
195:                int numTris = 0;
196:                for (int i = 0; i < children.nodes.length; i++) {
197:                    BaseNode child = children.nodes[i];
198:                    numTris += child.getNumTris();
199:                }
200:                return numTris;
201:            }
202:
203:            /**
204:             *  Description of the Method
205:             *
206:             *@param  newChildren Description of the Parameter
207:             */
208:            void doAddChildren(MFNode newChildren) {
209:                BaseNode[] newCh = newChildren.getValue();
210:                BaseNode[] oldCh = children.getValue();
211:
212:                Vector v = new Vector(newCh.length + oldCh.length);
213:                for (int i = 0; i < oldCh.length; i++) {
214:                    v.addElement(oldCh[i]);
215:                }
216:
217:                for (int i = 0; i < newCh.length; i++) {
218:                    if (loader.debug) {
219:                        System.out.println(this  + " doAddChildren " + newCh[i]);
220:                    }
221:                    v.addElement(newCh[i]);
222:                }
223:
224:                BaseNode[] newFamily = new BaseNode[newCh.length + oldCh.length];
225:                v.copyInto(newFamily);
226:
227:                children = new MFNode(newFamily);
228:                FieldSpec.remove("children");
229:                children.init(this , FieldSpec, Field.EXPOSED_FIELD, "children");
230:
231:                replaceChildren();
232:            }
233:
234:            /**
235:             *  Description of the Method
236:             *
237:             *@param  removeChildren Description of the Parameter
238:             */
239:            void doRemoveChildren(MFNode removeChildren) {
240:                BaseNode[] oldCh = children.getValue();// where do new children
241:                // get thier values from? MTV
242:                BaseNode[] removeCh = removeChildren.getValue();
243:
244:                Vector v = new Vector(children.getValue().length);
245:
246:                for (int i = 0; i < oldCh.length; i++) {
247:                    v.addElement(oldCh[i]);
248:                }
249:
250:                for (int i = 0; i < removeCh.length; i++) {
251:                    // unfortunately these children don't
252:                    // go to the prinicpals office!
253:                    // ever see soilent green?
254:                    if (loader.debug) {
255:                        System.out.println("doRemoveChildren " + removeCh[i]);
256:                    }
257:                    v.removeElement(removeCh[i]);
258:                }
259:
260:                BaseNode[] newFamily = new BaseNode[children.getSize()
261:                        - removeCh.length];
262:                v.copyInto(newFamily);
263:
264:                children = new MFNode(newFamily);
265:                FieldSpec.remove("children");
266:                FieldSpec.put("children", children);
267:                replaceChildren();
268:            }
269:
270:            /**
271:             *  Gets the type attribute of the GroupBase object
272:             *
273:             *@return  The type value
274:             */
275:            public String getType() {
276:                return "Group";
277:            }
278:
279:            // this may be overridden by subclasses
280:            /**  Description of the Method */
281:            void initFields() {
282:            }
283:
284:            /**  Description of the Method */
285:            void initGroupBaseFields() {
286:                addChildren
287:                        .init(this , FieldSpec, Field.EVENT_IN, "addChildren");
288:                removeChildren.init(this , FieldSpec, Field.EVENT_IN,
289:                        "removeChildren");
290:                children.init(this , FieldSpec, Field.EXPOSED_FIELD, "children");
291:                bboxCenter.init(this , FieldSpec, Field.FIELD, "bboxCenter");
292:                bboxSize.init(this , FieldSpec, Field.FIELD, "bboxSize");
293:            }
294:
295:            /**
296:             *  Description of the Method
297:             *
298:             *@return  Description of the Return Value
299:             */
300:            public String toStringBodyS() {
301:                String retval = "children " + children;
302:                if ((bboxCenter.value[0] != 0.0)
303:                        || (bboxCenter.value[1] != 0.0)
304:                        || (bboxCenter.value[2] != 0.0)) {
305:                    retval += "bboxCenter " + bboxCenter;
306:                }
307:                if ((bboxSize.value[0] != -1.0) || (bboxSize.value[1] != -1.0)
308:                        || (bboxSize.value[2] != -1.0)) {
309:                    retval += "bboxSize " + bboxSize;
310:                }
311:                return retval;
312:            }
313:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.