Class SceneGraphFileWriter


  • public class SceneGraphFileWriter
    extends java.lang.Object
    Write a (set) of Java3D BranchGraphs and/or Universe to a file. The BranchGraphs are stored in the order in which they are written, they can be read in any order using SceneGraphFileReader. The API handles Nodes and NodeComponents that are shared between seperate graphs. It will handle all Java3D 1.3 core classes and any user subclass of a Node or NodeComponent that implements the SceneGraphIO interface.
    • Constructor Summary

      Constructors 
      Constructor Description
      SceneGraphFileWriter​(java.io.File file, SimpleUniverse universe, boolean writeUniverseContent, java.lang.String fileDescription, java.io.Serializable fileUserData)
      Creates new SceneGraphFileWriter and opens the file for writing.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addObjectName​(java.lang.String name, SceneGraphObject object)
      Add a named reference to a SceneGraphObject in the file.
      void close()
      Close the file and cleanup internal data structures.
      void writeBranchGraph​(BranchGroup graph)
      Write the graph to the end of the file.
      void writeBranchGraph​(BranchGroup graph, java.io.Serializable data)
      Write a branch graph and some user associated data to the end of the file.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • SceneGraphFileWriter

        public SceneGraphFileWriter​(java.io.File file,
                                    SimpleUniverse universe,
                                    boolean writeUniverseContent,
                                    java.lang.String fileDescription,
                                    java.io.Serializable fileUserData)
                             throws java.io.IOException,
                                    UnsupportedUniverseException
        Creates new SceneGraphFileWriter and opens the file for writing.

        Writes the Java3D Universe structure to the file. This includes the number and position of the Locales, PlatformGeometry, ViewerAvatar, and the MultitransformGroup between the ViewingPlatform and the View. However this call does not write the content of the branch graphs unless writeUniverseContent is true. universe may be null. This call will overwrite any existing universe, fileDescription and userData in the file.

        close() MUST be called when IO is complete. If close() is not called the file contents will be undefined.

        Parameters:
        file - The file to write the data to
        universe - The SimpleUniverse to write
        writeUniverseContent - If true, the content of the Locales will be written. Otherwise just the universe configuration data will be written.
        fileDescription - A description of the file's content
        fileUserData - User defined object
        Throws:
        java.io.IOException - Thrown if there are any IO errors
        UnsupportedUniverseException - Thrown if universe is not a supported universe class. Currently SimpleUniverse and ConfiguredUniverse are supported.
    • Method Detail

      • writeBranchGraph

        public void writeBranchGraph​(BranchGroup graph)
                              throws java.io.IOException
        Write the graph to the end of the file. close() MUST be called when IO is complete. If close() is not called the file contents will be undefined.
        Throws:
        java.io.IOException
      • writeBranchGraph

        public void writeBranchGraph​(BranchGroup graph,
                                     java.io.Serializable data)
                              throws java.io.IOException
        Write a branch graph and some user associated data to the end of the file. close() MUST be called when IO is complete. If close() is not called the file contents will be undefined.
        Throws:
        java.io.IOException
      • addObjectName

        public void addObjectName​(java.lang.String name,
                                  SceneGraphObject object)
                           throws NamedObjectException
        Add a named reference to a SceneGraphObject in the file. object must have been written to the file before this method is called. If the object is not in the file a NamedObjectException will be thrown. Adding duplicate names will result in the old name being overwritten. Different names can reference the same object
        Throws:
        NamedObjectException
      • close

        public void close()
                   throws java.io.IOException
        Close the file and cleanup internal data structures.
        Throws:
        java.io.IOException