Package com.sun.j3d.utils.scenegraph.io
Class SceneGraphFileReader
- java.lang.Object
-
- com.sun.j3d.utils.scenegraph.io.SceneGraphFileReader
-
public class SceneGraphFileReader extends java.lang.ObjectRead Java3D BranchGraphs and/or Universe from a file. Individual branchgraphs or an entire Universe can be read and references (shared nodes and components) between the graphs are handled correctly.
-
-
Constructor Summary
Constructors Constructor Description SceneGraphFileReader(java.io.File file)Creates new SceneGraphFileReader.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Close the file and cleanup internal data structuresvoiddereferenceBranchGraph(BranchGroup graph)Remove the IO system's reference to this branchgraph and all its nodes.intgetBranchGraphCount()Return the number of BranchGraphs in the fileintgetBranchGraphPosition(BranchGroup graph)Given a BranchGraph that has been loaded return the index of the graph in the file.java.lang.ClassLoadergetClassLoader()Get the ClassLoader used to load the scene graph objects and deserialize user dataSceneGraphObjectgetNamedObject(java.lang.String name)Return the named object.java.lang.String[]getNames()Return the names of all the named objectsBranchGroup[]readAllBranchGraphs()Read and return all the branchgraphs in the fileBranchGroup[]readBranchGraph(int index)Read the BranchGraph at index in the file.java.lang.ObjectreadBranchGraphUserData(int index)Read the userdata for the branchgraph at 'index' in the filejava.lang.StringreadDescription()Get the Description of this file's contentsConfiguredUniversereadUniverse(boolean attachBranchGraphs)Create and return a ConfiguredUniverse with the PlatformGeometry, ViewerAvatar, and Locales saved in the file.ConfiguredUniversereadUniverse(boolean attachBranchGraphs, Canvas3D canvas)Create and return a ConfiguredUniverse with the PlatformGeometry, ViewerAvatar, and Locales saved in the file.java.lang.ObjectreadUserData()Get the UserData in the File headervoidsetClassLoader(java.lang.ClassLoader classLoader)Set the ClassLoader used to load the scene graph objects and deserialize user data
-
-
-
Method Detail
-
readUniverse
public ConfiguredUniverse readUniverse(boolean attachBranchGraphs) throws java.io.IOException
Create and return a ConfiguredUniverse with the PlatformGeometry, ViewerAvatar, and Locales saved in the file. The MultiTransformGroup between the ViewingPlatform and the View is also restored. Universe configuration information is retrieved viaConfiguredUniverse.getConfigURL().If the file does not contain universe information, null is returned.
- Parameters:
attachBranchGraphs- load and attach all the branchgraphs to the universe.- Throws:
java.io.IOException- See Also:
ConfiguredUniverse.getConfigURL()
-
setClassLoader
public void setClassLoader(java.lang.ClassLoader classLoader)
Set the ClassLoader used to load the scene graph objects and deserialize user data
-
getClassLoader
public java.lang.ClassLoader getClassLoader()
Get the ClassLoader used to load the scene graph objects and deserialize user data
-
readUniverse
public ConfiguredUniverse readUniverse(boolean attachBranchGraphs, Canvas3D canvas) throws java.io.IOException
Create and return a ConfiguredUniverse with the PlatformGeometry, ViewerAvatar, and Locales saved in the file. The MultiTransformGroup between the ViewingPlatform and the View is also restored.If the file does not contain universe information, null is returned.
- Parameters:
attachBranchGraphs- load and attach all the branchgraphs to the universe.canvas- The canvas to be associated with the Universe.- Throws:
java.io.IOException
-
readUserData
public java.lang.Object readUserData() throws java.io.IOExceptionGet the UserData in the File header- Throws:
java.io.IOException
-
readDescription
public java.lang.String readDescription() throws java.io.IOExceptionGet the Description of this file's contents- Throws:
java.io.IOException
-
getBranchGraphCount
public int getBranchGraphCount()
Return the number of BranchGraphs in the file
-
readBranchGraph
public BranchGroup[] readBranchGraph(int index) throws java.io.IOException
Read the BranchGraph at index in the file. If the graph contains references to nodes in other BranchGraphs that have not already been loaded, they will also be loaded and returned.The requested graph will always be the first element in the array.
The file index of all the Graphs can be discovered using
getBranchGraphPosition.- Parameters:
index- The index of the Graph in the file. First graph is at index 0- Throws:
java.io.IOException- See Also:
getBranchGraphPosition( BranchGroup graph )
-
readAllBranchGraphs
public BranchGroup[] readAllBranchGraphs() throws java.io.IOException
Read and return all the branchgraphs in the file- Throws:
java.io.IOException
-
dereferenceBranchGraph
public void dereferenceBranchGraph(BranchGroup graph)
Remove the IO system's reference to this branchgraph and all its nodes.References to all loaded graphs are maintained by the IO system in order to facilitate node and component sharing between the graphs.
This call removes the references to graph
indexNOT CURRENTLY IMPLEMENTED
-
getBranchGraphPosition
public int getBranchGraphPosition(BranchGroup graph)
Given a BranchGraph that has been loaded return the index of the graph in the file. The the Branchgroup isn't found, -1 is returned.
-
readBranchGraphUserData
public java.lang.Object readBranchGraphUserData(int index) throws java.io.IOExceptionRead the userdata for the branchgraph at 'index' in the file- Parameters:
index- the index of the graph in the file- Throws:
java.io.IOException
-
getNames
public java.lang.String[] getNames()
Return the names of all the named objects
-
getNamedObject
public SceneGraphObject getNamedObject(java.lang.String name) throws NamedObjectException, ObjectNotLoadedException
Return the named object.- Parameters:
name- The name of the object- Throws:
NamedObjectException- is thrown if the name is not known to the systemObjectNotLoadedException- is thrown if the named object has not been loaded yet
-
close
public void close() throws java.io.IOExceptionClose the file and cleanup internal data structures- Throws:
java.io.IOException
-
-