Source Code Cross Referenced for Switch.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: Switch.java,v $
003:         *
004:         *      @(#)Switch.java 1.21 98/11/05 20:35:24
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:02 $
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.Vector;
044:
045:        /**  Description of the Class */
046:        public class Switch extends NonSharedNode {
047:            // exposedField
048:            MFNode choice;
049:
050:            // field
051:            SFInt32 whichChoice;
052:
053:            javax.media.j3d.Switch impl;
054:
055:            /**
056:             *Constructor for the Switch object
057:             *
058:             *@param  loader Description of the Parameter
059:             */
060:            public Switch(Loader loader) {
061:                super (loader);
062:                choice = new MFNode();
063:                whichChoice = new SFInt32(-1);
064:                initFields();
065:            }
066:
067:            /**
068:             *Constructor for the Switch object
069:             *
070:             *@param  loader Description of the Parameter
071:             *@param  choice Description of the Parameter
072:             *@param  whichChoice Description of the Parameter
073:             */
074:            Switch(Loader loader, MFNode choice, SFInt32 whichChoice) {
075:                super (loader);
076:                this .choice = choice;
077:                this .whichChoice = whichChoice;
078:                initFields();
079:            }
080:
081:            /**  Description of the Method */
082:            void initImpl() {
083:                if (loader.debug) {
084:                    System.out.println("Switch.initImpl() called");
085:                }
086:                impl = new javax.media.j3d.Switch();
087:                impl.setCapability(javax.media.j3d.Switch.ALLOW_SWITCH_READ);
088:                impl.setCapability(javax.media.j3d.Switch.ALLOW_SWITCH_WRITE);
089:                impl.setCapability(javax.media.j3d.Group.ALLOW_CHILDREN_READ);
090:                impl.setCapability(javax.media.j3d.Group.ALLOW_CHILDREN_WRITE);
091:                impl.setCapability(javax.media.j3d.Group.ALLOW_CHILDREN_EXTEND);
092:                impl.setUserData(new Vector());
093:                replaceChoices();
094:                setWhichChild();
095:                if (loader.debug) {
096:                    System.out.println("Switch " + toStringId() + " impl is "
097:                            + impl);
098:                }
099:                implNode = impl;
100:                implReady = true;
101:            }
102:
103:            /**  Sets the whichChild attribute of the Switch object */
104:            void setWhichChild() {
105:                if (browser.debug) {
106:                    System.out.println("Switch: setting " + whichChoice.value);
107:                }
108:                if (whichChoice.value < 0
109:                        || whichChoice.value > impl.numChildren()) {
110:                    impl.setWhichChild(javax.media.j3d.Switch.CHILD_NONE);
111:                } else {
112:                    impl.setWhichChild(whichChoice.value);
113:                }
114:            }
115:
116:            // the choice field has been updated. Remove any nodes on the impl
117:            // and add the current list to the impl
118:            /**  Description of the Method */
119:            void replaceChoices() {
120:                int numChildren;
121:                if ((numChildren = impl.numChildren()) != 0) {
122:                    for (int i = 0; i < numChildren; i++) {
123:                        impl.removeChild(0);// should shift the rest down...
124:                    }
125:                }
126:                for (int i = 0; i < choice.nodes.length; i++) {
127:                    BaseNode child = choice.nodes[i];
128:
129:                    // let the new child know this is their parent
130:                    child.updateParent(impl);
131:
132:                    // add the child's impl to the j3d group
133:                    javax.media.j3d.Node implNode = child.getImplNode();
134:                    if (loader.debug) {
135:                        System.out.println(this .toStringId() + ":  index = "
136:                                + i + " child node type is " + child.getType()
137:                                + " " + child.toStringId()
138:                                + " gets implNoded to " + implNode);
139:                    }
140:                    if (implNode != null) {
141:                        if (implNode.getParent() == null) {
142:                            impl.addChild(implNode);
143:                        } else {
144:                            impl.addChild(implNode.cloneNode(true));
145:                        }
146:                        if (child instanceof  DirectionalLight) {
147:                            DirectionalLight dirLight = (DirectionalLight) child;
148:                            dirLight.setScope(impl);
149:                        }
150:                    }
151:                }
152:            }
153:
154:            // return the number of tris in choice 0
155:            /**
156:             *  Gets the numTris attribute of the Switch object
157:             *
158:             *@return  The numTris value
159:             */
160:            public int getNumTris() {
161:                int numTris = 0;
162:                if ((choice != null) && (choice.nodes != null)
163:                        && (choice.nodes.length > 0)) {
164:                    numTris += choice.nodes[0].getNumTris();
165:                }
166:                return numTris;
167:            }
168:
169:            /**
170:             *  Description of the Method
171:             *
172:             *@param  eventInName Description of the Parameter
173:             *@param  time Description of the Parameter
174:             */
175:            public void notifyMethod(String eventInName, double time) {
176:                if (eventInName.equals("choice")) {
177:                    replaceChoices();
178:                } else if (eventInName.equals("whichChoice")) {
179:                    setWhichChild();
180:                }
181:            }
182:
183:            /**
184:             *  Description of the Method
185:             *
186:             *@return  Description of the Return Value
187:             */
188:            public Object clone() {
189:                return new Switch(loader, (MFNode) choice.clone(),
190:                        (SFInt32) whichChoice.clone());
191:            }
192:
193:            /**
194:             *  Gets the type attribute of the Switch object
195:             *
196:             *@return  The type value
197:             */
198:            public String getType() {
199:                return "Switch";
200:            }
201:
202:            /**  Description of the Method */
203:            void initFields() {
204:                choice.init(this , FieldSpec, Field.EXPOSED_FIELD, "choice");
205:                whichChoice.init(this , FieldSpec, Field.EXPOSED_FIELD,
206:                        "whichChoice");
207:            }
208:
209:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.