com.sun.j3d.utils.scenegraph.io

## Class SceneGraphStreamWriter

- java.lang.Object
- - com.sun.j3d.utils.scenegraph.io.SceneGraphStreamWriter

-     public class SceneGraphStreamWriter
      extends java.lang.Object

  Writes a Java3D SceneGraph to a Java OutputStream.

  Using this class to write to a FileOutputStream is not recommended. Use SceneGraphFileWriter instead to achieve maximum performance and flexibility.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `SceneGraphStreamWriter(java.io.OutputStream outputStream)` Creates new SceneGraphStreamWriter that will write to the supplied stream

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `close()` Close the SceneGraphStreamWriter and the associated stream
    `void` | `writeBranchGraph(BranchGroup graph, java.util.HashMap namedObjects)` Write the entire graph to the stream.
    `void` | `writeUniverse(SimpleUniverse universe, boolean writeContent)` Write `universe` to the Stream.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### SceneGraphStreamWriter

          public SceneGraphStreamWriter(java.io.OutputStream outputStream)
                                 throws java.io.IOException

      Creates new SceneGraphStreamWriter that will write to the supplied stream
      Throws:
        `java.io.IOException`

  - ### Method Detail

    - #### writeUniverse

          public void writeUniverse(SimpleUniverse universe,
                           boolean writeContent)
                             throws java.io.IOException,
                                    UnsupportedUniverseException

      Write `universe` to the Stream.

      If `writeContent` is true then all BranchGraphs attached to the universe will be saved. If it is false then only the universe data structures will be output (PlatformGeometry, ViewerAvatar, Locales, and the MultiTransformGroup between the ViewingPlatform and the View).

      If `writeContent` is true then all the BranchGraphs attached to the Locales of the universe must have the ALLOW_DETACH capability set. If they do not, a `CapabilityNotSetException` will be thrown

      Parameters:
        `universe` - The universe to write
        `writeContent` - Flag enabling the BranchGraphs to be written
      Throws:
        `java.io.IOException`
        `UnsupportedUniverseException` - Thrown if the universe class is not supported by this implementation

    - #### writeBranchGraph

          public void writeBranchGraph(BranchGroup graph,
                              java.util.HashMap namedObjects)
                                throws java.io.IOException,
                                       DanglingReferenceException,
                                       NamedObjectException

      Write the entire graph to the stream.

      The API will correctly handle NodeComponents that are shared between seperate graphs. However Nodes cannot be referenced in other Graphs.

      If a reference to a Node in another graph is encountered a DanglingReferenceException will be thrown. `namedObjects` can contain a mapping between a key and a SceneGraphObject in the graph. During the read process this can be used to locate nodes in the graph.

      Throws:
        `java.io.IOException`
        `DanglingReferenceException`
        `NamedObjectException`

    - #### close

          public void close()
                     throws java.io.IOException

      Close the SceneGraphStreamWriter and the associated stream
      Throws:
        `java.io.IOException`

Copyright 1996-2008 Sun Microsystems, Inc. All Rights Reserved. Use is subject to license terms.