Class BaseInline
java.lang.Object
org.web3d.vrml.renderer.common.nodes.AbstractNode
org.web3d.vrml.renderer.common.nodes.networking.BaseInline
- All Implemented Interfaces:
VRMLExecutionSpace
,VRMLNode
,FrameStateListener
,VRMLBoundedNodeType
,VRMLChildNodeType
,VRMLExternalNodeType
,VRMLInlineNodeType
,VRMLNodeType
,VRMLSingleExternalNodeType
,VRMLWorldRootChildNodeType
A node that can handle inlined content from other VRML worlds.
This implementation does not care whether the source world came from a UTF8 or XML encoded file.
While the node is awaiting content to be downloaded, it will put a wireframe box around the suggested bounds of the content. If no bounds are set then a 1x1x1 box is placed at the local origin. If the URL given is null, then the outline box will not be shown.
TODO:
- Implement a scheme to allow the updating of the contents at runtime when
the URL changes. It currently removes the old content, but does not
inform any ContentLoadManager to fetch it's new values.
- Load is ignored
- Version:
- $Revision: 1.23 $
- Author:
- Justin Couch
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final int
Index of the Bounding box center bboxCenter fieldprotected static final int
Index of the Bounding box size bboxDisplay fieldprotected static final int
Index of the Bounding box size bboxSize fieldprotected static final int
Index of the Load fieldprotected static final int
Index of the url fieldprotected static final int
Index of the Bounding box size visible fieldprotected static final VRMLFieldDeclaration[]
Array of VRMLFieldDeclarationsHashmap between a field name and its indexprotected static final int
The last field index used by this classprotected String
The URI of the content that was actually loadedprotected int
The state of the loadprotected VRMLScene
Scene containing the nested infoprotected boolean
Flag to indicate if we've checked the URLs for relative referencesprotected float[]
SFVec3f bboxCenter NULLprotected boolean
SFBool bboxDisplay FALSEprotected float[]
SFVec3f bboxSize NULLprotected boolean
The load fieldprotected String[]
The URL listprotected boolean
SFBool visible TRUEprotected String
The world URL for correcting relative URL valuesFields inherited from class org.web3d.vrml.renderer.common.nodes.AbstractNode
errorReporter, FIELD_METADATA, fieldLocalData, hasChanged, inSetup, isDEF, isStatic, LAST_NODE_INDEX, layerIds, nodeName, pMetadata, refCounts, removedLayerIds, stateManager, STATIC_SCENE_GRAPH, vfMetadata, vrmlMajorVersion, vrmlMinorVersion
Fields inherited from interface org.web3d.vrml.nodes.VRMLExternalNodeType
LOAD_COMPLETE, LOAD_FAILED, LOADING, NOT_LOADED
-
Constructor Summary
ConstructorsConstructorDescriptionCreate a new, default instance of this class.BaseInline
(VRMLNodeType node) Construct a new instance of this node based on the details from the given node. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Add a listener to this node instance for the content state changes.void
Add a listener to this node instance.boolean
checkValidContentType
(String mimetype) Check to see if the given MIME type is one that would be supported as content coming into this node.protected void
Send a notification to the registered listeners that the content state has been changed.protected void
Send a notification to the registered listeners that a field has been changed.float[]
Get the current value of field the bboxCenter field.boolean
Get the current value of the bboxDisplay field.float[]
Get the current value of the bboxSize field.Get the contained scene graph that this instance has.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.int
Ask the state of the load of this node.int[]
Get the list of indices that correspond to fields that contain nodes ie MFNode and SFNode).int
Get the number of fields.Get the parent execution space of this Inline.int
Get the primary type of this node.int[]
Get the secondary type of this node.String[]
getUrl()
Get the list of URI's currently registered with this node.boolean
Get the current value of the visible field.Get the world URL so set for this node.boolean
isShared()
Check to see if this node has been used more than once.void
Remove a listener from this node instance for the content state changes.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
setBboxCenter
(float[] newBboxCenter) Convenience method to set a new value the vfBboxCenter fieldsvoid
setBboxDisplay
(boolean newBboxDisplay) Convenience method to set a new value for the vfBoxDisplay field.void
setBboxSize
(float[] newBboxSize) Convenience method to set a new value for the vfBboxSize field.void
setContent
(String mimetype, Object content) Set the content of this node to the given object.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
setImportNodes
(Map<String, VRMLNode> imports) Set the mapping of import names to their proxy node implementations.protected void
setLoad
(boolean value) Convenience method to handle the load field value.void
setLoadedURI
(String URI) Notify the node which URL was used to load the content.void
setLoadState
(int state) Set the load state of the node.void
setParentSpace
(VRMLExecutionSpace space) Set the parent execution space of this Inline.void
setShared
(boolean used) Adjust the sharing count up or down one increment depending on the flag.void
Notification that the construction phase of this node has finished.void
Set the URL to a new value.void
setValue
(int index, boolean value) Set the value of the field at the given index as an array of strings.void
setValue
(int index, float[] value, int numValid) Set the value of the field at the given index as an array of floats.void
Set the value of the field at the given index as an array of strings.void
setVisible
(boolean val) Set visible field for this node.void
setWorldUrl
(String url) Set the world URL so that any relative URLs may be corrected to the fully qualified version.Methods inherited from class org.web3d.vrml.renderer.common.nodes.AbstractNode
addNodeListener, allEventsComplete, checkNodeType, checkSecondaryType, checkSecondaryType, clearRemovedLayerIds, fireFieldChanged, getLayerIds, getMetadataObject, getRefCount, getRemovedLayerIds, getUserData, getVRMLNodeName, hasFieldChanged, isDEF, isSetupFinished, notifyExternProtoLoaded, removeNodeListener, setDEF, setFrameStateManager, setMetadataObject, setUserData, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setVersion, throwInitOnlyWriteException, throwInputOnlyWriteException, throwInvalidNodeException, throwInvalidProtoException, throwOutputOnlyWriteException, updateRefCount, updateRefs
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.nodes.FrameStateListener
allEventsComplete
Methods inherited from interface org.web3d.vrml.lang.VRMLNode
getUserData, getVRMLNodeName, isDEF, setUserData, setVersion
Methods inherited from interface org.web3d.vrml.nodes.VRMLNodeType
addNodeListener, clearRemovedLayerIds, getLayerIds, getMetadataObject, getRefCount, getRemovedLayerIds, hasFieldChanged, isSetupFinished, notifyExternProtoLoaded, removeNodeListener, setDEF, setFrameStateManager, setMetadataObject, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, updateRefCount
-
Field Details
-
FIELD_URL
protected static final int FIELD_URLIndex of the url field- See Also:
-
FIELD_BBOX_CENTER
protected static final int FIELD_BBOX_CENTERIndex of the Bounding box center bboxCenter field- See Also:
-
FIELD_BBOX_SIZE
protected static final int FIELD_BBOX_SIZEIndex of the Bounding box size bboxSize field- See Also:
-
FIELD_BBOX_DISPLAY
protected static final int FIELD_BBOX_DISPLAYIndex of the Bounding box size bboxDisplay field- See Also:
-
FIELD_VISIBLE
protected static final int FIELD_VISIBLEIndex of the Bounding box size visible field- See Also:
-
FIELD_LOAD
protected static final int FIELD_LOADIndex of the Load field- See Also:
-
LAST_INLINE_INDEX
protected static final int LAST_INLINE_INDEXThe last field index used by this class- See Also:
-
fieldDecl
Array of VRMLFieldDeclarations -
fieldMap
-
vfBboxCenter
protected float[] vfBboxCenterSFVec3f bboxCenter NULL -
vfBboxSize
protected float[] vfBboxSizeSFVec3f bboxSize NULL -
vfBboxDisplay
protected boolean vfBboxDisplaySFBool bboxDisplay FALSE -
vfVisible
protected boolean vfVisibleSFBool visible TRUE -
vfUrl
The URL list -
vfLoad
protected boolean vfLoadThe load field -
worldURL
The world URL for correcting relative URL values -
loadedURI
The URI of the content that was actually loaded -
urlRelativeCheck
protected boolean urlRelativeCheckFlag to indicate if we've checked the URLs for relative references -
loadState
protected int loadStateThe state of the load -
scene
Scene containing the nested info
-
-
Constructor Details
-
BaseInline
public BaseInline()Create a new, default instance of this class. -
BaseInline
Construct a new instance of this node based on the details from the given node. If the node is not the same type, an exception will be thrown.- Parameters:
node
- The node to copy- Throws:
IllegalArgumentException
- Incorrect Node Type
-
-
Method Details
-
getBboxCenter
public float[] getBboxCenter()Description copied from interface:VRMLBoundedNodeType
Get the current value of field the bboxCenter field. The default value is0 0 0
.- Specified by:
getBboxCenter
in interfaceVRMLBoundedNodeType
- Returns:
- The value of bboxCenter(SFVec3f)
-
getBboxSize
public float[] getBboxSize()Description copied from interface:VRMLBoundedNodeType
Get the current value of the bboxSize field. The default value is-1 -1 -1
.- Specified by:
getBboxSize
in interfaceVRMLBoundedNodeType
- Returns:
- The size of the bboxSize(SFVec3f)
-
getBboxDisplay
public boolean getBboxDisplay()Description copied from interface:VRMLBoundedNodeType
Get the current value of the bboxDisplay field. The default value isfalse
.- Specified by:
getBboxDisplay
in interfaceVRMLBoundedNodeType
- Returns:
- the value of the bboxDisplay(SFBool)
-
getVisible
public boolean getVisible()Description copied from interface:VRMLBoundedNodeType
Get the current value of the visible field. The default value istrue
.- Specified by:
getVisible
in interfaceVRMLBoundedNodeType
- Returns:
- the value of the visible(SFBool)
-
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
-
getParentSpace
Get the parent execution space of this Inline. This is for internal usage, you cannot use this to walk back up the scene graph because of protos.- Specified by:
getParentSpace
in interfaceVRMLInlineNodeType
- Returns:
- The execution space of the loaded inline
-
setParentSpace
Set the parent execution space of this Inline. This is for internal usage, you cannot use this to walk back up the scene graph because of protos.- Specified by:
setParentSpace
in interfaceVRMLInlineNodeType
- Parameters:
space
- The parent space or null for the world root space
-
setImportNodes
Set the mapping of import names to their proxy node implementations. The mapping is from the exported name to theImportNodeProxy
instance that it represents.- Specified by:
setImportNodes
in interfaceVRMLInlineNodeType
- Parameters:
imports
- The map of export names to proxy instances
-
checkValidContentType
Check to see if the given MIME type is one that would be supported as content coming into this node.- Specified by:
checkValidContentType
in interfaceVRMLSingleExternalNodeType
- Parameters:
mimetype
- The type to check for- Returns:
- true if this is OK, false if not
-
getLoadState
public int getLoadState()Ask the state of the load of this node. The value will be one of the constants defined above.- Specified by:
getLoadState
in interfaceVRMLSingleExternalNodeType
- Returns:
- The current load state of the node
-
setLoadState
public void setLoadState(int state) Set the load state of the node. The value must be one of the constants defined above.- Specified by:
setLoadState
in interfaceVRMLSingleExternalNodeType
- Parameters:
state
- The new state of the node
-
setUrl
Set the URL to a new value. If the value is null, it removes the old contents (if set) and treats it as though there is no content.- Specified by:
setUrl
in interfaceVRMLSingleExternalNodeType
- Parameters:
newUrl
- The list of urls to set or nullnumValid
- The number of valid values to copy from the array
-
getUrl
Get the list of URI's currently registered with this node.- Specified by:
getUrl
in interfaceVRMLSingleExternalNodeType
- Returns:
- The list of URLs to attempt to load
-
setContent
Set the content of this node to the given object. The object is then cast by the internal representation to the form it needs. This assumes at least some amount of intelligence on the part of the caller, but we also know that we should not pass something dumb to it when we can check what sort of content types it likes to handle. We assume the loader thread is operating in the same context as the one that created the node in the first place and thus knows the general types of items to pass through.- Specified by:
setContent
in interfaceVRMLSingleExternalNodeType
- Parameters:
mimetype
- The mime type of this object if knowncontent
- The content of the object- Throws:
IllegalArgumentException
- The content object is not supported
-
setLoadedURI
Notify the node which URL was used to load the content. It will be the complete URI with path, query and references parts. This method will be called before setContent.- Specified by:
setLoadedURI
in interfaceVRMLSingleExternalNodeType
- Parameters:
URI
- The URI used to load this content
-
setWorldUrl
Set the world URL so that any relative URLs may be corrected to the fully qualified version. Guaranteed to be non-null.- Specified by:
setWorldUrl
in interfaceVRMLExternalNodeType
- Parameters:
url
- The world URL.
-
getWorldUrl
Get the world URL so set for this node.- Specified by:
getWorldUrl
in interfaceVRMLExternalNodeType
- Returns:
- url The world URL.
-
addUrlListener
Add a listener to this node instance. If the listener is already added or null the request is silently ignored.- Specified by:
addUrlListener
in interfaceVRMLExternalNodeType
- Parameters:
ul
- The listener instance to add
-
removeUrlListener
Remove a listener from this node instance. If the listener is null or not registered, the request is silently ignored.- Specified by:
removeUrlListener
in interfaceVRMLExternalNodeType
- Parameters:
ul
- The listener to be removed
-
addContentStateListener
Add a listener to this node instance for the content state changes. If the listener is already added or null the request is silently ignored.- Specified by:
addContentStateListener
in interfaceVRMLExternalNodeType
- Parameters:
l
- The listener instance to add
-
removeContentStateListener
Remove a listener from this node instance for the content state changes. If the listener is null or not registered, the request is silently ignored.- Specified by:
removeContentStateListener
in interfaceVRMLExternalNodeType
- Parameters:
l
- The listener to be removed
-
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
- Overrides:
setupFinished
in classAbstractNode
-
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
- Overrides:
setErrorReporter
in classAbstractNode
- Parameters:
reporter
- The instance to use or null
-
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.- Specified by:
getNumFields
in interfaceVRMLNode
- Returns:
- The number of fields.
-
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.- Specified by:
getSecondaryType
in interfaceVRMLNode
- Overrides:
getSecondaryType
in classAbstractNode
- Returns:
- The secondary type
-
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
- Overrides:
getFieldValue
in classAbstractNode
- Parameters:
index
- The index of the field to change.- Returns:
- The class representing the field value
- Throws:
InvalidFieldException
- The field index is not known
-
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
- Overrides:
sendRoute
in classAbstractNode
- 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
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
- Overrides:
setValue
in classAbstractNode
- 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.
-
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 type url.- Specified by:
setValue
in interfaceVRMLNodeType
- Overrides:
setValue
in classAbstractNode
- 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 not in range or not appropriate for this field
-
setValue
public void setValue(int index, boolean value) throws InvalidFieldException, InvalidFieldValueException Set the value of the field at the given index as an array of strings. This would be used to set the load field.- Specified by:
setValue
in interfaceVRMLNodeType
- Overrides:
setValue
in classAbstractNode
- 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 not in range or not appropriate for this field
-
setBboxCenter
Convenience method to set a new value the vfBboxCenter fields- Specified by:
setBboxCenter
in interfaceVRMLBoundedNodeType
- Parameters:
newBboxCenter
- The new center of the bounding box- Throws:
InvalidFieldAccessException
-
setBboxSize
Convenience method to set a new value for the vfBboxSize field.- Specified by:
setBboxSize
in interfaceVRMLBoundedNodeType
- Parameters:
newBboxSize
- The new size for the bounding box- Throws:
InvalidFieldAccessException
-
setBboxDisplay
public void setBboxDisplay(boolean newBboxDisplay) Convenience method to set a new value for the vfBoxDisplay field.- Specified by:
setBboxDisplay
in interfaceVRMLBoundedNodeType
- Parameters:
newBboxDisplay
- the new display for the bounding box
-
setVisible
public void setVisible(boolean val) Set visible field for this node. Only used by the field parser- Specified by:
setVisible
in interfaceVRMLBoundedNodeType
- Parameters:
val
- the display value to set
-
setLoad
Convenience method to handle the load field value. When value istrue
replace the new URL with the old value by placing it immediately on the load queue. If the value isfalse
then it should immediately remove the content. The derived classes should make sure they override this method and handle the content removal. The derived class should do all its work before calling this method.- Parameters:
value
- The new load field state- Throws:
InvalidFieldException
-
fireUrlChanged
protected void fireUrlChanged()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. -
fireContentStateChanged
protected void fireContentStateChanged()Send a notification to the registered listeners that the content state has been changed. If no listeners have been registered, then this does nothing, so always call it regardless.
-