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

java.lang.Object
  extended by com.sun.j3d.utils.scenegraph.io.retained.SymbolTable
All Implemented Interfaces:
SceneGraphObjectReferenceControl

public class SymbolTable
extends java.lang.Object
implements SceneGraphObjectReferenceControl

SymbolTable class for SceneGraph I/O.


Constructor Summary
SymbolTable(Controller control)
          Creates new SymbolTable
 
Method Summary
 int addBranchGraphReference(javax.media.j3d.SceneGraphObject node, int branchGraphID)
          Add a refernce to the BranchGraph root Also returns the nodes id Used to associate graphs with a locale without storing the graph at the current time.
 void addNamedObject(java.lang.String name, javax.media.j3d.SceneGraphObject object)
          Associate the name with the scene graph object
 void addNamedObjects(java.util.HashMap map)
          Add all the named objects in map
 int addReference(javax.media.j3d.SceneGraphObject node)
          Add a refernce to the specified node Also returns the nodes id
 int addReference(SymbolTableData symbol)
          Add a refernce to the specified node Also returns the nodes id
 boolean branchGraphHasDependencies(int graphID)
          Return true if the graph is dependent on nodes in other graphs Only Nodes (not node components) cause dependencies
 void clear()
          Clear all elements from the symbol table
 void clearUnshared()
          Clear all the Symbols that are not shared with other Graphs in the file Remove all Symbols from all structures with referenceCounts=1
 SymbolTableData createSymbol(javax.media.j3d.SceneGraphObject node)
          Create a new symbol and provide a new nodeID This is used during the save process
 SymbolTableData createSymbol(SceneGraphObjectState state, javax.media.j3d.SceneGraphObject node, int nodeID)
          Create a new symbol using the specified nodeID This is used during the load process.
 void endUnsavedNodeComponentFrame()
           
 int getBranchGraphCount()
           
 int[] getBranchGraphDependencies(int graphID)
          Return an array of each BranchGraph on which graphID is dependent for closure of the graph Only Nodes (not node components) cause dependencies If there are no dependencies int[0] is returned
 long getBranchGraphFilePosition(int graphID)
           
 SymbolTableData getBranchGraphRoot(int graphID)
           
 javax.media.j3d.SceneGraphObject getJ3dNode(int nodeID)
          Return the Java3D node associated with the nodeID.
 javax.media.j3d.SceneGraphObject getNamedObject(java.lang.String name)
          Return the SceneGraphObject associated with the name
 void getNamedObjectMap(java.util.HashMap map)
          Add the namedObject mappings to map
 java.lang.String[] getNames()
          Get all the names of the named objects
 SymbolTableData getSharedGroup(int nodeID)
          Get the symbol for the shared group If the sharedgroup has not been loaded then load it before returning (if we are using RandomAccessFileControl
 SymbolTableData getSymbol(int nodeID)
          Return the node with the give ID
 SymbolTableData getSymbol(javax.media.j3d.SceneGraphObject node)
          Get the table entry for node
 java.util.ListIterator getUnsavedNodeComponents()
           
 int getUnsavedNodeComponentsSize()
           
 void incNodeComponentRefCount(int nodeID)
          Update the reference count for the node component.
 boolean isLoaded(int nodeID)
          Return true if this node has already been loaded
 void readTable(java.io.DataInput in, boolean streamRead)
          Read and store the entire symbol table
 javax.media.j3d.SceneGraphObject resolveReference(int nodeID)
          Given a nodeID return the corresponding scene graph object.
 void setBranchGraphID(SymbolTableData symbol)
          Set the branchGraphID in the symbol to the current branch graph ID
 void setBranchGraphRoot(SymbolTableData symbol, long filePointer)
          Mark the node referenced by this Symbol as a branch graph root The filePointer is the position of the BranchGraph in the file, this is not the same as the BranchGroups position due to the extra data stored for a graph.
 void setFilePosition(long ptr, SceneGraphObjectState state)
          Set the position of the object referenced by state
 void startUnsavedNodeComponentFrame()
           
 java.lang.String toString()
           
 void writeTable(java.io.DataOutput out)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SymbolTable

public SymbolTable(Controller control)
Creates new SymbolTable

Method Detail

writeTable

public void writeTable(java.io.DataOutput out)
                throws java.io.IOException
Throws:
java.io.IOException

readTable

public void readTable(java.io.DataInput in,
                      boolean streamRead)
               throws java.io.IOException
Read and store the entire symbol table

Parameters:
streamRead - - true if reading from a Stream in which case only the branchGraphs and named objects are read.
Throws:
java.io.IOException

setBranchGraphRoot

public void setBranchGraphRoot(SymbolTableData symbol,
                               long filePointer)
Mark the node referenced by this Symbol as a branch graph root The filePointer is the position of the BranchGraph in the file, this is not the same as the BranchGroups position due to the extra data stored for a graph.


getBranchGraphRoot

public SymbolTableData getBranchGraphRoot(int graphID)

setBranchGraphID

public void setBranchGraphID(SymbolTableData symbol)
Set the branchGraphID in the symbol to the current branch graph ID


getBranchGraphDependencies

public int[] getBranchGraphDependencies(int graphID)
Return an array of each BranchGraph on which graphID is dependent for closure of the graph Only Nodes (not node components) cause dependencies If there are no dependencies int[0] is returned


branchGraphHasDependencies

public boolean branchGraphHasDependencies(int graphID)
Return true if the graph is dependent on nodes in other graphs Only Nodes (not node components) cause dependencies


getBranchGraphCount

public int getBranchGraphCount()

getBranchGraphFilePosition

public long getBranchGraphFilePosition(int graphID)

createSymbol

public SymbolTableData createSymbol(javax.media.j3d.SceneGraphObject node)
Create a new symbol and provide a new nodeID This is used during the save process


createSymbol

public SymbolTableData createSymbol(SceneGraphObjectState state,
                                    javax.media.j3d.SceneGraphObject node,
                                    int nodeID)
Create a new symbol using the specified nodeID This is used during the load process.


getUnsavedNodeComponentsSize

public int getUnsavedNodeComponentsSize()

getUnsavedNodeComponents

public java.util.ListIterator getUnsavedNodeComponents()

startUnsavedNodeComponentFrame

public void startUnsavedNodeComponentFrame()

endUnsavedNodeComponentFrame

public void endUnsavedNodeComponentFrame()

incNodeComponentRefCount

public void incNodeComponentRefCount(int nodeID)
Update the reference count for the node component. Called during NodeComponentState.addSubReference()


addReference

public int addReference(javax.media.j3d.SceneGraphObject node)
Add a refernce to the specified node Also returns the nodes id

Specified by:
addReference in interface SceneGraphObjectReferenceControl

addReference

public int addReference(SymbolTableData symbol)
Add a refernce to the specified node Also returns the nodes id


addBranchGraphReference

public int addBranchGraphReference(javax.media.j3d.SceneGraphObject node,
                                   int branchGraphID)
Add a refernce to the BranchGraph root Also returns the nodes id Used to associate graphs with a locale without storing the graph at the current time.


isLoaded

public boolean isLoaded(int nodeID)
Return true if this node has already been loaded


getJ3dNode

public javax.media.j3d.SceneGraphObject getJ3dNode(int nodeID)
Return the Java3D node associated with the nodeID. The method will call buildGraph() on the node if necessary


getSymbol

public SymbolTableData getSymbol(javax.media.j3d.SceneGraphObject node)
Get the table entry for node


getSymbol

public SymbolTableData getSymbol(int nodeID)
Return the node with the give ID


getSharedGroup

public SymbolTableData getSharedGroup(int nodeID)
Get the symbol for the shared group If the sharedgroup has not been loaded then load it before returning (if we are using RandomAccessFileControl


setFilePosition

public void setFilePosition(long ptr,
                            SceneGraphObjectState state)
Set the position of the object referenced by state


addNamedObject

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


addNamedObjects

public void addNamedObjects(java.util.HashMap map)
Add all the named objects in map


getNamedObject

public javax.media.j3d.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


getNamedObjectMap

public void getNamedObjectMap(java.util.HashMap map)
Add the namedObject mappings to map


toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

clear

public void clear()
Clear all elements from the symbol table


clearUnshared

public void clearUnshared()
Clear all the Symbols that are not shared with other Graphs in the file Remove all Symbols from all structures with referenceCounts=1


resolveReference

public javax.media.j3d.SceneGraphObject resolveReference(int nodeID)
Given a nodeID return the corresponding scene graph object. Use only during the load cycle

Specified by:
resolveReference in interface SceneGraphObjectReferenceControl