com.sun.j3d.utils.scenegraph.io.retained
Class Controller

java.lang.Object
  extended by com.sun.j3d.utils.scenegraph.io.retained.Controller
Direct Known Subclasses:
RandomAccessFileControl, StreamControl

public abstract class Controller
extends java.lang.Object

Provides code to control the reading and writing of Java3D objects to and from any Java IO mechanism.


Nested Class Summary
(package private)  class Controller.J3dIOObjectInputStream
          An ObjectInputStream that uses a different classLoader
 
Field Summary
protected static long BG_DIR_PTR
           
protected static long BRANCH_GRAPH_COUNT
           
protected  java.lang.ClassLoader classLoader
          When running the application within webstart this may not be the correct ClassLoader.
protected  int currentFileVersion
          The currentFileVersion being read
protected static long FILE_DESCRIPTION
           
private  int imageCompression
           
(package private)  java.lang.Class[] j3dClasses
           
protected static long NAMES_OBJECTS_TABLE_PTR
           
protected static long NODE_TYPES_PTR
           
protected  NullSceneGraphObjectState nullObject
           
protected  int outputFileVersion
          The File version which will be written 1 = Java3D 1.3 beta 1 2 = Java3D 1.3 FCS, 1) fix to allow skipping user data written via SceneGraphIO interface 2) Add missing duplicateOnCloneTree flag (bug 4690159) 3 = Java3D 1.5.1 1) Add support for SceneGraphObject Name field 4 = Java3D 1.5.2 issue 532, for saving Background Geometry
protected static long SYMBOL_TABLE_PTR
           
protected  SymbolTable symbolTable
           
protected static long UNIVERSE_CONFIG_PTR
           
private  boolean useSuperClass
          If true when loading a scenegraph that contains nodes who's classes are not in the classpath then use then first Java3D core superclass to instantiate the node.
 
Constructor Summary
Controller()
          Creates new Controller
 
Method Summary
 void addNamedObject(java.lang.String name, SceneGraphObject object)
          Associate the name with the scene graph object
private  SceneGraphObjectState checkSuperClasses(SymbolTableData symbol)
          Check to see if any of the superclasses of obj are known to the Java3D IO package
abstract  void close()
           
private  SceneGraphObjectState constructStateObj(SymbolTableData symbol, java.lang.Class state, java.lang.Class objClass)
           
private  SceneGraphObjectState createCoreState(int classID)
          'Core' classes (ie those hard coded in this API) are assigned a numerical value representing their class.
 SceneGraphObjectState createState(SceneGraphObject obj)
          Create a new state object and check for a pre-existing symbol table entry
 SceneGraphObjectState createState(SceneGraphObject obj, SymbolTableData symbol)
          Given a scene graph object instantiate the correct State class for that object.
 SceneGraphObjectState createState(SymbolTableData symbol)
          Return the state class for the SceneGraphObject, creating one if it does not already exist
 java.lang.ClassLoader getClassLoader()
          Get the class loader used to load the Scene Graph Objects and the serialized user data.
 int getCurrentFileVersion()
          Get the file version of the file we are reading
abstract  long getFilePointer()
          Get the current file 'pointer' location.
 int getImageCompression()
          Returns the imageCompression to be used IMAGE_COMPRESSION_NONE, IMAGE_COMPRESSION_GZIP, IMAGE_COMPRESSION_JPEG
 SceneGraphObject getNamedObject(java.lang.String name)
          Return the SceneGraphObject associated with the name
 java.lang.String[] getNames()
          Get all the names of the named objects
 java.lang.Class getNodeClassFromID(int classID)
           
 int getNodeClassID(SceneGraphObject node)
           
 int getOutputFileVersion()
          Get the file version that we should write
private  int getStateID(SceneGraphObjectState state)
          Return the id of the state class
 SymbolTable getSymbolTable()
           
 Bounds readBounds(java.io.DataInput in)
           
protected abstract  void readBranchGraphs(int[] graphs)
          Read the set of branchgraps.
 Color3f readColor3f(java.io.DataInput in)
           
 Color4f readColor4f(java.io.DataInput in)
           
 Matrix4d readMatrix4d(java.io.DataInput in)
           
