Source Code Cross Referenced for J3fLoader.java in  » 6.0-JDK-Modules » java-3d » org » jdesktop » j3d » loaders » wrappers » 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.wrappers 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * $RCSfile: J3fLoader.java,v $
003:         *
004:         * Copyright (c) 2007 Sun Microsystems, Inc. All rights reserved.
005:         *
006:         * Redistribution and use in source and binary forms, with or without
007:         * modification, are permitted provided that the following conditions
008:         * are met:
009:         *
010:         * - Redistribution of source code must retain the above copyright
011:         *   notice, this list of conditions and the following disclaimer.
012:         *
013:         * - Redistribution in binary form must reproduce the above copyright
014:         *   notice, this list of conditions and the following disclaimer in
015:         *   the documentation and/or other materials provided with the
016:         *   distribution.
017:         *
018:         * Neither the name of Sun Microsystems, Inc. or the names of
019:         * contributors may be used to endorse or promote products derived
020:         * from this software without specific prior written permission.
021:         *
022:         * This software is provided "AS IS," without a warranty of any
023:         * kind. ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND
024:         * WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY,
025:         * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY
026:         * EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL
027:         * NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF
028:         * USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS
029:         * DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR
030:         * ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL,
031:         * CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED AND
032:         * REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF OR
033:         * INABILITY TO USE THIS SOFTWARE, EVEN IF SUN HAS BEEN ADVISED OF THE
034:         * POSSIBILITY OF SUCH DAMAGES.
035:         *
036:         * You acknowledge that this software is not designed, licensed or
037:         * intended for use in the design, construction, operation or
038:         * maintenance of any nuclear facility.
039:         *
040:         * $Revision: 1.4 $
041:         * $Date: 2007/02/09 17:17:00 $
042:         * $State: Exp $
043:         */
044:
045:        package org.jdesktop.j3d.loaders.wrappers;
046:
047:        import com.sun.j3d.loaders.Scene;
048:        import com.sun.j3d.loaders.SceneBase;
049:
050:        import javax.media.j3d.BranchGroup;
051:
052:        import com.sun.j3d.utils.scenegraph.io.SceneGraphFileReader;
053:
054:        /**
055:         * Provides a Loader which can load Java3D scene graphs saved using the
056:         * SceneGraphFileWriter.
057:         *
058:         * The Java3D LoaderInterface implemented by this class does not provide access
059:         * to all the features that can be stored in a .j3f file.
060:         * Most importantly the file may contain a universe which will be ignored
061:         * by this loader.
062:         *
063:         * @author Paul Byrne
064:         * @version	1.8, 01/18/02
065:         */
066:        public class J3fLoader extends com.sun.j3d.loaders.LoaderBase {
067:
068:            private SceneGraphFileReader reader = null;
069:            //    private com.sun.j3d.demos.utils.scenegraph.io.SceneGraphFileReader oldReader=null;
070:            //    private static J3fLoaderListener loaderListener = null;
071:            private BranchGroup[] graphs = null;
072:            private static ClassLoader classLoader = null;
073:
074:            /**
075:             * Setup a listener to get notified when this loader is used
076:             */
077:            //    public static void setJ3fLoaderListener( J3fLoaderListener listener ) {
078:            //        loaderListener = listener;
079:            //    }
080:            /**
081:             * Set the ClassLoader which will be used by the SceneGraphIO system
082:             * when loading the scene graph.
083:             *
084:             * The default null in which case the system will use system class loader
085:             */
086:            public static void setClassLoader(ClassLoader cLoader) {
087:                classLoader = cLoader;
088:            }
089:
090:            /**
091:             * Get the ClassLoader set by setClassLoader
092:             *
093:             * If setClassLoader has not been called the default null will be returned.
094:             * This indicates that systemClassLoader will be used.
095:             */
096:            public static ClassLoader getClassLoader() {
097:                return classLoader;
098:            }
099:
100:            /**
101:             * Load all the BranchGraphs from the file called filename and return
102:             * a Scene containing all the BranchGraphs
103:             */
104:            public Scene load(String filename)
105:                    throws java.io.FileNotFoundException,
106:                    com.sun.j3d.loaders.IncorrectFormatException,
107:                    com.sun.j3d.loaders.ParsingErrorException {
108:
109:                SceneBase scenebase = null;
110:                Scene scene = null;
111:                try {
112:                    reader = new SceneGraphFileReader(
113:                            new java.io.File(filename));
114:                    if (classLoader != null)
115:                        reader.setClassLoader(classLoader);
116:                    int size = reader.getBranchGraphCount();
117:                    scenebase = new SceneBase();
118:
119:                    BranchGroup bg = new BranchGroup();
120:                    graphs = new BranchGroup[size];
121:
122:                    if (size > 1) {
123:                        for (int i = 0; i < size; i++) {
124:                            graphs[i] = reader.readBranchGraph(i)[0];
125:                            bg.addChild(graphs[i]);
126:                        }
127:                    } else {
128:                        bg = reader.readBranchGraph(0)[0];
129:                        graphs[0] = bg;
130:                    }
131:
132:                    scenebase.setSceneGroup(bg);
133:
134:                    String[] objectNames = reader.getNames();
135:                    for (int i = 0; i < objectNames.length; i++)
136:                        try {
137:                            scenebase.addNamedObject(objectNames[i], reader
138:                                    .getNamedObject(objectNames[i]));
139:                        } catch (com.sun.j3d.utils.scenegraph.io.ObjectNotLoadedException e) {
140:                        } catch (com.sun.j3d.utils.scenegraph.io.NamedObjectException e) {
141:                        }
142:
143:                    //            if (loaderListener!=null)
144:                    //                loaderListener.loadingJ3f( this );
145:                    reader.close();
146:
147:                } catch (java.io.InvalidClassException ex) {
148:                    throw new com.sun.j3d.loaders.IncorrectFormatException(ex
149:                            .getMessage());
150:                } catch (java.io.FileNotFoundException e) {
151:                    throw new java.io.FileNotFoundException(filename);
152:                } catch (java.io.IOException exc) {
153:                    throw new java.io.FileNotFoundException(exc.getMessage());
154:                }
155:
156:                if (scenebase == null)
157:                    return scene;
158:                else
159:                    return scenebase;
160:            }
161:
162:            /**
163:             * Scene only supports a single sceneBase.
164:             *
165:             * For any J3f files containing multiple BranchGraphs all the graphs
166:             * will be added as children of SceneBase.
167:             *
168:             * This call will return the actual set of BranchGraphs (this will
169:             * still be children of the sceneBase ). If their is only a single
170:             * branchgraph getBranchGrapgs()[0] == sceneBase
171:             */
172:            public BranchGroup[] getBranchGraphs() {
173:                return graphs;
174:            }
175:
176:            /**
177:             * Get the user object for the file, should be called from within a J3fLoaderListener only
178:             */
179:            public Object getFileUserData() throws java.io.IOException {
180:                return reader.readUserData();
181:            }
182:
183:            /** Not Implemented
184:             */
185:            public Scene load(java.net.URL url)
186:                    throws java.io.FileNotFoundException,
187:                    com.sun.j3d.loaders.IncorrectFormatException,
188:                    com.sun.j3d.loaders.ParsingErrorException {
189:                throw new RuntimeException("NOT IMPLEMENTED");
190:            }
191:
192:            /** Not Implemented
193:             */
194:            public Scene load(java.io.Reader reader)
195:                    throws java.io.FileNotFoundException,
196:                    com.sun.j3d.loaders.IncorrectFormatException,
197:                    com.sun.j3d.loaders.ParsingErrorException {
198:
199:                throw new RuntimeException("NOT IMPLEMENTED");
200:            }
201:
202:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.