Package org.web3d.vrml.nodes
Class ImportNodeProxy
java.lang.Object
org.web3d.vrml.nodes.ImportNodeProxy
- All Implemented Interfaces:
Cloneable
,VRMLNode
,FrameStateListener
,VRMLNodeListener
,VRMLNodeType
A proxy node representation for allowing processing of X3D imports.
- Version:
- $Revision: 1.7 $
- Author:
- Justin Couch
-
Constructor Summary
ConstructorsConstructorDescriptionImportNodeProxy
(String importedAs, String inlineDef, String exportedAs) Create a new instance of this node with the given node type name. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Add a listener to this node instance.void
Ignored by this base implementation.void
Clear the current removed layer ID list.clone()
Make a cloned copy of this class.void
fieldChanged
(int index) Notification that the field represented by the given index has changed.Get the name that the node was exported as from the inline.getFieldDeclaration
(int index) Get the declaration of the field at the given index.int
getFieldIndex
(String fieldName) Get the index of the given field name.getFieldValue
(int index) Get the value of a field.Get the import name.Get the DEF name of the inline that this import works with.int[]
Get a listing of the current layer IDs that are directly or indirectly referencing this node.Get the currently registered metadata object instance.int[]
Get the list of indices that correspond to fields that contain nodes ie MFNode and SFNode).int
Get the number of fields.int
Get the primary type of this node.Fetch the real node reference.int
getRefCount
(int layer) Ask for the current number of references to this object.int[]
Get the list of layer IDs that this node has just been removed from.int[]
Get the secondary types of this node.getUserData
(int index) Fetch the stored user data for a given field index.Get the name of this node as a string.boolean
hasFieldChanged
(int index) Check to see if the given field has changed since we last checked.boolean
isDEF()
Check to see if this node has been DEFd.boolean
Check to see if setupFinished() has already been called on this node.void
notifyExternProtoLoaded
(int index, VRMLNodeType node) Notify a node that an ExternProto has resolved.void
Remove a listener from this node instance.void
sendRoute
(double time, int srcIndex, VRMLNodeType destNode, int destIndex) Send a routed value from this node to the given destination node.void
setDEF()
Notify this node that is has been DEFd.void
setErrorReporter
(org.j3d.util.ErrorReporter reporter) Register an error reporter with the engine so that any errors generated by the node's internals can be reported in a nice, pretty fashion.void
Ignored by this implementation.void
Set the X3DMetadataObject that is associated with this node.void
setRealNode
(VRMLNodeType node) Set the real node that this proxy is representing.void
Notification that the construction phase of this node has finished.void
setUserData
(int index, Object data) Set arbitrary data for a given field.void
setValue
(int index, boolean value) Set the value of the field at the given index as an boolean.void
setValue
(int index, boolean[] value, int numValid) Set the value of the field at the given index as an array of boolean.void
setValue
(int index, double value) Set the value of the field at the given index as an double.void
setValue
(int index, double[] value, int numValid) Set the value of the field at the given index as an array of doubles.void
setValue
(int index, float value) Set the value of the field at the given index as a float.void
setValue
(int index, float[] value, int numValid) Set the value of the field at the given index as an array of floats.void
setValue
(int index, int value) Set the value of the field at the given index as an integer.void
setValue
(int index, int[] value, int numValid) Set the value of the field at the given index as an array of integers.void
setValue
(int index, long value) Set the value of the field at the given index as an long.void
setValue
(int index, long[] value, int numValid) Set the value of the field at the given index as an array of longs.void
Set the value of the field at the given index as a string.void
Set the value of the field at the given index as an array of strings.void
setValue
(int index, VRMLNodeType child) Set the value of the field at the given index as a node.void
setValue
(int index, VRMLNodeType[] children, int numValid) Set the value of the field at the given index as an array of nodes.void
setVersion
(int major, int minor, boolean isStatic) Set the version of VRML that this node should represent.void
updateRefCount
(int layer, boolean add) Change the reference count up or down by one.
-
Constructor Details
-
ImportNodeProxy
Create a new instance of this node with the given node type name. inSetup will be set to true and isDEF set to false.- Parameters:
importedAs
- The name from the import statementinlineDef
- The DEF name of the inline this import refers toexportedAs
- The name the node was exported from the Inline as
-
-
Method Details
-
allEventsComplete
public void allEventsComplete()Ignored by this base implementation. Any class that needs this method may override this method as required.- Specified by:
allEventsComplete
in interfaceFrameStateListener
-
setErrorReporter
public void setErrorReporter(org.j3d.util.ErrorReporter reporter) Register an error reporter with the engine so that any errors generated by the node's internals can be reported in a nice, pretty fashion. Setting a value of null will clear the currently set reporter. If one is already set, the new value replaces the old.- Specified by:
setErrorReporter
in interfaceVRMLNode
- Parameters:
reporter
- The instance to use or null
-
getVRMLNodeName
Get the name of this node as a string.- Specified by:
getVRMLNodeName
in interfaceVRMLNode
- Returns:
- The name of the node
-
isDEF
-
getPrimaryType
public int getPrimaryType()Get the primary type of this node. Replaces the instanceof mechanism for use in switch statements.- Specified by:
getPrimaryType
in interfaceVRMLNode
- Returns:
- The primary type
-
getSecondaryType
public int[] getSecondaryType()Get the secondary types of this node. Replaces the instanceof mechanism for use in switch statements. If there are no secondary types, it will return a zero-length array.- Specified by:
getSecondaryType
in interfaceVRMLNode
- Returns:
- The secondary type
-
setVersion
public void setVersion(int major, int minor, boolean isStatic) Set the version of VRML that this node should represent. Different versions have different capabilities, even within the same node.- Specified by:
setVersion
in interfaceVRMLNode
- Parameters:
major
- The major version number of this sceneminor
- The minor version number of this sceneisStatic
- true if this node is under a StaticGroup and won't change after the setup is finished
-
getFieldDeclaration
Get the declaration of the field at the given index. This allows for reverse lookup if needed. If the field does not exist, this will give a value of null.- Specified by:
getFieldDeclaration
in interfaceVRMLNode
- Parameters:
index
- The index of the field to get information- Returns:
- A representation of this field's information
-
getFieldIndex
Get the index of the given field name. If the name does not exist for this node then return a value of -1.- Specified by:
getFieldIndex
in interfaceVRMLNode
- Parameters:
fieldName
- The name of the field we want the index from- Returns:
- The index of the field name or -1
-
getNumFields
public int getNumFields()Get the number of fields.- Specified by:
getNumFields
in interfaceVRMLNode
- Returns:
- The number of fields.
-
getNodeFieldIndices
public int[] getNodeFieldIndices()Get the list of indices that correspond to fields that contain nodes ie MFNode and SFNode). Empty for the default implementation. Any derived class that has node children should override this method with real values.- Specified by:
getNodeFieldIndices
in interfaceVRMLNode
- Returns:
- null
-
setUserData
Set arbitrary data for a given field. Provided primarily to help the EAI fulfill its requirements, but may be useful elsewhere.- Specified by:
setUserData
in interfaceVRMLNode
- Parameters:
index
- The index of destination field to setdata
- The item to store for the field- Throws:
InvalidFieldException
- The field index is not known
-
getUserData
Fetch the stored user data for a given field index. If nothing is registered, null is returned.- Specified by:
getUserData
in interfaceVRMLNode
- Parameters:
index
- The index of destination field to set- Returns:
- The item stored for the field or null
- Throws:
InvalidFieldException
- The field index is not known
-
setMetadataObject
Set the X3DMetadataObject that is associated with this node.- Specified by:
setMetadataObject
in interfaceVRMLNodeType
- Parameters:
data
- The node to register as the metadata- Throws:
InvalidFieldValueException
- The object instance provided does not implement VRMLMetadataNodeType or is not a proto instance that encapsulates it as it's primary type
-
getMetadataObject
Get the currently registered metadata object instance. If none is set then return null.- Specified by:
getMetadataObject
in interfaceVRMLNodeType
- Returns:
- The current metadata object or null
-
isSetupFinished
public boolean isSetupFinished()Check to see if setupFinished() has already been called on this node.- Specified by:
isSetupFinished
in interfaceVRMLNodeType
- Returns:
- true if setupFinished() has been called
-
setupFinished
public void setupFinished()Notification that the construction phase of this node has finished. If the node would like to do any internal processing, such as setting up geometry, then go for it now.- Specified by:
setupFinished
in interfaceVRMLNodeType
-
setDEF
public void setDEF()Notify this node that is has been DEFd. This method shall only be called before setupFinished(). It is an error to call it any other time. It is also guaranteed that this call will be made after construction, but before any of the setValue() methods have been called.- Specified by:
setDEF
in interfaceVRMLNodeType
- Throws:
IllegalStateException
- The setup is finished.
-
getRefCount
public int getRefCount(int layer) Ask for the current number of references to this object. Always returns zero for the proxy.- Specified by:
getRefCount
in interfaceVRMLNodeType
- Parameters:
layer
- The id of the layer to modify the ref count on- Returns:
- 0
-
updateRefCount
public void updateRefCount(int layer, boolean add) Change the reference count up or down by one. Ignored for node proxies.- Specified by:
updateRefCount
in interfaceVRMLNodeType
- Parameters:
layer
- The id of the layer to modify the ref count onadd
- true to increment the reference count, false to decrement
-
getLayerIds
public int[] getLayerIds()Get a listing of the current layer IDs that are directly or indirectly referencing this node. Always returns null for proxies.- Specified by:
getLayerIds
in interfaceVRMLNodeType
- Returns:
- null
-
getRemovedLayerIds
public int[] getRemovedLayerIds()Get the list of layer IDs that this node has just been removed from. If it currently has not been removed from anything, this will return null. This will remain updated until the nextclearRemovedLayerIds()
call.- Specified by:
getRemovedLayerIds
in interfaceVRMLNodeType
- Returns:
- An array of all the IDs this is delete from or null if none
-
clearRemovedLayerIds
public void clearRemovedLayerIds()Clear the current removed layer ID list. If there is nothing removed, this method does nothing.- Specified by:
clearRemovedLayerIds
in interfaceVRMLNodeType
-
setFrameStateManager
Ignored by this implementation.- Specified by:
setFrameStateManager
in interfaceVRMLNodeType
- Parameters:
mgr
- The manager instance to use
-
hasFieldChanged
public boolean hasFieldChanged(int index) Check to see if the given field has changed since we last checked. Calling this method will set the flag back to "not changed" so that two consecutive reads after a changed value would result in a true and then false being returned. If the field number is not recognized for this node then this returns false.- Specified by:
hasFieldChanged
in interfaceVRMLNodeType
- Parameters:
index
- The index of the field to change.- Returns:
- true if the field has changed since last read
-
sendRoute
Send a routed value from this node to the given destination node. Empty implementation in the base class. Derived classes will need to override this to make route management work.- Specified by:
sendRoute
in interfaceVRMLNodeType
- Parameters:
time
- The time that this route occurred (not necessarily epoch time. Should be treated as a relative value only)srcIndex
- The index of the field in this node that the value should be sent fromdestNode
- The node reference that we will be sending the value todestIndex
- The index of the field in the destination node that the value should be sent to.
-
addNodeListener
Add a listener to this node instance. If the listener is already added or null the request is silently ignored.- Specified by:
addNodeListener
in interfaceVRMLNodeType
- Parameters:
l
- The listener instance to add
-
removeNodeListener
Remove a listener from this node instance. If the listener is null or not registered, the request is silently ignored.- Specified by:
removeNodeListener
in interfaceVRMLNodeType
- Parameters:
l
- The listener to be removed
-
getFieldValue
Get the value of a field. If the field is a primitive type, it will return a class representing the value. For arrays or nodes it will return the instance directly.- Specified by:
getFieldValue
in interfaceVRMLNodeType
- Parameters:
index
- The index of the field to change.- Returns:
- The class representing the field value
- Throws:
InvalidFieldException
- The field index is not known
-
setValue
public void setValue(int index, int value) throws InvalidFieldException, InvalidFieldValueException, InvalidFieldAccessException Set the value of the field at the given index as an integer. This would be used to set SFInt32 field types.- Specified by:
setValue
in interfaceVRMLNodeType
- Parameters:
index
- The index of destination field to setvalue
- The new value to use for the node- Throws:
InvalidFieldException
- The field index is not knownInvalidFieldValueException
- The value provided is out of range for the field type.InvalidFieldAccessException
- The call is attempting to write to a field that does not permit writing now
-
setValue
public void setValue(int index, int[] value, int numValid) throws InvalidFieldException, InvalidFieldValueException, InvalidFieldAccessException Set the value of the field at the given index as an array of integers. This would be used to set MFInt32 field types.- Specified by:
setValue
in interfaceVRMLNodeType
- Parameters:
index
- The index of destination field to setvalue
- The new value to use for the nodenumValid
- The number of valid values to copy from the array- Throws:
InvalidFieldException
- The field index is not knownInvalidFieldValueException
- The value provided is out of range for the field type.InvalidFieldAccessException
- The call is attempting to write to a field that does not permit writing now
-
setValue
public void setValue(int index, boolean value) throws InvalidFieldException, InvalidFieldValueException, InvalidFieldAccessException Set the value of the field at the given index as an boolean. This would be used to set SFBool field types.- Specified by:
setValue
in interfaceVRMLNodeType
- Parameters:
index
- The index of destination field to setvalue
- The new value to use for the node- Throws:
InvalidFieldException
- The field index is not knownInvalidFieldValueException
- The value provided is out of range for the field type.InvalidFieldAccessException
- The call is attempting to write to a field that does not permit writing now
-
setValue
public void setValue(int index, boolean[] value, int numValid) throws InvalidFieldException, InvalidFieldValueException, InvalidFieldAccessException Set the value of the field at the given index as an array of boolean. This would be used to set MFBool field types.- Specified by:
setValue
in interfaceVRMLNodeType
- Parameters:
index
- The index of destination field to setvalue
- The new value to use for the nodenumValid
- The number of valid values to copy from the array- Throws:
InvalidFieldException
- The field index is not knownInvalidFieldValueException
- The value provided is out of range for the field type.InvalidFieldAccessException
- The call is attempting to write to a field that does not permit writing now
-
setValue
public void setValue(int index, float value) throws InvalidFieldException, InvalidFieldValueException, InvalidFieldAccessException Set the value of the field at the given index as a float. This would be used to set SFFloat field types.- Specified by:
setValue
in interfaceVRMLNodeType
- Parameters:
index
- The index of destination field to setvalue
- The new value to use for the node- Throws:
InvalidFieldException
- The field index is not knownInvalidFieldValueException
- The value provided is out of range for the field type.InvalidFieldAccessException
- The call is attempting to write to a field that does not permit writing now
-
setValue
public void setValue(int index, float[] value, int numValid) throws InvalidFieldException, InvalidFieldValueException, InvalidFieldAccessException Set the value of the field at the given index as an array of floats. This would be used to set MFFloat, SFVec2f, SFVec3f and SFRotation field types.- Specified by:
setValue
in interfaceVRMLNodeType
- Parameters:
index
- The index of destination field to setvalue
- The new value to use for the nodenumValid
- The number of valid values to copy from the array- Throws:
InvalidFieldException
- The field index is not knownInvalidFieldValueException
- The value provided is out of range for the field type.InvalidFieldAccessException
- The call is attempting to write to a field that does not permit writing now
-
setValue
public void setValue(int index, long value) throws InvalidFieldException, InvalidFieldValueException, InvalidFieldAccessException Set the value of the field at the given index as an long. This would be used to set SFTime field types.- Specified by:
setValue
in interfaceVRMLNodeType
- Parameters:
index
- The index of destination field to setvalue
- The new value to use for the node- Throws:
InvalidFieldException
- The field index is not knownInvalidFieldValueException
- The value provided is out of range for the field type.InvalidFieldAccessException
- The call is attempting to write to a field that does not permit writing now
-
setValue
public void setValue(int index, long[] value, int numValid) throws InvalidFieldException, InvalidFieldValueException, InvalidFieldAccessException Set the value of the field at the given index as an array of longs. This would be used to set MFTime field types.- Specified by:
setValue
in interfaceVRMLNodeType
- Parameters:
index
- The index of destination field to setvalue
- The new value to use for the nodenumValid
- The number of valid values to copy from the array- Throws:
InvalidFieldException
- The field index is not knownInvalidFieldValueException
- The value provided is out of range for the field type.InvalidFieldAccessException
- The call is attempting to write to a field that does not permit writing now
-
setValue
public void setValue(int index, double value) throws InvalidFieldException, InvalidFieldValueException, InvalidFieldAccessException Set the value of the field at the given index as an double. This would be used to set SFDouble field types.- Specified by:
setValue
in interfaceVRMLNodeType
- Parameters:
index
- The index of destination field to setvalue
- The new value to use for the node- Throws:
InvalidFieldException
- The field index is not knownInvalidFieldValueException
- The value provided is out of range for the field type.InvalidFieldAccessException
- The call is attempting to write to a field that does not permit writing now
-
setValue
public void setValue(int index, double[] value, int numValid) throws InvalidFieldException, InvalidFieldValueException, InvalidFieldAccessException Set the value of the field at the given index as an array of doubles. This would be used to set MFDouble, SFVec2d and SFVec3d field types.- Specified by:
setValue
in interfaceVRMLNodeType
- Parameters:
index
- The index of destination field to setvalue
- The new value to use for the nodenumValid
- The number of valid values to copy from the array- Throws:
InvalidFieldException
- The field index is not knownInvalidFieldValueException
- The value provided is out of range for the field type.InvalidFieldAccessException
- The call is attempting to write to a field that does not permit writing now
-
setValue
public void setValue(int index, String value) throws InvalidFieldException, InvalidFieldValueException, InvalidFieldAccessException Set the value of the field at the given index as a string. This would be used to set SFString field types.- Specified by:
setValue
in interfaceVRMLNodeType
- Parameters:
index
- The index of destination field to setvalue
- The new value to use for the node- Throws:
InvalidFieldException
- The field index is not knownInvalidFieldValueException
- The value provided is out of range for the field type.InvalidFieldAccessException
- The call is attempting to write to a field that does not permit writing now
-
setValue
public void setValue(int index, String[] value, int numValid) throws InvalidFieldException, InvalidFieldValueException, InvalidFieldAccessException Set the value of the field at the given index as an array of strings. This would be used to set MFString field types.- Specified by:
setValue
in interfaceVRMLNodeType
- Parameters:
index
- The index of destination field to setvalue
- The new value to use for the nodenumValid
- The number of valid values to copy from the array- Throws:
InvalidFieldException
- The field index is not knownInvalidFieldValueException
- The value provided is out of range for the field type.InvalidFieldAccessException
- The call is attempting to write to a field that does not permit writing now
-
setValue
public void setValue(int index, VRMLNodeType child) throws InvalidFieldException, InvalidFieldValueException, InvalidFieldAccessException Set the value of the field at the given index as a node. This would be used to set SFNode field types.- Specified by:
setValue
in interfaceVRMLNodeType
- Parameters:
index
- The index of destination field to setchild
- The new value to use for the node- Throws:
InvalidFieldException
- The field index is not knownInvalidFieldValueException
- The value provided is out of range for the field type.InvalidFieldAccessException
- The call is attempting to write to a field that does not permit writing now
-
setValue
public void setValue(int index, VRMLNodeType[] children, int numValid) throws InvalidFieldException, InvalidFieldValueException, InvalidFieldAccessException Set the value of the field at the given index as an array of nodes. This would be used to set MFNode field types.- Specified by:
setValue
in interfaceVRMLNodeType
- Parameters:
index
- The index of destination field to setchildren
- The new value to use for the nodenumValid
- The number of valid values to copy from the array- Throws:
InvalidFieldException
- The field index is not knownInvalidFieldValueException
- The value provided is out of range for the field type.InvalidFieldAccessException
- The call is attempting to write to a field that does not permit writing now
-
notifyExternProtoLoaded
Description copied from interface:VRMLNodeType
Notify a node that an ExternProto has resolved. This will verify the objects type and add it to the render sceneGraph.- Specified by:
notifyExternProtoLoaded
in interfaceVRMLNodeType
- Parameters:
index
- The field indexnode
- The node resolved- Throws:
InvalidFieldValueException
- If the proto contains he wrong type
-
fieldChanged
public void fieldChanged(int index) Notification that the field represented by the given index has changed. Use this to pass into the root scene a notification that it's own output has changed, as well as mark the local flag so that routing can happen.- Specified by:
fieldChanged
in interfaceVRMLNodeListener
- Parameters:
index
- The index of the field that changed.
-
clone
Make a cloned copy of this class. Implementation makes something between a shallow and deep copy, depending on the internal structure.- Overrides:
clone
in classObject
- Returns:
- A cloned instance of this instance
- Throws:
CloneNotSupportedException
- Something lower couldn't clone
-
setRealNode
Set the real node that this proxy is representing. At this time, do any mapping from the fields to check for validity. If the parameter value is null, clear the existing mappings. If a field has been requested due to an external ROUTE that does not exist in the real node, an error message is sent through the error reporter and that field is subsequently ignored, but the rest of the mappings continue.- Parameters:
node
- The node instance to use
-
getRealNode
Fetch the real node reference. If one is not set, this will return null.- Returns:
- A reference to the real node or null
-
getInlineDEFName
Get the DEF name of the inline that this import works with.- Returns:
- The DEF name string
-
getExportedName
Get the name that the node was exported as from the inline.- Returns:
- The export name string
-
getImportedName
-