protected  void readNodeComponents(java.io.DataInput in)
          Read in all the node components in this block
 SceneGraphObjectState readObject(java.io.DataInput in)
           
 Point3d readPoint3d(java.io.DataInput in)
           
 Point3f readPoint3f(java.io.DataInput in)
           
 Quat4f readQuat4f(java.io.DataInput in)
           
 java.lang.Object readSerializedData(java.io.DataInput dataInput)
           
 int readSharedGroup(java.io.DataInput in)
          Read a Shared group and it's node components from the IO Stream
 Transform3D readTransform3D(java.io.DataInput in)
           
 Tuple3d readTuple3d(java.io.DataInput in, Tuple3d tuple)
           
 Tuple3f readTuple3f(java.io.DataInput in, Tuple3f tuple)
           
 Tuple4d readTuple4d(java.io.DataInput in, Tuple4d tuple)
           
 Tuple4f readTuple4f(java.io.DataInput in, Tuple4f tuple)
           
 ConfiguredUniverse readUniverse(java.io.DataInput in, boolean attachBranchGraphs, Canvas3D canvas)
          Read and create a new Universe matching the one used during save.
 Vector3f readVector3f(java.io.DataInput in)
           
 Vector4d readVector4d(java.io.DataInput in)
           
 Vector4f readVector4f(java.io.DataInput in)
           
 void reset()
          Reset the controller, ready to load/save data to a new file
 void setClassLoader(java.lang.ClassLoader classLoader)
          Set the class loader used to load the Scene Graph Objects and the serialized user data.
 void skipUserData(java.io.DataInput dataInput)
          Skip past the user data object
 boolean useSuperClassIfNoChildClass()
          Indicates to SceneGraphObjectState that it should use the Java3D core superclass for any tree nodes whose classes are not in the classpath during a load.
 void writeBounds(java.io.DataOutput out, Bounds bounds)
           
abstract  void writeBranchGraph(BranchGroup bg, java.io.Serializable userData)
           
 void writeColor3f(java.io.DataOutput out, Color3f color)
           
 void writeColor4f(java.io.DataOutput out, Color4f vec)
           
 void writeMatrix4d(java.io.DataOutput out, Matrix4d m)
           
protected  void writeNodeComponents(java.io.DataOutput out)
          Write all the unsaved NodeComponents and SharedGroups to DataOutput.
 void writeObject(java.io.DataOutput out, SceneGraphObjectState obj)
           
 void writePoint3d(java.io.DataOutput out, Point3d pt)
           
 void writePoint3f(java.io.DataOutput out, Point3f pt)
           
 void writeQuat4f(java.io.DataOutput out, Quat4f vec)
           
 void writeSerializedData(java.io.DataOutput dataOutput, java.io.Serializable userData)
          Write a serializable object to the current file position, proceeded by the size of the object
 void writeSharedGroup(java.io.DataOutput out, SharedGroup sharedGroup, SymbolTableData symbol)
          Write the shared group and it's node components to the IO stream
 void writeTransform3D(java.io.DataOutput out, Transform3D tran)
           
 void writeTuple3d(java.io.DataOutput out, Tuple3d tuple)
           
 void writeTuple3f(java.io.DataOutput out, Tuple3f tuple)
           
 void writeTuple4d(java.io.DataOutput out, Tuple4d tuple)
           
 void writeTuple4f(java.io.DataOutput out, Tuple4f tuple)
           
 void writeUniverse(java.io.DataOutput out, SimpleUniverse universe, boolean writeUniverseContent)
          Write out the Universe information.
 void writeVector3f(java.io.DataOutput out, Vector3f vec)
           
 void writeVector4d(java.io.DataOutput out, Vector4d vec)
           
 void writeVector4f(java.io.DataOutput out, Vector4f vec)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SYMBOL_TABLE_PTR

protected static final long SYMBOL_TABLE_PTR
See Also:
Constant Field Values

BG_DIR_PTR

protected static final long BG_DIR_PTR
See Also:
Constant Field Values

NAMES_OBJECTS_TABLE_PTR

protected static final long NAMES_OBJECTS_TABLE_PTR
See Also:
Constant Field Values

NODE_TYPES_PTR

