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 intIndex of the Bounding box center bboxCenter fieldprotected static final intIndex of the Bounding box size bboxDisplay fieldprotected static final intIndex of the Bounding box size bboxSize fieldprotected static final intIndex of the Load fieldprotected static final intIndex of the url fieldprotected static final intIndex of the Bounding box size visible fieldprotected static final VRMLFieldDeclaration[]Array of VRMLFieldDeclarationsHashmap between a field name and its indexprotected static final intThe last field index used by this classprotected StringThe URI of the content that was actually loadedprotected intThe state of the loadprotected VRMLSceneScene containing the nested infoprotected booleanFlag to indicate if we've checked the URLs for relative referencesprotected float[]SFVec3f bboxCenter NULLprotected booleanSFBool bboxDisplay FALSEprotected float[]SFVec3f bboxSize NULLprotected booleanThe load fieldprotected String[]The URL listprotected booleanSFBool visible TRUEprotected StringThe 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, vrmlMinorVersionFields 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 TypeMethodDescriptionvoidAdd a listener to this node instance for the content state changes.voidAdd a listener to this node instance.booleancheckValidContentType(String mimetype) Check to see if the given MIME type is one that would be supported as content coming into this node.protected voidSend a notification to the registered listeners that the content state has been changed.protected voidSend a notification to the registered listeners that a field has been changed.float[]Get the current value of field the bboxCenter field.booleanGet 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.intgetFieldIndex(String fieldName) Get the index of the given field name.getFieldValue(int index) Get the value of a field.intAsk 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).intGet the number of fields.Get the parent execution space of this Inline.intGet 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.booleanGet the current value of the visible field.Get the world URL so set for this node.booleanisShared()Check to see if this node has been used more than once.voidRemove a listener from this node instance for the content state changes.voidRemove a listener from this node instance.voidsendRoute(double time, int srcIndex, VRMLNodeType destNode, int destIndex) Send a routed value from this node to the given destination node.voidsetBboxCenter(float[] newBboxCenter) Convenience method to set a new value the vfBboxCenter fieldsvoidsetBboxDisplay(boolean newBboxDisplay) Convenience method to set a new value for the vfBoxDisplay field.voidsetBboxSize(float[] newBboxSize) Convenience method to set a new value for the vfBboxSize field.voidsetContent(String mimetype, Object content) Set the content of this node to the given object.voidsetErrorReporter(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.voidsetImportNodes(Map<String, VRMLNode> imports) Set the mapping of import names to their proxy node implementations.protected voidsetLoad(boolean value) Convenience method to handle the load field value.voidsetLoadedURI(String URI) Notify the node which URL was used to load the content.voidsetLoadState(int state) Set the load state of the node.voidsetParentSpace(VRMLExecutionSpace space) Set the parent execution space of this Inline.voidsetShared(boolean used) Adjust the sharing count up or down one increment depending on the flag.voidNotification that the construction phase of this node has finished.voidSet the URL to a new value.voidsetValue(int index, boolean value) Set the value of the field at the given index as an array of strings.voidsetValue(int index, float[] value, int numValid) Set the value of the field at the given index as an array of floats.voidSet the value of the field at the given index as an array of strings.voidsetVisible(boolean val) Set visible field for this node.voidsetWorldUrl(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, updateRefsMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.web3d.vrml.nodes.FrameStateListener
allEventsCompleteMethods inherited from interface org.web3d.vrml.lang.VRMLNode
getUserData, getVRMLNodeName, isDEF, setUserData, setVersionMethods 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:VRMLBoundedNodeTypeGet the current value of field the bboxCenter field. The default value is0 0 0.- Specified by:
getBboxCenterin interfaceVRMLBoundedNodeType- Returns:
- The value of bboxCenter(SFVec3f)
-
getBboxSize
public float[] getBboxSize()Description copied from interface:VRMLBoundedNodeTypeGet the current value of the bboxSize field. The default value is-1 -1 -1.- Specified by:
getBboxSizein interfaceVRMLBoundedNodeType- Returns:
- The size of the bboxSize(SFVec3f)
-
getBboxDisplay
public boolean getBboxDisplay()Description copied from interface:VRMLBoundedNodeTypeGet the current value of the bboxDisplay field. The default value isfalse.- Specified by:
getBboxDisplayin interfaceVRMLBoundedNodeType- Returns:
- the value of the bboxDisplay(SFBool)
-
getVisible
public boolean getVisible()Description copied from interface:VRMLBoundedNodeTypeGet the current value of the visible field. The default value istrue.- Specified by:
getVisiblein 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:
getContainedScenein 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:
getParentSpacein 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:
setParentSpacein 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 theImportNodeProxyinstance that it represents.- Specified by:
setImportNodesin 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:
checkValidContentTypein 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:
getLoadStatein 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:
setLoadStatein 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:
setUrlin 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:
getUrlin 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:
setContentin 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:
setLoadedURIin 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:
setWorldUrlin interfaceVRMLExternalNodeType- Parameters:
url- The world URL.
-
getWorldUrl
Get the world URL so set for this node.- Specified by:
getWorldUrlin 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:
addUrlListenerin 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:
removeUrlListenerin 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:
addContentStateListenerin 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:
removeContentStateListenerin 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:
setupFinishedin interfaceVRMLNodeType- Overrides:
setupFinishedin 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:
setErrorReporterin interfaceVRMLNode- Overrides:
setErrorReporterin 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:
getFieldIndexin 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:
getNodeFieldIndicesin 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:
getFieldDeclarationin 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:
getNumFieldsin 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:
getPrimaryTypein 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:
getSecondaryTypein interfaceVRMLNode- Overrides:
getSecondaryTypein 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:
getFieldValuein interfaceVRMLNodeType- Overrides:
getFieldValuein 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:
sendRoutein interfaceVRMLNodeType- Overrides:
sendRoutein 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:
setValuein interfaceVRMLNodeType- Overrides:
setValuein 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:
setValuein interfaceVRMLNodeType- Overrides:
setValuein 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:
setValuein interfaceVRMLNodeType- Overrides:
setValuein 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:
setBboxCenterin 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:
setBboxSizein 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:
setBboxDisplayin 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:
setVisiblein interfaceVRMLBoundedNodeType- Parameters:
val- the display value to set
-
setLoad
Convenience method to handle the load field value. When value istruereplace the new URL with the old value by placing it immediately on the load queue. If the value isfalsethen 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.
-