Class BaseImageTexture
java.lang.Object
org.web3d.vrml.renderer.common.nodes.AbstractNode
org.web3d.vrml.renderer.common.nodes.BaseTextureNode
org.web3d.vrml.renderer.common.nodes.BaseTexture2DNode
org.web3d.vrml.renderer.common.nodes.texture.BaseImageTexture
- All Implemented Interfaces:
VRMLNode
,FrameStateListener
,VRMLAppearanceChildNodeType
,VRMLExternalNodeType
,VRMLNodeType
,VRMLSingleExternalNodeType
,VRMLTexture2DNodeType
,VRMLTextureNodeType
- Direct Known Subclasses:
NRImageTexture
,OGLImageTexture
Common implementation of a ImageTexture node.
- Version:
- $Revision: 1.20 $
- Author:
- Alan Hudson, Justin Couch
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final int
Index of the autoRefresh fieldprotected static final int
Index of the autoRefreshTimeLimit fieldprotected static final int
Index of the load fieldprotected static final int
Field Indexprotected String
The URI of the finally loaded texture.protected int
URL Load Stateprotected double
SFBool autoRefreshprotected double
SFBool autoRefreshTimeLimitprotected boolean
SFBool loadprotected String[]
exposedField MFString url []Fields inherited from class org.web3d.vrml.renderer.common.nodes.BaseTexture2DNode
FIELD_DESCRIPTION, FIELD_REPEATS, FIELD_REPEATT, FIELD_TEXTURE_PROPERTIES, implImage, LAST_TEXTURENODETYPE_INDEX, pTextureProperties, TEXPROPS_VERSION_MSG, TEXTURE_PROPS_NODE_MSG, TEXTURE_PROPS_PROTO_MSG, vfDescription, vfRepeatS, vfRepeatT, vfTextureProperties
Fields inherited from class org.web3d.vrml.renderer.common.nodes.BaseTextureNode
listenerList
Fields 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
ConstructorsModifierConstructorDescriptionprotected
Default constructor builds the default node defined in the spec.protected
BaseImageTexture
(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
fireUrlChanged
(int index) Send a notification to the registered listeners that a field has been changed.double
Get the autoRefresh value to associate with the link.double
Get the autoRefreshTimeLimit value to associate with the link.getCacheString
(int stage) Get a string for caching this object.Get the description to associate with the link.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.boolean
getLoad()
Get the load value to associate with the link.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.int
Get the primary type of this node.int[]
Get the secondary type of this node.String[]
getUrl()
Get the list of URLs requested by this node.Get the world URL so set for this node.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
setAutoRefresh
(double newValue) Set the autoRefresh value for this link.void
setAutoRefreshTimeLimit
(double newValue) Set the autoRefreshTimeLimit value for this link.void
setContent
(String mimetype, Object content) Set the content of this node to the given object.void
setDescription
(String desc) Set the description string for this link.void
setLoad
(boolean newValue) Set the load value for this link.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
Sets the URL to a new value.void
setValue
(int index, boolean value) Set the value of the field at the given index as a boolean.void
setValue
(int index, double value) Set the value of the field at the given index as a double.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
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.BaseTexture2DNode
copy, getImage, getRepeatS, getRepeatT, getTextureProperties, getTextureType, setTextureProperties, setupFinished, setValue
Methods inherited from class org.web3d.vrml.renderer.common.nodes.BaseTextureNode
addTextureListener, fireTextureImageChanged, fireTextureParamsChanged, removeTextureListener
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, setErrorReporter, setFrameStateManager, setMetadataObject, setUserData, 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, setErrorReporter, 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, updateRefCount
Methods inherited from interface org.web3d.vrml.nodes.VRMLTextureNodeType
addTextureListener, removeTextureListener
-
Field Details
-
FIELD_URL
protected static final int FIELD_URLField Index- See Also:
-
FIELD_AUTOREFRESH
protected static final int FIELD_AUTOREFRESHIndex of the autoRefresh field- See Also:
-
FIELD_AUTOREFRESHTIMELIMIT
protected static final int FIELD_AUTOREFRESHTIMELIMITIndex of the autoRefreshTimeLimit field- See Also:
-
FIELD_LOAD
protected static final int FIELD_LOADIndex of the load field- See Also:
-
vfURL
exposedField MFString url [] -
vfAutoRefresh
protected double vfAutoRefreshSFBool autoRefresh -
vfAutoRefreshTimeLimit
protected double vfAutoRefreshTimeLimitSFBool autoRefreshTimeLimit -
vfLoad
protected boolean vfLoadSFBool load -
loadState
protected int loadStateURL Load State -
loadedURI
The URI of the finally loaded texture. Null if not loaded yet
-
-
Constructor Details
-
BaseImageTexture
protected BaseImageTexture()Default constructor builds the default node defined in the spec. -
BaseImageTexture
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
-
getAutoRefresh
public double getAutoRefresh()Get the autoRefresh value to associate with the link.- Returns:
- The current autoRefresh value
-
setAutoRefresh
public void setAutoRefresh(double newValue) Set the autoRefresh value for this link.- Parameters:
newValue
- The new autoRefresh value to set
-
getAutoRefreshTimeLimit
public double getAutoRefreshTimeLimit()Get the autoRefreshTimeLimit value to associate with the link.- Returns:
- The current TimeLimit value
-
setAutoRefreshTimeLimit
public void setAutoRefreshTimeLimit(double newValue) Set the autoRefreshTimeLimit value for this link.- Parameters:
newValue
- The new autoRefreshTimeLimit value to set
-
getLoad
public boolean getLoad()Get the load value to associate with the link.- Returns:
- The current TimeLimit value
-
setLoad
public void setLoad(boolean newValue) Set the load value for this link.- Parameters:
newValue
- The new load value to set
-
getCacheString
Get a string for caching this object. Null means do not cache this texture.- Specified by:
getCacheString
in interfaceVRMLTextureNodeType
- Overrides:
getCacheString
in classBaseTextureNode
- Parameters:
stage
- The stage number, 0 for all single stage textures.- Returns:
- A string to use in lookups. Typically the url loaded.
-
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
-
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.
-
setUrl
Sets the URL to a new value. We will load only one of these URL's. The list provides alternates.- Specified by:
setUrl
in interfaceVRMLSingleExternalNodeType
- Parameters:
newURL
- Array of candidate URL stringsnumValid
- The number of valid values to copy from the array
-
getUrl
Get the list of URLs requested by this node. If there are no URLs supplied in the text file then this will return a zero length array.- Specified by:
getUrl
in interfaceVRMLSingleExternalNodeType
- Returns:
- The list of URLs to attempt to load
-
getDescription
Get the description to associate with the link. This is a line of text suitable for mouseovers, status information etc. If there is no description set then it returns null.- Specified by:
getDescription
in interfaceVRMLTexture2DNodeType
- Overrides:
getDescription
in classBaseTexture2DNode
- Returns:
- The current description or null
-
setDescription
Set the description string for this link. Setting a value of null will clear the current description.- Parameters:
desc
- The new description to set
-
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
-
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
-
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
-
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
-
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.
-
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
-
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 classBaseTexture2DNode
- 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 classBaseTexture2DNode
- 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 a boolean.- Specified by:
setValue
in interfaceVRMLNodeType
- Overrides:
setValue
in classBaseTexture2DNode
- Parameters:
index
- The index of destination field to setvalue
- The new value to use for the node- Throws:
InvalidFieldException
- The field index is not know
-
setValue
Set the value of the field at the given index as a double.- 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 know
-
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
- Overrides:
setValue
in classBaseTexture2DNode
- 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 not in range or not appropriate for this field
-
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
- 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 knowInvalidFieldValueException
- The value provided is not in range or not appropriate for this field
-
fireUrlChanged
protected void fireUrlChanged(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
-
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.
-