Class CRProtoInstance
- All Implemented Interfaces:
VRMLExecutionSpace
,VRMLNode
,FrameStateListener
,VRMLNodeType
,VRMLProtoInstance
This class cannot be instantiated directly. The only way to get an instance of this is to ask for one from a proto implementation - either external or normal. As a node that does not form part of the scene graph, the fields that are those of the root node's definition. If you ask for the normal implementation node, you will also get this first node.
IS Implementation
This implementation handles IS values as a sort of route with a few missing
bits. When a value is set in the interface declaration, we look up all the
IS related nodes and fields. For each of these we then call
sendRoute()
on them to update their value.
For the reverse case, when a value changes inside the proto body, we just
mark the field as being changed in that node. Then, when someone checks the
proto interface field, it will go through the list of related IS nodes and
ask their field if it has been updated. If it has, then this value is
copied to the interface declaration field and, using setValue()
call on the interface field, makes sure it gets propagated to the other
users.
Note: The upshot of this implementation is that is does not correctly
deal with IS values where the end user has not connected a ROUTE to one of
the proto declaration fields. In order to send values to items where there
is an IS, we rely on having the user call hasFieldChanged()
or setValue()
to update all the internal users of the field.
In the case where fields are not routed, this means that
hasFieldChanged()
is never called and hence the other users of
IS are never informed.
DEF/USE Handling
Because you can DEF an instance of a Proto, we run into all sorts of interesting problems. As we have to put in Java3D shared groups and stuff we really need access to the root node before it is created. The problem there is that we don't have that access, and even when we do it is too late to deal with the DEF work. In an ideal world, when you ask for the implementation node the J3D node it returns and the node this instance returns are going to be the same thing. DEF completely stuffs with that idea.
The solution implemented here is to take the root node and apply any wrapping that may be needed to get it to work in a shared environment. In order to use a ProtoInstance within the J3D scene you first check for the type being correct by asking for the Implementation node and checking the interface corresponds to one that you are allowed to accept. If that passes then you check for the DEF with isDEF() just like any other node. Then, to add the real object to the scene graph you call either getSharedObject() or getSceneGraphObject() as appropriate. Note that they must be called on this class instance, not on the implementation node. If you call them on the implementation instance, the results are undefined and will probably lead to a lot of errors generated by the Java3D internals.
- Version:
- $Revision: 1.77 $
- Author:
- Justin Couch
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final String
A standard message for when the supplied node is wrong.protected int
A counter for the number of body nodesprotected VRMLNodeType[]
The nodes that form the body groupprotected boolean
Whether the protoBody is completeprotected org.j3d.util.ErrorReporter
Reporter instance for handing out errorsprotected static final String
When the same field is defined twice, but with different typesprotected final int
Index of the metadata fieldprotected final org.j3d.util.IntHashMap
<Boolean> Map of whether the field index has been changed since last checkprotected List
<VRMLFieldDeclaration> List of the field maps registered in order for their definitions.Data mapping holding the field name -> index (Integer) mappingprotected final ThreadLocal
<VRMLFieldData> Scratch class var for returning field data.protected final org.j3d.util.IntHashMap
<Integer> A map of the field indexes (Integer) to the size of the data provided at that field.protected final org.j3d.util.IntHashMap
<Object> A map of the field indexes (Integer) to their values (object).protected boolean
Flag indicating we are in setup mode currentlyprotected boolean
Flag indicating this is a DEF nodeprotected int[]
IsList entry to use for sendRoute, the one that triggered the eventprotected final org.j3d.util.IntHashMap
<ProtoFieldInfo[]> The mapping that holds is field index (key) to the list of destination node information.protected boolean
Flag for the node being staticprotected boolean
Flag indicating VRML97 lookup semantics for IS behaviourprotected int
The last field index.protected int[]
The list of layer IDs that reference this node.protected static final String
Message for when the node in setValue() is not a Metadataprotected static final String
Message for when the proto is not a Metadataprotected final String
The name of this node typeprotected VRMLProtoInstance
proto representation of the metadata nodeMapping of an external imported name to the ImportNodeProxy instanceprotected int[]
The current number of references to this node.protected int[]
The list of IDs that have been marked as being removed.protected VRMLNodeType
The node that describes the type of protoprotected ProtoScene
Contained scene informationprotected FrameStateManager
Frame state manager for this event model instanceUnique version of fieldIndexMap with no exposedField expansionsprotected VRMLNodeType
SFNode metadata NULLprotected static final String
Message when the field type is not valid in VRML97protected int
The major version of the spec this instance belongs to.protected int
The minor version of the spec this instance belongs to. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
CRProtoInstance
(String name, boolean vrml97, VRMLFieldDeclaration[] fields, int numBodyNodes) Create an instance for the proto with the number of fields. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Add a listener to this node instance.void
Ignored by this implementation.protected int
appendField
(VRMLFieldDeclaration field) Append a field declaration to this node.void
Clear the current removed layer ID list.protected void
fireFieldChanged
(int index) Send a notification to the registered listeners that a field has been changed.Make a listing of all fields that are currently registered in this node.Get the list of all the body nodes in this proto instance.boolean
Find out whether this proto is complete and ready to use.Get the contained scene graph that this instance has.int
Get the count of the number of fields currently registered.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 first node declared in the proto as that defines just how we we can add this into the scene graph.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 defined for this node.int
Get the primary type of this node.int
getRefCount
(int layer) Ask for the current number of references to this object in the given layer.int[]
Get the list of layer IDs that this node has just been removed from.int[]
Get the secondary type 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
isDefaultValue
(int index) Determine whether the field is a default value or has been set by the proto resolving.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
Denote that this proto is complete and ready to use.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
Set the frame state manager to be used by this proto instance.void
Set the X3DMetadataObject that is associated with this node.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 booleans.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 integer.void
setValue
(int index, long[] value, int numValid) Set the value of the field at the given index as an array of integers.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 for a given layer ID.
-
Field Details
-
BAD_NODE_MSG
A standard message for when the supplied node is wrong. Just add the node name of the wrong type to the end.- See Also:
-
METADATA_PROTO_MSG
Message for when the proto is not a Metadata- See Also:
-
METADATA_NODE_MSG
Message for when the node in setValue() is not a Metadata- See Also:
-
VRML97_FIELD_MSG
Message when the field type is not valid in VRML97- See Also:
-
FIELD_CLASH_MSG
When the same field is defined twice, but with different types- See Also:
-
errorReporter
protected org.j3d.util.ErrorReporter errorReporterReporter instance for handing out errors -
isStatic
protected boolean isStaticFlag for the node being static -
vrmlMajorVersion
protected int vrmlMajorVersionThe major version of the spec this instance belongs to. -
vrmlMinorVersion
protected int vrmlMinorVersionThe minor version of the spec this instance belongs to. -
fieldIndexMap
-
uniqueFieldIndexMap
-
fieldDeclList
List of the field maps registered in order for their definitions. When created, this list will have a null value in each index position for the size of the number of declared fields. This allows a user to set(int, object) the value if they want. -
nodeName
The name of this node type -
FIELD_METADATA
protected final int FIELD_METADATAIndex of the metadata field -
fieldLocalData
Scratch class var for returning field data. Assigned at construction. -
bodyNodes
The nodes that form the body group -
bodyNodeCount
protected int bodyNodeCountA counter for the number of body nodes -
rootNode
The node that describes the type of proto -
sceneInfo
Contained scene information -
stateManager
Frame state manager for this event model instance -
proxyNodeMap
-
isMap
The mapping that holds is field index (key) to the list of destination node information. (ProtoFieldInfo - value). -
fieldValueMap
A map of the field indexes (Integer) to their values (object). Fields using primitive types have these converted to the equivalent Class. -
fieldSizeMap
A map of the field indexes (Integer) to the size of the data provided at that field. Used for multi-value fields and represents the number of elements, not the number of raw values. -
fieldChangedMap
Map of whether the field index has been changed since last check -
isDEF
protected boolean isDEFFlag indicating this is a DEF node -
inSetup
protected boolean inSetupFlag indicating we are in setup mode currently -
isVrml97
protected boolean isVrml97Flag indicating VRML97 lookup semantics for IS behaviour -
lastFieldIndex
protected int lastFieldIndexThe last field index. Used for extern protos that append fields -
isListEntry
protected int[] isListEntryIsList entry to use for sendRoute, the one that triggered the event -
refCounts
protected int[] refCountsThe current number of references to this node. This is for informational purposes only and should never be touched by derived classes. -
layerIds
protected int[] layerIdsThe list of layer IDs that reference this node. Should correspond 1:1 to the counts inrefCounts
. If none, this is null. -
removedLayerIds
protected int[] removedLayerIdsThe list of IDs that have been marked as being removed. -
completeBody
protected boolean completeBodyWhether the protoBody is complete -
vfMetadata
SFNode metadata NULL -
pMetadata
proto representation of the metadata node
-
-
Constructor Details
-
CRProtoInstance
protected CRProtoInstance(String name, boolean vrml97, VRMLFieldDeclaration[] fields, int numBodyNodes) Create an instance for the proto with the number of fields. To set the values of these fields, use the normal setValue methods. The fields are list does not care if it contains null values.- Parameters:
name
- The node name of the protovrml97
- true if this is a VRML97 issue protofields
- The fields that need to be set herenumBodyNodes
- The number of nodes in the body of the proto
-
-
Method Details
-
getImplementationNode
Get the first node declared in the proto as that defines just how we we can add this into the scene graph. If this is an empty prototype implementation, or represents an Extern proto that has not been loaded yet then this will return null.- Specified by:
getImplementationNode
in interfaceVRMLProtoInstance
- Returns:
- The node instance that represents the first node
-
getBodyNodes
Get the list of all the body nodes in this proto instance. Nodes are defined in declaration order. Index 0 is always the same value as that returned bygetImplementationNode()
. This should be called sparingly. It is really only of use to something that needs to traverse the entire scene graph or for scripting to provide access to the root of the scene.- Specified by:
getBodyNodes
in interfaceVRMLProtoInstance
- Returns:
- The list of nodes from the body
-
getFieldCount
public int getFieldCount()Get the count of the number of fields currently registered.- Specified by:
getFieldCount
in interfaceVRMLProtoInstance
- Returns:
- The number of fields available
-
getAllFields
Make a listing of all fields that are currently registered in this node. The list contains instances ofVRMLFieldDeclaration
.- Specified by:
getAllFields
in interfaceVRMLProtoInstance
- Returns:
- A list of the current field declarations
-
getRefCount
public int getRefCount(int layer) Ask for the current number of references to this object in the given layer. If this node represents a layer node itself, then the value returned for that ID should always be one. If the layer requested does not have a reference to this node, return zero.- Specified by:
getRefCount
in interfaceVRMLNodeType
- Parameters:
layer
- The id of the layer to get the ref count for- Returns:
- The number of references to this node
-
updateRefCount
public void updateRefCount(int layer, boolean add) Change the reference count up or down by one for a given layer ID. If there is no reference to the given layer ID previously, add one now. A listing of the layer IDs that reference this node can be retrieved throughgetLayerIds()
.- 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. If this layer is not part of a live scene graph (eg held by a script code, but not by the script itself) then this will will return a null value. The array will always be exactly equal in length to the number of IDs that reference this node.- Specified by:
getLayerIds
in interfaceVRMLNodeType
- Returns:
- An array of all the IDs referencing this node or null if none
-
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
-
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 implment 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
-
setFrameStateManager
Set the frame state manager to be used by this proto instance. used to pass in information about the contained scene for extern proto handler.- Specified by:
setFrameStateManager
in interfaceVRMLNodeType
- Parameters:
mgr
- The manager instance to use
-
allEventsComplete
public void allEventsComplete()Ignored by this implementation.- 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
-
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
-
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.
-
isDEF
-
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
-
getNodeFieldIndices
public int[] getNodeFieldIndices()Get the list of indices that correspond to fields that contain nodes ie MFNode and SFNode). Used for blind scene graph traversal without needing to spend time querying for all fields etc. If a node does not have any fields that contain nodes, this shall return null. The field list covers all field types, regardless of whether they are readable or not at the VRML-level.- Specified by:
getNodeFieldIndices
in interfaceVRMLNode
- Returns:
- The list of field indices that correspond to SF/MFnode fields or null if none
-
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
-
getNumFields
public int getNumFields()Get the number of fields defined for this node.- Specified by:
getNumFields
in interfaceVRMLNode
- Returns:
- The number of fields.
-
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
-
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 consective 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.For a proto instance, we have to check the IS values and so look at every output node that has output mapped back to this field. We never keep a local flag of the fields stored here.
- Specified by:
hasFieldChanged
in interfaceVRMLNodeType
- Parameters:
index
- The index of the field to change.- Returns:
- true if the field has changed since last read
-
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
-
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 type of this node. Replaces the instanceof mechanism for use in switch statements. For protos, the secondary type is described as the primary type of the defining node type.- Specified by:
getSecondaryType
in interfaceVRMLNode
- Returns:
- The secondary type
-
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
-
sendRoute
Send a routed value from this node to the given destination node. The route should use the appropriate setValue() method of the destination node. It should not attempt to cast the node up to a higher level. Routing should also follow the standard rules for the loop breaking and other appropriate rules for the specification.- 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.
-
setValue
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 index does not match a known fieldInvalidFieldValueException
- The value provided is out of range for the field type.
-
setValue
public void setValue(int index, int[] value, int numValid) throws InvalidFieldException, InvalidFieldValueException 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 index does not match a known fieldInvalidFieldValueException
- The value provided is out of range for the field type.
-
setValue
public void setValue(int index, long value) throws InvalidFieldException, InvalidFieldValueException Set the value of the field at the given index as an integer. This would be used to set SFLong 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 index does not match a known fieldInvalidFieldValueException
- The value provided is out of range for the field type.
-
setValue
public void setValue(int index, long[] value, int numValid) throws InvalidFieldException, InvalidFieldValueException Set the value of the field at the given index as an array of integers. This would be used to set MFLong 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 index does not match a known fieldInvalidFieldValueException
- The value provided is out of range for the field type.
-
setValue
public void setValue(int index, boolean value) throws InvalidFieldException, InvalidFieldValueException 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 knowInvalidFieldValueException
- The value provided is out of range for the field type.
-
setValue
public void setValue(int index, boolean[] value, int numValid) throws InvalidFieldException, InvalidFieldValueException Set the value of the field at the given index as an array of booleans. 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 knowInvalidFieldValueException
- The value provided is out of range for the field type.
-
setValue
public void setValue(int index, float value) throws InvalidFieldException, InvalidFieldValueException 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 index does not match a known fieldInvalidFieldValueException
- The value provided is out of range for the field type.
-
setValue
public void setValue(int index, float[] value, int numValid) throws InvalidFieldException, InvalidFieldValueException 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 index does not match a known fieldInvalidFieldValueException
- The value provided is out of range for the field type.
-
setValue
public void setValue(int index, double value) throws InvalidFieldException, InvalidFieldValueException 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 index does not match a known fieldInvalidFieldValueException
- The value provided is out of range for the field type.
-
setValue
public void setValue(int index, double[] value, int numValid) throws InvalidFieldException, InvalidFieldValueException 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 index does not match a known fieldInvalidFieldValueException
- The value provided is out of range for the field type.
-
setValue
public void setValue(int index, String value) throws InvalidFieldException, InvalidFieldValueException 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 index does not match a known fieldInvalidFieldValueException
- The value provided is out of range for the field type.
-
setValue
public void setValue(int index, String[] value, int numValid) throws InvalidFieldException, InvalidFieldValueException 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 index does not match a known fieldInvalidFieldValueException
- The value provided is out of range for the field type.
-
setValue
public void setValue(int index, VRMLNodeType child) throws InvalidFieldException, InvalidFieldValueException 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 index does not match a known fieldInvalidFieldValueException
- The value provided is out of range for the field type.
-
setValue
public void setValue(int index, VRMLNodeType[] children, int numValid) throws InvalidFieldException, InvalidFieldValueException 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 index does not match a known fieldInvalidFieldValueException
- The value provided is out of range for the field type.
-
getContainedScene
Get the contained scene graph that this instance has. This represents everything about the internal scene that the node declaration wraps. This is a real-time representation so that if it the nodes contains a script that changes the internal representation then this instance will be updated to reflect and changes made.- Specified by:
getContainedScene
in interfaceVRMLExecutionSpace
- Returns:
- The scene contained by this node instance
-
appendField
Append a field declaration to this node. This is added to the current list on the end. If the field already exists with the given name but different values exception will be generated. If the field has exactly the same signature it will silently ignore the request.- Parameters:
field
- The new field to add- Returns:
- The index that this field was added at
- Throws:
FieldExistsException
- A conflicting field of the same name already exists for this node
-
setComplete
public void setComplete()Denote that this proto is complete and ready to use. Extern protos and local protos resolve completeness differently so this cannot be in the finishCreate method. -
getComplete
public boolean getComplete()Find out whether this proto is complete and ready to use.- Returns:
- Is the proto ready to use?
-
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
-
isDefaultValue
Determine whether the field is a default value or has been set by the proto resolving.- Parameters:
index
- The index of the field to change.- Returns:
- Is it a default value
- Throws:
InvalidFieldException
- The field index is not known
-
fireFieldChanged
protected void fireFieldChanged(int index) Send a notification to the registered listeners that a field has been changed. If no listeners have been registered, then this does nothing, so always call it regardless.- Parameters:
index
- The index of the field that changed
-