protected static final long NODE_TYPES_PTR
See Also:
Constant Field Values

UNIVERSE_CONFIG_PTR

protected static final long UNIVERSE_CONFIG_PTR
See Also:
Constant Field Values

BRANCH_GRAPH_COUNT

protected static final long BRANCH_GRAPH_COUNT
See Also:
Constant Field Values

FILE_DESCRIPTION

protected static final long FILE_DESCRIPTION
See Also:
Constant Field Values

symbolTable

protected SymbolTable symbolTable

nullObject

protected NullSceneGraphObjectState nullObject

currentFileVersion

protected int currentFileVersion
The currentFileVersion being read


outputFileVersion

protected int outputFileVersion
The File version which will be written 1 = Java3D 1.3 beta 1 2 = Java3D 1.3 FCS, 1) fix to allow skipping user data written via SceneGraphIO interface 2) Add missing duplicateOnCloneTree flag (bug 4690159) 3 = Java3D 1.5.1 1) Add support for SceneGraphObject Name field 4 = Java3D 1.5.2 issue 532, for saving Background Geometry


classLoader

protected java.lang.ClassLoader classLoader
When running the application within webstart this may not be the correct ClassLoader. If Java 3D is not installed in the local vm and is instead installed by webstart then this definitely is NOT the correct classloader, in this case Thread.getCurrent().getClass().getClassLoader() would probably be a good default. The user can also set their preferred classloader by calling setClassLoader in SceneGraph[Stream|File]Reader.


useSuperClass

private boolean useSuperClass
If true when loading a scenegraph that contains nodes who's classes are not in the classpath then use then first Java3D core superclass to instantiate the node. If false a SGIORuntimeException will be thrown when classes cannot be located


imageCompression

private int imageCompression

j3dClasses

java.lang.Class[] j3dClasses
Constructor Detail

Controller

public Controller()
Creates new Controller

Method Detail

getSymbolTable

public final SymbolTable getSymbolTable()

getOutputFileVersion

public int getOutputFileVersion()
Get the file version that we should write


getCurrentFileVersion

public int getCurrentFileVersion()
Get the file version of the file we are reading


createState

public SceneGraphObjectState createState(SceneGraphObject obj)
Create a new state object and check for a pre-existing symbol table entry


createState

public SceneGraphObjectState createState(SceneGraphObject obj,
                                         SymbolTableData symbol)
Given a scene graph object instantiate the correct State class for that object. If the symbol already exists (is not null) then increment the reference count, otherwise create a new symbol.


createState

public SceneGraphObjectState createState(SymbolTableData symbol)
Return the state class for the SceneGraphObject, creating one if it does not already exist


constructStateObj

private SceneGraphObjectState constructStateObj(SymbolTableData symbol,
                                                java.lang.Class state,
                                                java.lang.Class objClass)

checkSuperClasses

private SceneGraphObjectState checkSuperClasses(SymbolTableData symbol)
Check to see if any of the superclasses of obj are known to the Java3D IO package


writeObject

public void writeObject(java.io.DataOutput out,
                        SceneGraphObjectState obj)
                 throws java.io.IOException
Throws:
java.io.IOException

readObject

public SceneGraphObjectState readObject(java.io.DataInput in)
                                 throws java.io.IOException
Throws:
java.io.IOException

setClassLoader

public void setClassLoader(java.lang.ClassLoader classLoader)
Set the class loader used to load the Scene Graph Objects and the serialized user data. The default is ClassLoader.getSystemClassLoader()


getClassLoader

public java.lang.ClassLoader getClassLoader()
Get the class loader used to load the Scene Graph Objects and the serialized user data. The default is ClassLoader.getSystemClassLoader()


writeNodeComponents

protected void writeNodeComponents(java.io.DataOutput out)
                            throws java.io.IOException
Write all the unsaved NodeComponents and SharedGroups to DataOutput. Mark all the NodeComponents as saved.

Throws:
java.io.IOException

readNodeComponents

protected void readNodeComponents(java.io.DataInput in)
                           throws java.io.IOException
Read in all the node components in this block

Throws:
java.io.IOException

writeSharedGroup

