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


001:        /*
002:         * Copyright (c) 2001 Silvere Martin-Michiellot All Rights Reserved.
003:         *
004:         * Silvere Martin-Michiellot grants you ("Licensee") a non-exclusive,
005:         * royalty free, license to use, modify and redistribute this
006:         * software in source and binary code form,
007:         * provided that i) this copyright notice and license appear on all copies of
008:         * the software; and ii) Licensee does not utilize the software in a manner
009:         * which is disparaging to Silvere Martin-Michiellot.
010:         *
011:         * This software is provided "AS IS," without a warranty of any kind. ALL
012:         * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING ANY
013:         * IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR
014:         * NON-INFRINGEMENT, ARE HEREBY EXCLUDED. Silvere Martin-Michiellot
015:         * AND ITS LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES
016:         * SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING
017:         * OR DISTRIBUTING THE SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL
018:         * Silvere Martin-Michiellot OR ITS LICENSORS BE LIABLE
019:         * FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT,
020:         * INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER
021:         * CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF
022:         * OR INABILITY TO USE SOFTWARE, EVEN IF Silvere Martin-Michiellot HAS BEEN
023:         * ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
024:         *
025:         * This software is not designed or intended for use in on-line control of
026:         * aircraft, air traffic, aircraft navigation or aircraft communications; or in
027:         * the design, construction, operation or maintenance of any nuclear
028:         * facility. Licensee represents and warrants that it will not use or
029:         * redistribute the Software for such purposes.
030:         *
031:         * @Author: Silvere Martin-Michiellot
032:         *
033:         */
034:
035:        // This code is repackaged after the code from Sun by Rick Goldberg and Doug Gehringer
036:        // Site http://java.sun.com/
037:        // Email
038:
039:        package com.db.utils.tree;
040:
041:        import javax.media.j3d.*;
042:        import java.io.PrintStream;
043:        import java.util.Set;
044:        import java.util.HashSet;
045:        import java.util.Enumeration;
046:        import java.util.Iterator;
047:
048:        public class TreePrinter {
049:
050:            PrintStream printStream;
051:            String j3dPkg = new String("javax.media.j3d.");
052:
053:            public void print(PrintStream s, Locale l) {
054:
055:                printStream = s;
056:                HashSet sharedGroups = new HashSet();
057:                printTree(l, 0, sharedGroups);
058:                Iterator iterator = sharedGroups.iterator();
059:                while (iterator.hasNext()) {
060:                    SharedGroup sg = (SharedGroup) iterator.next();
061:                    print(s, sg);
062:                }
063:
064:            }
065:
066:            public void print(Locale l) {
067:
068:                print(System.out, l);
069:
070:            }
071:
072:            private void printTree(Locale l, int graphDepth, Set sharedGroups) {
073:
074:                printNode(l, 0, sharedGroups);
075:                try {
076:                    Enumeration e = l.getAllBranchGraphs();
077:                    while (e.hasMoreElements()) {
078:                        Object o = e.nextElement();
079:                        if (o instanceof  Locale)
080:                            printTree((Locale) o, graphDepth + 1, sharedGroups);
081:                        else if (o instanceof  SceneGraphObject)
082:                            printTree((SceneGraphObject) o, graphDepth + 1,
083:                                    sharedGroups);
084:                        else
085:                            printStream.println(o + " unknown and in tree");
086:                    }
087:                } catch (CapabilityNotSetException e) {
088:                    printStream.println("No capability to read children");
089:                }
090:
091:            }
092:
093:            public void print(PrintStream s, SceneGraphObject sgo) {
094:
095:                printStream = s;
096:                HashSet sharedGroups = new HashSet();
097:                printTree(sgo, 0, sharedGroups);
098:                Iterator iterator = sharedGroups.iterator();
099:                while (iterator.hasNext()) {
100:                    SharedGroup sg = (SharedGroup) iterator.next();
101:                    print(s, sg);
102:                }
103:
104:            }
105:
106:            public void print(SceneGraphObject sgo) {
107:
108:                print(System.out, sgo);
109:
110:            }
111:
112:            private void printTree(SceneGraphObject sgo, int graphDepth,
113:                    Set sharedGroups) {
114:
115:                printNode(sgo, graphDepth, sharedGroups);
116:                if (sgo instanceof  javax.media.j3d.Group) {
117:                    try {
118:                        Enumeration e = ((javax.media.j3d.Group) sgo)
119:                                .getAllChildren();
120:                        while (e.hasMoreElements()) {
121:                            printTree((SceneGraphObject) (e.nextElement()),
122:                                    graphDepth + 1, sharedGroups);
123:                        }
124:                    } catch (CapabilityNotSetException e) {
125:                        // Can't read handled below
126:                    }
127:                }
128:
129:            }
130:
131:            private String nodeString(Object o) {
132:
133:                String objString = o.toString();
134:                if (objString.startsWith(j3dPkg)) {
135:                    objString = objString.substring(j3dPkg.length());
136:                }
137:
138:                return objString;
139:
140:            }
141:
142:            private void printNode(Object o, int indent, Set sharedGroups) {
143:
144:                for (int i = 0; i < indent; i++)
145:                    printStream.print(">");
146:                printStream.print(nodeString(o) + ": ");
147:                if (o instanceof  SceneGraphObject) {
148:                    SceneGraphObject sgo = (SceneGraphObject) o;
149:                    int capBits = 0;
150:                    // TODO: how to make sure we always check all the valid bits?
151:                    for (int i = 0; i < 64; i++) {
152:                        if (sgo.getCapability(i)) {
153:                            capBits |= 1 << i;
154:                        }
155:                    }
156:                    printStream.print("capBits:Ox"
157:                            + Integer.toHexString(capBits));
158:                    if (o instanceof  javax.media.j3d.Group) {
159:                        javax.media.j3d.Group g = (javax.media.j3d.Group) o;
160:                        int numChildren = 0;
161:                        try {
162:                            numChildren = g.numChildren();
163:                        } catch (CapabilityNotSetException e) {
164:                            //anyone who is using treePrinter, is debugging, so it is
165:                            //alright to blindly allow read. you should first detach
166:                            //browser.curScene, print the tree, then add it back to
167:                            //browser.locale when finished.
168:                            g
169:                                    .setCapability(javax.media.j3d.Group.ALLOW_CHILDREN_READ);
170:                            numChildren = g.numChildren();
171:                            //System.out.println("Can't read children on group");
172:                            //return;
173:                        }
174:                        printStream.print(" children:" + numChildren);
175:                        if (o instanceof  TransformGroup) {
176:                            Transform3D transform = new Transform3D();
177:                            Transform3D identity = new Transform3D();
178:                            TransformGroup t = (TransformGroup) o;
179:                            t.getTransform(transform);
180:                            // TODO: use getBestType() when implemented
181:                            if (transform.equals(identity)) {
182:                                printStream.print(" xform:IDENTITY ");
183:                            } else {
184:                                printStream.print(" xform:NON-IDENTITY ");
185:                            }
186:                        }
187:                    } else if (o instanceof  Link) {
188:                        Link l = (Link) o;
189:                        SharedGroup sg = l.getSharedGroup();
190:                        printStream.print(" sg:" + nodeString(sg));
191:                        sharedGroups.add(sg);
192:                    } else {
193:                        printStream.print(": leaf");
194:                    }
195:                }
196:                printStream.println();
197:
198:            }
199:
200:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.