|
Xj3D 2.0 VRML/X3D Code API | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.web3d.vrml.renderer.common.nodes.AbstractNode
public abstract class AbstractNode
Base node for all implementations that define their own field handling.
Each node will keep its own fieldDeclarations and fieldMaps. These will be created in a static constructor so only one copy per class will be created.
Each node will maintain its own LAST_*_INDEX which tells others what the last field declared by this node.
| Field Summary | |
|---|---|
protected static java.lang.String |
BAD_NODE_MSG
A standard message for when the supplied node is wrong. |
protected ErrorReporter |
errorReporter
Reporter instance for handing out errors |
static int |
FIELD_METADATA
The field index for the metadata node field |
protected java.lang.ThreadLocal<VRMLFieldData> |
fieldLocalData
Scratch class var for returning field data. |
protected boolean[] |
hasChanged
hasChanged flags for fields |
protected static java.lang.String |
INIT_ONLY_WRITE_MSG
Standard message for when the user is attempting to set a value for an initializeOnly field (field access field in VRML97 terms) after the setup process is complete. |
protected boolean |
inSetup
Is this node still being setup/parsed. |
protected boolean |
isDEF
Flag indicating this is a DEF node |
protected boolean |
isStatic
Flag for the node being static |
static int |
LAST_NODE_INDEX
The last field index used by this class |
protected int[] |
layerIds
The list of layer IDs that reference this node. |
protected static java.lang.String |
METADATA_NODE_MSG
Message for when the node in setValue() is not a Metadata |
protected static java.lang.String |
METADATA_PROTO_MSG
Message for when the proto is not a Metadata |
protected java.lang.String |
nodeName
The name of this node |
protected VRMLProtoInstance |
pMetadata
proto representation of the metadata node |
protected int[] |
refCounts
The current number of references to this node. |
protected int[] |
removedLayerIds
The list of IDs that have been marked as being removed. |
protected FrameStateManager |
stateManager
State manager for propogating updates |
protected VRMLNodeType |
vfMetadata
SFNode metadata NULL |
protected int |
vrmlMajorVersion
The major version of the spec this instance belongs to. |
protected int |
vrmlMinorVersion
The minor version of the spec this instance belongs to. |
| Constructor Summary | |
|---|---|
AbstractNode(java.lang.String name)
Create a new instance of this node with the given node type name. |
|
| Method Summary | |
|---|---|
void |
addNodeListener(VRMLNodeListener l)
Add a listener to this node instance. |
void |
allEventsComplete()
Ignored by this base implementation. |
protected void |
checkNodeType(VRMLNodeType node)
Check to see if the supplied node type is the same as this node. |
protected static void |
checkSecondaryType(VRMLNodeType instance,
int[] type,
java.lang.String msg)
Verify that one of a protoInstance's secondary type is one of the supplied types. |
protected static void |
checkSecondaryType(VRMLNodeType instance,
int type,
java.lang.String msg)
Verify that one of a protoInstance's secondary type is the supplied type. |
void |
clearRemovedLayerIds()
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. |
VRMLFieldData |
getFieldValue(int index)
Get the value of a field. |
int[] |
getLayerIds()
Get a listing of the current layer IDs that are directly or indirectly referencing this node. |
VRMLNodeType |
getMetadataObject()
Get the currently registered metadata object instance. |
int |
getRefCount(int layer)
Ask for the current number of references to this object in the given layer. |
int[] |
getRemovedLayerIds()
Get the list of layer IDs that this node has just been removed from. |
int[] |
getSecondaryType()
Get the secondary types of this node. |
java.lang.Object |
getUserData(int index)
Fetch the stored user data for a given field index. |
java.lang.String |
getVRMLNodeName()
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 |
isSetupFinished()
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 |
removeNodeListener(VRMLNodeListener l)
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(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 |
setFrameStateManager(FrameStateManager mgr)
Set the state manager instance to be used by the node. |
void |
setMetadataObject(VRMLNodeType data)
Set the X3DMetadataObject that is associated with this node. |
void |
setupFinished()
Notification that the construction phase of this node has finished. |
void |
setUserData(int index,
java.lang.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 |
setValue(int index,
java.lang.String value)
Set the value of the field at the given index as a string. |
void |
setValue(int index,
java.lang.String[] value,
int numValid)
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. |
protected void |
updateRefs(VRMLNodeType node,
boolean add)
Internal convenience method to update references on the given child node of the current node. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface org.web3d.vrml.lang.VRMLNode |
|---|
getFieldDeclaration, getFieldIndex, getNodeFieldIndices, getNumFields, getPrimaryType |
| Field Detail |
|---|
public static final int FIELD_METADATA
public static final int LAST_NODE_INDEX
protected static final java.lang.String BAD_NODE_MSG
protected static final java.lang.String INIT_ONLY_WRITE_MSG
protected static final java.lang.String METADATA_PROTO_MSG
protected static final java.lang.String METADATA_NODE_MSG
protected final java.lang.String nodeName
protected final java.lang.ThreadLocal<VRMLFieldData> fieldLocalData
protected ErrorReporter errorReporter
protected boolean[] hasChanged
protected boolean inSetup
protected boolean isDEF
protected boolean isStatic
protected int vrmlMajorVersion
protected int vrmlMinorVersion
protected FrameStateManager stateManager
protected int[] refCounts
protected int[] layerIds
refCounts. If none, this is null.
protected int[] removedLayerIds
protected VRMLNodeType vfMetadata
protected VRMLProtoInstance pMetadata
| Constructor Detail |
|---|
public AbstractNode(java.lang.String name)
name - The name of the type of node| Method Detail |
|---|
public void allEventsComplete()
allEventsComplete in interface FrameStateListenerpublic void setErrorReporter(ErrorReporter reporter)
setErrorReporter in interface VRMLNodereporter - The instance to use or nullpublic java.lang.String getVRMLNodeName()
getVRMLNodeName in interface VRMLNodepublic boolean isDEF()
isDEF in interface VRMLNodepublic int[] getSecondaryType()
getSecondaryType in interface VRMLNode
public void setVersion(int major,
int minor,
boolean isStatic)
setVersion in interface VRMLNodemajor - The major version number of this sceneminor - The minor version number of this sceneisStatic - true if this node is under a static group and won't
change after the setup is finished
public void setUserData(int index,
java.lang.Object data)
throws InvalidFieldException
setUserData in interface VRMLNodeindex - The index of destination field to setdata - The item to store for the field
InvalidFieldException - The field index is not known
public java.lang.Object getUserData(int index)
throws InvalidFieldException
getUserData in interface VRMLNodeindex - The index of destination field to set
InvalidFieldException - The field index is not known
public void setMetadataObject(VRMLNodeType data)
throws InvalidFieldValueException
setMetadataObject in interface VRMLNodeTypedata - The node to register as the metadata
InvalidFieldValueException - The object instance provided
does not implment VRMLMetadataNodeType or is not a proto instance
that encapsulates it as it's primary typepublic VRMLNodeType getMetadataObject()
getMetadataObject in interface VRMLNodeTypepublic boolean isSetupFinished()
isSetupFinished in interface VRMLNodeTypepublic void setupFinished()
setupFinished in interface VRMLNodeTypepublic void setDEF()
setDEF in interface VRMLNodeTypejava.lang.IllegalStateException - The setup is finished.public int getRefCount(int layer)
getRefCount in interface VRMLNodeTypelayer - The id of the layer to get the ref count for
public void updateRefCount(int layer,
boolean add)
getLayerIds().
updateRefCount in interface VRMLNodeTypelayer - The id of the layer to modify the ref count onadd - true to increment the reference count, false to decrementpublic int[] getLayerIds()
getLayerIds in interface VRMLNodeTypepublic int[] getRemovedLayerIds()
clearRemovedLayerIds() call.
getRemovedLayerIds in interface VRMLNodeTypepublic void clearRemovedLayerIds()
clearRemovedLayerIds in interface VRMLNodeTypepublic void setFrameStateManager(FrameStateManager mgr)
setFrameStateManager in interface VRMLNodeTypemgr - The manager instance to usepublic boolean hasFieldChanged(int index)
hasFieldChanged in interface VRMLNodeTypeindex - The index of the field to change.
public void sendRoute(double time,
int srcIndex,
VRMLNodeType destNode,
int destIndex)
sendRoute in interface VRMLNodeTypetime - 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.public void addNodeListener(VRMLNodeListener l)
addNodeListener in interface VRMLNodeTypel - The listener instance to addpublic void removeNodeListener(VRMLNodeListener l)
removeNodeListener in interface VRMLNodeTypel - The listener to be removed
public VRMLFieldData getFieldValue(int index)
throws InvalidFieldException
getFieldValue in interface VRMLNodeTypeindex - The index of the field to change.
InvalidFieldException - The field index is not known
public void setValue(int index,
int value)
throws InvalidFieldException,
InvalidFieldValueException,
InvalidFieldAccessException
setValue in interface VRMLNodeTypeindex - The index of destination field to setvalue - The new value to use for the node
InvalidFieldException - The field index is not known
InvalidFieldValueException - 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
public void setValue(int index,
int[] value,
int numValid)
throws InvalidFieldException,
InvalidFieldValueException,
InvalidFieldAccessException
setValue in interface VRMLNodeTypeindex - 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
InvalidFieldException - The field index is not known
InvalidFieldValueException - 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
public void setValue(int index,
boolean value)
throws InvalidFieldException,
InvalidFieldValueException,
InvalidFieldAccessException
setValue in interface VRMLNodeTypeindex - The index of destination field to setvalue - The new value to use for the node
InvalidFieldException - The field index is not known
InvalidFieldValueException - 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
public void setValue(int index,
boolean[] value,
int numValid)
throws InvalidFieldException,
InvalidFieldValueException,
InvalidFieldAccessException
setValue in interface VRMLNodeTypeindex - 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
InvalidFieldException - The field index is not known
InvalidFieldValueException - 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
public void setValue(int index,
float value)
throws InvalidFieldException,
InvalidFieldValueException,
InvalidFieldAccessException
setValue in interface VRMLNodeTypeindex - The index of destination field to setvalue - The new value to use for the node
InvalidFieldException - The field index is not known
InvalidFieldValueException - 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
public void setValue(int index,
float[] value,
int numValid)
throws InvalidFieldException,
InvalidFieldValueException,
InvalidFieldAccessException
setValue in interface VRMLNodeTypeindex - 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
InvalidFieldException - The field index is not known
InvalidFieldValueException - 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
public void setValue(int index,
long value)
throws InvalidFieldException,
InvalidFieldValueException,
InvalidFieldAccessException
setValue in interface VRMLNodeTypeindex - The index of destination field to setvalue - The new value to use for the node
InvalidFieldException - The field index is not known
InvalidFieldValueException - 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
public void setValue(int index,
long[] value,
int numValid)
throws InvalidFieldException,
InvalidFieldValueException,
InvalidFieldAccessException
setValue in interface VRMLNodeTypeindex - 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
InvalidFieldException - The field index is not known
InvalidFieldValueException - 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
public void setValue(int index,
double value)
throws InvalidFieldException,
InvalidFieldValueException,
InvalidFieldAccessException
setValue in interface VRMLNodeTypeindex - The index of destination field to setvalue - The new value to use for the node
InvalidFieldException - The field index is not known
InvalidFieldValueException - 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
public void setValue(int index,
double[] value,
int numValid)
throws InvalidFieldException,
InvalidFieldValueException,
InvalidFieldAccessException
setValue in interface VRMLNodeTypeindex - 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
InvalidFieldException - The field index is not known
InvalidFieldValueException - 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
public void setValue(int index,
java.lang.String value)
throws InvalidFieldException,
InvalidFieldValueException,
InvalidFieldAccessException
setValue in interface VRMLNodeTypeindex - The index of destination field to setvalue - The new value to use for the node
InvalidFieldException - The field index is not known
InvalidFieldValueException - 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
public void setValue(int index,
java.lang.String[] value,
int numValid)
throws InvalidFieldException,
InvalidFieldValueException,
InvalidFieldAccessException
setValue in interface VRMLNodeTypeindex - 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
InvalidFieldException - The field index is not known
InvalidFieldValueException - 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
public void setValue(int index,
VRMLNodeType child)
throws InvalidFieldException,
InvalidFieldValueException,
InvalidFieldAccessException
setValue in interface VRMLNodeTypeindex - The index of destination field to setchild - The new value to use for the node
InvalidFieldException - The field index is not known
InvalidFieldValueException - 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
public void setValue(int index,
VRMLNodeType[] children,
int numValid)
throws InvalidFieldException,
InvalidFieldValueException,
InvalidFieldAccessException
setValue in interface VRMLNodeTypeindex - 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
InvalidFieldException - The field index is not known
InvalidFieldValueException - 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
public void notifyExternProtoLoaded(int index,
VRMLNodeType node)
throws InvalidFieldValueException
notifyExternProtoLoaded in interface VRMLNodeTypeindex - The field indexnode - The node resolved
InvalidFieldValueException - If the proto contains he wrong typeprotected void fireFieldChanged(int index)
index - The index of the field that changedprotected void checkNodeType(VRMLNodeType node)
node - The node to check
java.lang.IllegalArgumentException - The nodes are not the same
protected static void checkSecondaryType(VRMLNodeType instance,
int type,
java.lang.String msg)
instance - The proto instancetype - The type to check formsg - The error to message for the InvalidFieldValueException thrown
InvalidFieldValueException
protected static void checkSecondaryType(VRMLNodeType instance,
int[] type,
java.lang.String msg)
instance - The proto instancetype - The types to check formsg - The error to message for the InvalidFieldValueException thrown
InvalidFieldValueException
protected void updateRefs(VRMLNodeType node,
boolean add)
node - The child node of this group to send updates toadd - true if this is adding a new reference, false for delete
|
Xj3D 2.0 VRML/X3D Code API | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||