public void writeSharedGroup(java.io.DataOutput out,
                             SharedGroup sharedGroup,
                             SymbolTableData symbol)
                      throws java.io.IOException
Write the shared group and it's node components to the IO stream

Throws:
java.io.IOException

readSharedGroup

public int readSharedGroup(java.io.DataInput in)
                    throws java.io.IOException
Read a Shared group and it's node components from the IO Stream

Throws:
java.io.IOException

writeUniverse

public void writeUniverse(java.io.DataOutput out,
                          SimpleUniverse universe,
                          boolean writeUniverseContent)
                   throws java.io.IOException,
                          UnsupportedUniverseException,
                          CapabilityNotSetException
Write out the Universe information.

Throws:
java.io.IOException
UnsupportedUniverseException
CapabilityNotSetException

readUniverse

public ConfiguredUniverse readUniverse(java.io.DataInput in,
                                       boolean attachBranchGraphs,
                                       Canvas3D canvas)
                                throws java.io.IOException
Read and create a new Universe matching the one used during save.

Parameters:
attachBranchGraphs - If true then all the branchGraph attached to the universe when it was saved will be loaded and reattached.
Throws:
java.io.IOException

readBranchGraphs

protected abstract void readBranchGraphs(int[] graphs)
                                  throws java.io.IOException
Read the set of branchgraps. Used by readUniverse RandomAccessFileControl will read the graphs in the array, StreamControl will read all graphs in the stream

Throws:
java.io.IOException

writeBranchGraph

public abstract void writeBranchGraph(BranchGroup bg,
                                      java.io.Serializable userData)
                               throws java.io.IOException
Throws:
java.io.IOException

reset

public void reset()
Reset the controller, ready to load/save data to a new file


createCoreState

private SceneGraphObjectState createCoreState(int classID)
'Core' classes (ie those hard coded in this API) are assigned a numerical value representing their class. This simply saves space and IO bandwidth


getStateID

private int getStateID(SceneGraphObjectState state)
Return the id of the state class


getNodeClassFromID

public java.lang.Class getNodeClassFromID(int classID)

getNodeClassID

public int getNodeClassID(SceneGraphObject node)

addNamedObject

public void addNamedObject(java.lang.String name,
                           SceneGraphObject object)
Associate the name with the scene graph object


getNamedObject

public SceneGraphObject getNamedObject(java.lang.String name)
                                throws NamedObjectException,
                                       ObjectNotLoadedException
Return the SceneGraphObject associated with the name

Throws:
NamedObjectException
ObjectNotLoadedException

getNames

public java.lang.String[] getNames()
Get all the names of the named objects


writeSerializedData

public void writeSerializedData(java.io.DataOutput dataOutput,
                                java.io.Serializable userData)
                         throws java.io.IOException
Write a serializable object to the current file position, proceeded by the size of the object

Throws:
java.io.IOException

readSerializedData

public java.lang.Object readSerializedData(java.io.DataInput dataInput)
                                    throws java.io.IOException
Throws:
java.io.IOException

skipUserData

public void skipUserData(java.io.DataInput dataInput)
                  throws java.io.IOException
Skip past the user data object

Throws:
java.io.IOException

writeColor3f

public void writeColor3f(java.io.DataOutput out,
                         Color3f color)
                  throws java.io.IOException
Throws:
java.io.IOException

readColor3f

public Color3f readColor3f(java.io.DataInput in)
                    throws java.io.IOException
Throws:
java.io.IOException

writeColor4f

public void writeColor4f(java.io.DataOutput out,
                         Color4f vec)
                  throws java.io.IOException
Throws:
java.io.IOException

readColor4f

public Color4f readColor4f(java.io.DataInput in)
                    throws java.io.IOException
Throws:
java.io.IOException

writePoint3f

public void writePoint3f(java.io.DataOutput out,
                         Point3f pt)
                  throws java.io.IOException
Throws:
java.io.IOException

readPoint3f

public Point3f readPoint3f(java.io.DataInput in)
                    throws java.io.IOException
Throws:
java.io.IOException

writePoint3d

public void writePoint3d(java.io.DataOutput out,
                         Point3d pt)
                  throws java.io.IOException
Throws:
java.io.IOException

readPoint3d

