Source Code Cross Referenced for SceneGraphFileWriter.java in  » 6.0-JDK-Modules » java-3d » com » sun » j3d » utils » scenegraph » io » 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.sun.j3d.utils.scenegraph.io 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * $RCSfile: SceneGraphFileWriter.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:20:27 $
042:         * $State: Exp $
043:         */
044:
045:        package com.sun.j3d.utils.scenegraph.io;
046:
047:        import java.io.File;
048:        import java.io.IOException;
049:        import java.util.HashMap;
050:        import java.util.Map;
051:        import java.util.Iterator;
052:
053:        import javax.media.j3d.BranchGroup;
054:        import javax.media.j3d.SceneGraphObject;
055:        import javax.media.j3d.CapabilityNotSetException;
056:        import com.sun.j3d.utils.scenegraph.io.retained.RandomAccessFileControl;
057:        import com.sun.j3d.utils.universe.SimpleUniverse;
058:
059:        /**
060:         * Write a (set) of Java3D BranchGraphs and/or Universe to a file. The BranchGraphs 
061:         * are stored in the order in which they are written, they can be read in any order
062:         * using SceneGraphFileReader.
063:         *
064:         * The API handles Nodes and NodeComponents that are shared between seperate 
065:         * graphs. It will handle all Java3D 1.3 core classes and any user
066:         * subclass of a Node or NodeComponent that implements the SceneGraphIO
067:         * interface.
068:         */
069:        public class SceneGraphFileWriter extends java.lang.Object {
070:
071:            private RandomAccessFileControl fileControl;
072:            private File file;
073:
074:            /** Creates new SceneGraphFileWriter and opens the file for writing.
075:             *
076:             * <P>Writes the 
077:             * Java3D Universe structure to the file. This includes the number and position of
078:             * the Locales, PlatformGeometry, ViewerAvatar, and the MultitransformGroup between
079:             * the ViewingPlatform and the View. However this
080:             * call does not write the content of the branch graphs unless writeUniverseContent is true.
081:             * <code>universe</code> may be null.
082:             * This call will overwrite any existing universe, fileDescription and
083:             * userData in the file.</P>
084:             * 
085:             * <P>close() MUST be called when IO is complete. If close() is not called
086:             * the file contents will be undefined.</P>
087:             *
088:             * @param file The file to write the data to
089:             * @param universe The SimpleUniverse to write
090:             * @param writeUniverseContent If true, the content of the Locales will be written.
091:             * Otherwise just the universe configuration data will be written.
092:             * @param fileDescription A description of the file's content
093:             * @param fileUserData User defined object
094:             *
095:             * @exception IOException Thrown if there are any IO errors
096:             * @exception UnsupportedUniverseException Thrown if <code>universe</code> is not
097:             * a supported universe class. Currently SimpleUniverse and ConfiguredUniverse
098:             * are supported.
099:             */
100:            public SceneGraphFileWriter(java.io.File file,
101:                    SimpleUniverse universe, boolean writeUniverseContent,
102:                    String fileDescription, java.io.Serializable fileUserData)
103:                    throws IOException, UnsupportedUniverseException {
104:                fileControl = new RandomAccessFileControl();
105:                this .file = file;
106:                file.createNewFile();
107:
108:                if (!file.canWrite())
109:                    throw new IOException("Can not Write to File");
110:
111:                fileControl.createFile(file, universe, writeUniverseContent,
112:                        fileDescription, fileUserData);
113:            }
114:
115:            /**
116:             * Write the graph to the end of the file.
117:             *
118:             * close() MUST be called when IO is complete. If close() is not called
119:             * the file contents will be undefined.
120:             */
121:            public void writeBranchGraph(BranchGroup graph) throws IOException {
122:                writeBranchGraph(graph, null);
123:            }
124:
125:            /**
126:             * Write a branch graph and some user associated data to the
127:             * end of the file.
128:             *
129:             * close() MUST be called when IO is complete. If close() is not called
130:             * the file contents will be undefined.
131:             */
132:            public void writeBranchGraph(BranchGroup graph,
133:                    java.io.Serializable data) throws IOException {
134:                fileControl.writeBranchGraph(graph, data);
135:            }
136:
137:            /**
138:             * Add a named reference to a SceneGraphObject in the file.
139:             *
140:             * <code>object</code> must have been written to the file before this method is
141:             * called. If the object is not in the file a NamedObjectException will be thrown.
142:             *
143:             * Adding duplicate names will result in the old name being overwritten.
144:             * Different names can reference the same object
145:             */
146:            public void addObjectName(String name, SceneGraphObject object)
147:                    throws NamedObjectException {
148:                fileControl.addNamedObject(name, object);
149:            }
150:
151:            /**
152:             * Close the file and cleanup internal data structures.
153:             */
154:            public void close() throws IOException {
155:                fileControl.close();
156:            }
157:
158:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.