Source Code Cross Referenced for Traverser.java in  » 6.0-JDK-Modules » java-3d » org » jdesktop » j3dedit » scenegrapheditor » sourcecontrol » 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.j3dedit.scenegrapheditor.sourcecontrol 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         *  $Header: /cvs/j3dfly/J3dEditor/src/org/jdesktop/j3dedit/scenegrapheditor/sourcecontrol/Traverser.java,v 1.1 2005/04/20 22:21:21 paulby Exp $
003:         *
004:         *                         Sun Public License Notice
005:         *
006:         *  The contents of this file are subject to the Sun Public License Version
007:         *  1.0 (the "License"). You may not use this file except in compliance with
008:         *  the License. A copy of the License is available at http://www.sun.com/
009:         *  
010:         *  The Original Code is the Java 3D(tm) Scene Graph Editor.
011:         *  The Initial Developer of the Original Code is Jan Becicka.
012:         *  Portions created by Jan Becicka are Copyright (C) 2002.
013:         *  All Rights Reserved.
014:         *  
015:         *  Contributor(s): Jan Becicka.
016:         *  
017:         **/
018:        package org.jdesktop.j3dedit.scenegrapheditor.sourcecontrol;
019:
020:        import org.jdesktop.j3dedit.scenegraph.SGObject;
021:        import java.util.ArrayList;
022:        import java.util.LinkedList;
023:        import java.util.List;
024:        import java.util.Iterator;
025:        import java.lang.StringBuffer;
026:        import java.lang.reflect.Constructor;
027:        import java.lang.reflect.InvocationTargetException;
028:        import org.jdesktop.j3dedit.J3dEditContext;
029:        import java.util.Vector;
030:        import java.util.Enumeration;
031:        import org.jdesktop.j3dedit.scenegraph.SGLocale;
032:        import org.jdesktop.j3dedit.scenegrapheditor.nodeeditors.panels.TextureExtraData;
033:        import org.jdesktop.j3dedit.scenegraph.SGTexture;
034:        import org.jdesktop.j3dedit.scenegraph.SGGroup;
035:
036:        /** Traverser for Scene Graph
037:         * @author Jan Becicka
038:         * @version 0.1
039:         */
040:        public class Traverser {
041:
042:            /** Holds value of property root. */
043:            private SGObject root;
044:
045:            /** Holds value of property namePool. */
046:            private NamePool namePool;
047:
048:            /** Holds value of property fields. */
049:            private ArrayList fields;
050:
051:            /** Holds value of property constructionCodeLines. */
052:            private LinkedList constructionCodeLines;
053:
054:            /** Holds value of property customizationCodeLines. */
055:            private LinkedList customizationCodeLines;
056:
057:            /** Holds value of property needToProcess. */
058:            private Vector needToProcess;
059:
060:            private Object currentBean;
061:
062:            private J3dEditContext context;
063:
064:            /** Creates new Traverser
065:             * @param root  */
066:            public Traverser(J3dEditContext context, SGObject root) {
067:                // TODO We can get context from root.getContext() so it should
068:                // be removed from the constructor
069:                this (context, root, new NamePool());
070:            }
071:
072:            public Traverser(J3dEditContext context, SGObject root, NamePool np) {
073:                // TODO We can get context from root.getContext() so it should
074:                // be removed from the constructor
075:                this .context = context;
076:                setRoot(root);
077:                namePool = np;
078:                needToProcess = new Vector();
079:                fields = new ArrayList();
080:                constructionCodeLines = new LinkedList();
081:                customizationCodeLines = new LinkedList();
082:                putNames();
083:            }
084:
085:            /** Put names from SGObject tree into NamePool
086:             */
087:            private void putNames() {
088:                SGObject currentNode;
089:                LinkedList l = new LinkedList();
090:                l.add(root);
091:                while (!l.isEmpty()) {
092:                    currentNode = (SGObject) l.getFirst();
093:                    l.removeFirst();
094:                    if (currentNode.getNodeName() != null) {
095:                        namePool.put(currentNode.getJ3dSceneGraphObject(),
096:                                currentNode.getNodeName());
097:                    }
098:                    if (currentNode instanceof  SGTexture) {
099:                        namePool.put(currentNode.getJ3dSceneGraphObject(),
100:                                ((TextureExtraData) currentNode
101:                                        .getSGObjectExtraData()).getImageURL()
102:                                        .toString());
103:                    }
104:                    if (currentNode instanceof  SGGroup) {
105:                        for (int i = 0; i < ((SGGroup) currentNode)
106:                                .numChildren(); i++) {
107:                            l.add(((SGGroup) currentNode).getChild(i));
108:                        }
109:                    }
110:                }
111:            }
112:
113:            private void initNTP() {
114:                if (root instanceof  SGLocale) {
115:                    needToProcess.add(((SGLocale) root).getLocale());
116:                } else {
117:                    needToProcess.add(root.getJ3dSceneGraphObject());
118:                }
119:
120:            }
121:
122:            /** traverses the structure
123:             */
124:            public void traverse() {
125:                initNTP();
126:                BeanCodeGenerator g = null;
127:                Delegator d = new Delegator(context, namePool);
128:                Enumeration ntpe = needToProcess.elements();
129:                while (ntpe.hasMoreElements()) {
130:                    currentBean = ntpe.nextElement();
131:                    g = d.getBeanCodeGenerator(currentBean);
132:
133:                    addNeedToProcessBeans(g.getNeedToProcessBeans());
134:                    addFields(g.getDeclarationCode());
135:                    addConstructionCode(g.getConstructionCode());
136:                    addCustomizationCode(g.getCustomizationCode());
137:                }
138:            }
139:
140:            /** Inserts beans which need to be processed
141:             */
142:            private void addNeedToProcessBeans(List l) {
143:                //pokud tam jeste neni, tak ho tam pridam
144:                Iterator i = l.iterator();
145:                while (i.hasNext()) {
146:                    Object o = i.next();
147:                    if (!needToProcess.contains(o)) {
148:                        needToProcess.add(o);
149:                    }
150:                }
151:            }
152:
153:            /** addFields, which wants to be declared
154:             * @param f  */
155:            private void addFields(String f) {
156:                if (f != null) {
157:                    fields.add(f);
158:                }
159:            }
160:
161:            /** Add construction code e.g. <CODE>t = new TransformGroup()</CODE>
162:             * @param c
163:             */
164:            private void addConstructionCode(String c) {
165:                if (c != null) {
166:                    if (currentBean instanceof  javax.media.j3d.Behavior) {
167:                        constructionCodeLines.addLast(c);
168:                    } else {
169:                        constructionCodeLines.addFirst(c);
170:                    }
171:                }
172:            }
173:
174:            /** adds customization code e.g. <CODE>t.setTransform();</CODE>
175:             */
176:            private void addCustomizationCode(String c) {
177:                if (c != null) {
178:                    customizationCodeLines.addFirst(c);
179:                }
180:            }
181:
182:            /** Getter for property root.
183:             * @return Value of property root.
184:             */
185:            public SGObject getRoot() {
186:                return root;
187:            }
188:
189:            /** Setter for property root.
190:             * @param root New value of property root.
191:             */
192:            public void setRoot(SGObject root) {
193:                this .root = root;
194:            }
195:
196:            /** Getter for property namePool.
197:             * @return Value of property namePool.
198:             */
199:            public NamePool getNamePool() {
200:                return namePool;
201:            }
202:
203:            /** Getter for property fields.
204:             * @return Value of property fields.
205:             */
206:            public ArrayList getFields() {
207:                return fields;
208:            }
209:
210:            /** Getter for property constructionCodeLines.
211:             * @return Value of property constructionCodeLines.
212:             */
213:            public LinkedList getConstructionCodeLines() {
214:                return constructionCodeLines;
215:            }
216:
217:            /** Getter for property customizationCodeLines.
218:             * @return Value of property customizationCodeLines.
219:             */
220:            public LinkedList getCustomizationCodeLines() {
221:                return customizationCodeLines;
222:            }
223:
224:            /** Getter for property needToProcess.
225:             * @return Value of property needToProcess.
226:             */
227:            public Vector getNeedToProcess() {
228:                return needToProcess;
229:            }
230:
231:            /**
232:             * @return  */
233:            public String toString() {
234:                Iterator f = fields.iterator();
235:                Iterator c = constructionCodeLines.iterator();
236:                Iterator s = customizationCodeLines.iterator();
237:
238:                StringBuffer b = new StringBuffer();
239:
240:                while (f.hasNext()) {
241:                    b.append(f.next());
242:                }
243:
244:                while (c.hasNext()) {
245:                    b.append(c.next());
246:                }
247:
248:                while (s.hasNext()) {
249:                    b.append(s.next());
250:                }
251:
252:                return b.toString();
253:            }
254:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.