public Point3d readPoint3d(java.io.DataInput in)
                    throws java.io.IOException
Throws:
java.io.IOException

writeVector3f

public void writeVector3f(java.io.DataOutput out,
                          Vector3f vec)
                   throws java.io.IOException
Throws:
java.io.IOException

readVector3f

public Vector3f readVector3f(java.io.DataInput in)
                      throws java.io.IOException
Throws:
java.io.IOException

writeVector4d

public void writeVector4d(java.io.DataOutput out,
                          Vector4d vec)
                   throws java.io.IOException
Throws:
java.io.IOException

readVector4d

public Vector4d readVector4d(java.io.DataInput in)
                      throws java.io.IOException
Throws:
java.io.IOException

writeVector4f

public void writeVector4f(java.io.DataOutput out,
                          Vector4f vec)
                   throws java.io.IOException
Throws:
java.io.IOException

readVector4f

public Vector4f readVector4f(java.io.DataInput in)
                      throws java.io.IOException
Throws:
java.io.IOException

writeQuat4f

public void writeQuat4f(java.io.DataOutput out,
                        Quat4f vec)
                 throws java.io.IOException
Throws:
java.io.IOException

readQuat4f

public Quat4f readQuat4f(java.io.DataInput in)
                  throws java.io.IOException
Throws:
java.io.IOException

writeMatrix4d

public void writeMatrix4d(java.io.DataOutput out,
                          Matrix4d m)
                   throws java.io.IOException
Throws:
java.io.IOException

readMatrix4d

public Matrix4d readMatrix4d(java.io.DataInput in)
                      throws java.io.IOException
Throws:
java.io.IOException

writeTuple3f

public void writeTuple3f(java.io.DataOutput out,
                         Tuple3f tuple)
                  throws java.io.IOException
Throws:
java.io.IOException

readTuple3f

public Tuple3f readTuple3f(java.io.DataInput in,
                           Tuple3f tuple)
                    throws java.io.IOException
Throws:
java.io.IOException

writeTuple3d

public void writeTuple3d(java.io.DataOutput out,
                         Tuple3d tuple)
                  throws java.io.IOException
Throws:
java.io.IOException

readTuple3d

public Tuple3d readTuple3d(java.io.DataInput in,
                           Tuple3d tuple)
                    throws java.io.IOException
Throws:
java.io.IOException

writeTuple4d

public void writeTuple4d(java.io.DataOutput out,
                         Tuple4d tuple)
                  throws java.io.IOException
Throws:
java.io.IOException

readTuple4d

public Tuple4d readTuple4d(java.io.DataInput in,
                           Tuple4d tuple)
                    throws java.io.IOException
Throws:
java.io.IOException

writeTuple4f

public void writeTuple4f(java.io.DataOutput out,
                         Tuple4f tuple)
                  throws java.io.IOException
Throws:
java.io.IOException

readTuple4f

public Tuple4f readTuple4f(java.io.DataInput in,
                           Tuple4f tuple)
                    throws java.io.IOException
Throws:
java.io.IOException

writeTransform3D

public void writeTransform3D(java.io.DataOutput out,
                             Transform3D tran)
                      throws java.io.IOException
Throws:
java.io.IOException

readTransform3D

public Transform3D readTransform3D(java.io.DataInput in)
                            throws java.io.IOException
Throws:
java.io.IOException

writeBounds

public void writeBounds(java.io.DataOutput out,
                        Bounds bounds)
                 throws java.io.IOException
Throws:
java.io.IOException

readBounds

public Bounds readBounds(java.io.DataInput in)
                  throws java.io.IOException
Throws:
java.io.IOException

getFilePointer

public abstract long getFilePointer()
Get the current file 'pointer' location.


close

public abstract void close()
                    throws java.io.IOException
Throws:
java.io.IOException

useSuperClassIfNoChildClass

public boolean useSuperClassIfNoChildClass()
Indicates to SceneGraphObjectState that it should use the Java3D core superclass for any tree nodes whose classes are not in the classpath during a load.


getImageCompression

public int getImageCompression()
Returns the imageCompression to be used IMAGE_COMPRESSION_NONE, IMAGE_COMPRESSION_GZIP, IMAGE_COMPRESSION_JPEG



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