Class BaseBackground
java.lang.Object
org.web3d.vrml.renderer.common.nodes.AbstractNode
org.web3d.vrml.renderer.common.nodes.BaseBindableNode
org.web3d.vrml.renderer.common.nodes.enveffects.BaseBackground
- All Implemented Interfaces:
VRMLNode
,FrameStateListener
,VRMLBackgroundNodeType
,VRMLBindableNodeType
,VRMLChildNodeType
,VRMLExternalNodeType
,VRMLMultiExternalNodeType
,VRMLNodeType
,VRMLTimeDependentNodeType
,VRMLWorldRootChildNodeType
- Direct Known Subclasses:
NRBackground
,OGLBackground
public abstract class BaseBackground
extends BaseBindableNode
implements VRMLBackgroundNodeType, VRMLMultiExternalNodeType
Common base implementation of a Background node.
- Version:
- $Revision: 1.22 $
- Author:
- Justin Couch
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final int
protected static final int
protected static final String[]
An empty list of URL fields for initializationprotected static final int
Index of the backUrl fieldprotected static final int
Index of the bottomUrl fieldprotected static final int
Index of the frontUrl fieldprotected static final int
Index of the groundAngle fieldprotected static final int
Index of the groundColor fieldprotected static final int
Index of the leftUrl fieldprotected static final int
Index of the rightUrl fieldprotected static final int
Index of the skyAngle fieldprotected static final int
Index of the skyColor fieldprotected static final int
Index of the topUrl fieldprotected static final int
Index of the topUrl fieldprotected static final int
protected static final int
protected boolean
Flag indicating a spec version thresholdprotected static final int
The last field index used by this classprotected static final int
protected String[]
List of loaded URI stringsprotected int[]
The state of the load for the various fieldsprotected static final int
protected static final int
The number of fields implementedprotected int
Number of valid values in vfGroundAngleprotected int
Number of valid values in vfGroundColorprotected int
Number of valid values in vfSkyAngleprotected int
Number of valid values in vfSkyColorprotected static final int
protected static final int
protected static final int
protected static final int[]
The array of fields that need URL contentprotected boolean
Flag to indicate if we've checked the URLs for relative referencesprotected String[]
MFString backUrl listprotected String[]
MFString bottomUrl listprotected String[]
MFString frontUrl listprotected float[]
MFFloat groundAngleprotected float[]
MFColor groundColorprotected String[]
MFString leftUrl listprotected String[]
MFString rightUrl listprotected float[]
MFFloat skyAngleprotected float[]
MFColor skyColorprotected String[]
MFString topUrl listprotected float
SFFloat transparencyprotected String
The world URL for correcting relative URL valuesFields inherited from class org.web3d.vrml.renderer.common.nodes.BaseBindableNode
FIELD_BIND, FIELD_BIND_TIME, FIELD_IS_BOUND, isOnStack, LAST_BINDABLE_INDEX, vfBindTime, vfIsBound
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
Create a new, default instance of this class.protected
BaseBackground
(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 for URL changes.boolean
checkValidContentType
(int index, String mimetype) Check to see if the given MIME type is one that would be supported as content coming into this node at the given field index.protected void
fireContentStateChanged
(int index) 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.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.void
getGroundValues
(float[] color, float[] angle) Fetch the color and angles for the ground values.int
getLoadState
(int index) Ask the state of the load of this node.int[]
Get the list of indices that correspond to fields that contain nodes i.e. MFNode and SFNode).int
Get the number of fields defined for this node.int
Get the number of valid ground color values that are currently defined.int
Get the number of valid sky color values that are currently defined.Class[]
getPreferredClassTypes
(int index) Get the list of preferred content class types in order of preference.int
Get the primary type of this node.int[]
Get the secondary type of this node.void
getSkyValues
(float[] color, float[] angle) Fetch the color and angles for the sky values.float
Get the transparency of the background.String[]
getUrl
(int index) Get the list of URLs for the given field index requested by this node.int[]
Get the list of field index values that require external content.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 for URL changes.void
sendRoute
(double time, int srcIndex, VRMLNodeType destNode, int destIndex) Send a routed value from this node to the given destination node.void
setLoadedURI
(int fieldIdx, String uri) Notify the node which URL was used to load the content.void
setLoadState
(int index, int state) Set the load state of the node.void
setTransparency
(float val) Set the transparency of the background.void
Notification that the construction phase of this node has finished.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
Set the value of the field at the given index as an array of strings.void
setVersion
(int major, int minor, boolean isStatic) Set the version of VRML that this node should represent.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.BaseBindableNode
addBindableNodeListener, copy, fireIsBoundChanged, getBindTime, getIsBound, removeBindableNodeListener, setBind, setOnStack, setValue, setVRMLClock
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, setValue, 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.nodes.VRMLBindableNodeType
addBindableNodeListener, getBindTime, getIsBound, removeBindableNodeListener, setBind, setOnStack
Methods inherited from interface org.web3d.vrml.nodes.VRMLMultiExternalNodeType
setContent
Methods inherited from interface org.web3d.vrml.lang.VRMLNode
getUserData, getVRMLNodeName, isDEF, setErrorReporter, setUserData
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_GROUND_ANGLE
protected static final int FIELD_GROUND_ANGLEIndex of the groundAngle field- See Also:
-
FIELD_GROUND_COLOR
protected static final int FIELD_GROUND_COLORIndex of the groundColor field- See Also:
-
FIELD_SKY_ANGLE
protected static final int FIELD_SKY_ANGLEIndex of the skyAngle field- See Also:
-
FIELD_SKY_COLOR
protected static final int FIELD_SKY_COLORIndex of the skyColor field- See Also:
-
FIELD_BACK_URL
protected static final int FIELD_BACK_URLIndex of the backUrl field- See Also:
-
FIELD_FRONT_URL
protected static final int FIELD_FRONT_URLIndex of the frontUrl field- See Also:
-
FIELD_LEFT_URL
protected static final int FIELD_LEFT_URLIndex of the leftUrl field- See Also:
-
FIELD_RIGHT_URL
protected static final int FIELD_RIGHT_URLIndex of the rightUrl field- See Also:
-
FIELD_BOTTOM_URL
protected static final int FIELD_BOTTOM_URLIndex of the bottomUrl field- See Also:
-
FIELD_TOP_URL
protected static final int FIELD_TOP_URLIndex of the topUrl field- See Also:
-
FIELD_TRANSPARENCY
protected static final int FIELD_TRANSPARENCYIndex of the topUrl field- See Also:
-
LAST_BACKGROUND_INDEX
protected static final int LAST_BACKGROUND_INDEXThe last field index used by this class- See Also:
-
NUM_FIELDS
protected static final int NUM_FIELDSThe number of fields implemented- See Also:
-
EMPTY_LIST
An empty list of URL fields for initialization -
BACK
protected static final int BACK- See Also:
-
FRONT
protected static final int FRONT- See Also:
-
LEFT
protected static final int LEFT- See Also:
-
RIGHT
protected static final int RIGHT- See Also:
-
TOP
protected static final int TOP- See Also:
-
BOTTOM
protected static final int BOTTOM- See Also:
-
SKY_SPHERE
protected static final int SKY_SPHERE- See Also:
-
GROUND_SPHERE
protected static final int GROUND_SPHERE- See Also:
-
NUM_BG_OBJECTS
protected static final int NUM_BG_OBJECTS- See Also:
-
urlFieldIndexList
protected static final int[] urlFieldIndexListThe array of fields that need URL content -
worldURL
The world URL for correcting relative URL values -
urlRelativeCheck
protected boolean urlRelativeCheckFlag to indicate if we've checked the URLs for relative references -
loadState
protected int[] loadStateThe state of the load for the various fields -
loadedUri
List of loaded URI strings -
vfBackUrl
MFString backUrl list -
vfFrontUrl
MFString frontUrl list -
vfLeftUrl
MFString leftUrl list -
vfRightUrl
MFString rightUrl list -
vfTopUrl
MFString topUrl list -
vfBottomUrl
MFString bottomUrl list -
vfGroundAngle
protected float[] vfGroundAngleMFFloat groundAngle -
vfGroundColor
protected float[] vfGroundColorMFColor groundColor -
vfSkyAngle
protected float[] vfSkyAngleMFFloat skyAngle -
vfSkyColor
protected float[] vfSkyColorMFColor skyColor -
vfTransparency
protected float vfTransparencySFFloat transparency -
numGroundAngle
protected int numGroundAngleNumber of valid values in vfGroundAngle -
numGroundColor
protected int numGroundColorNumber of valid values in vfGroundColor -
numSkyAngle
protected int numSkyAngleNumber of valid values in vfSkyAngle -
numSkyColor
protected int numSkyColorNumber of valid values in vfSkyColor -
isVersionPost_3_2
protected boolean isVersionPost_3_2Flag indicating a spec version threshold
-
-
Constructor Details
-
BaseBackground
protected BaseBackground()Create a new, default instance of this class. -
BaseBackground
Construct a new instance of this node based on the details from the given node.- Parameters:
node
- The node to copy- Throws:
IllegalArgumentException
- The node is not the right type.
-
-
Method Details
-
getTransparency
public float getTransparency()Description copied from interface:VRMLBackgroundNodeType
Get the transparency of the background.- Specified by:
getTransparency
in interfaceVRMLBackgroundNodeType
- Returns:
- the transparency of the background
-
setTransparency
public void setTransparency(float val) Description copied from interface:VRMLBackgroundNodeType
Set the transparency of the background.- Specified by:
setTransparency
in interfaceVRMLBackgroundNodeType
- Parameters:
val
- The transparency value
-
getNumSkyColors
public int getNumSkyColors()Description copied from interface:VRMLBackgroundNodeType
Get the number of valid sky color values that are currently defined.- Specified by:
getNumSkyColors
in interfaceVRMLBackgroundNodeType
- Returns:
- The number of values
-
getNumGroundColors
public int getNumGroundColors()Description copied from interface:VRMLBackgroundNodeType
Get the number of valid ground color values that are currently defined.- Specified by:
getNumGroundColors
in interfaceVRMLBackgroundNodeType
- Returns:
- The number of values
-
getSkyValues
public void getSkyValues(float[] color, float[] angle) Description copied from interface:VRMLBackgroundNodeType
Fetch the color and angles for the sky values.- Specified by:
getSkyValues
in interfaceVRMLBackgroundNodeType
- Parameters:
color
- The array to return the color values inangle
- The array to return the angle values in
-
getGroundValues
public void getGroundValues(float[] color, float[] angle) Description copied from interface:VRMLBackgroundNodeType
Fetch the color and angles for the ground values.- Specified by:
getGroundValues
in interfaceVRMLBackgroundNodeType
- Parameters:
color
- The array to return the color values inangle
- The array to return the angle values in
-
getUrlFieldIndexes
public int[] getUrlFieldIndexes()Description copied from interface:VRMLMultiExternalNodeType
Get the list of field index values that require external content. These will be used to query for the URL values later. The field must be non-null and non-zero in length.- Specified by:
getUrlFieldIndexes
in interfaceVRMLMultiExternalNodeType
- Returns:
- A list of field indexes requiring textures
-
getUrl
Description copied from interface:VRMLMultiExternalNodeType
Get the list of URLs for the given field index 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 interfaceVRMLMultiExternalNodeType
- Parameters:
index
- The field index we want URL values for- Returns:
- The list of URLs to attempt to load
- Throws:
InvalidFieldException
- The field index is not valid for the query
-
getLoadState
public int getLoadState(int index) Description copied from interface:VRMLMultiExternalNodeType
Ask the state of the load of this node. The value will be one of the constants defined above.- Specified by:
getLoadState
in interfaceVRMLMultiExternalNodeType
- Parameters:
index
- The field index we want to set the state for- Returns:
- The current load state of the node
-
setLoadState
public void setLoadState(int index, int state) Description copied from interface:VRMLMultiExternalNodeType
Set the load state of the node. The value must be one of the constants defined above.- Specified by:
setLoadState
in interfaceVRMLMultiExternalNodeType
- Parameters:
index
- The field index we want to set the state for.state
- The new state of the node
-
checkValidContentType
Description copied from interface:VRMLMultiExternalNodeType
Check to see if the given MIME type is one that would be supported as content coming into this node at the given field index.- Specified by:
checkValidContentType
in interfaceVRMLMultiExternalNodeType
- Parameters:
index
- The field index we want to check content type for.mimetype
- The type to check for- Returns:
- true if this is OK, false if not
-
getPreferredClassTypes
Description copied from interface:VRMLMultiExternalNodeType
Get the list of preferred content class types in order of preference. This allows the code to ask for data in an order of preference. For example, for images it might want a BufferedImage preference to an Image. This is passed to the URI loading code. If there is no preference this may return a null list.- Specified by:
getPreferredClassTypes
in interfaceVRMLMultiExternalNodeType
- Parameters:
index
- The field index for the preferred types.- Returns:
- A list of preferred class types
- Throws:
InvalidFieldException
- The field index is not valid for the query
-
setLoadedURI
Description copied from interface:VRMLMultiExternalNodeType
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 interfaceVRMLMultiExternalNodeType
- Parameters:
fieldIdx
- The field index that was loadeduri
- The URI used to load this content
-
addUrlListener
Description copied from interface:VRMLExternalNodeType
Add a listener to this node instance for URL changes. 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
Description copied from interface:VRMLExternalNodeType
Remove a listener from this node instance for URL changes. 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
Description copied from interface:VRMLExternalNodeType
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
Description copied from interface:VRMLExternalNodeType
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
-
setWorldUrl
Description copied from interface:VRMLExternalNodeType
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
Description copied from interface:VRMLExternalNodeType
Get the world URL so set for this node.- Specified by:
getWorldUrl
in interfaceVRMLExternalNodeType
- Returns:
- url The world URL.
-
setVersion
public void setVersion(int major, int minor, boolean isStatic) Description copied from interface:VRMLNode
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
- Overrides:
setVersion
in classAbstractNode
- 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
-
setupFinished
public void setupFinished()Description copied from interface:VRMLNodeType
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. It is then responsible for calling its children's setupFinished.- Specified by:
setupFinished
in interfaceVRMLNodeType
- Overrides:
setupFinished
in classAbstractNode
-
getFieldIndex
Description copied from interface:VRMLNode
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()Description copied from interface:VRMLNode
Get the list of indices that correspond to fields that contain nodes i.e. 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
Description copied from interface:VRMLNode
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()Description copied from interface:VRMLNode
Get the number of fields defined for this node.- Specified by:
getNumFields
in interfaceVRMLNode
- Returns:
- The number of fields.
-
getPrimaryType
public int getPrimaryType()Description copied from interface:VRMLNode
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()Description copied from class:BaseBindableNode
Get the secondary type of this node. Replaces the instanceof mechanism for use in switch statements.- Specified by:
getSecondaryType
in interfaceVRMLNode
- Overrides:
getSecondaryType
in classBaseBindableNode
- Returns:
- The secondary type
-
getFieldValue
Description copied from class:BaseBindableNode
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 classBaseBindableNode
- 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
Description copied from class:BaseBindableNode
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 classBaseBindableNode
- 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) throws InvalidFieldException, InvalidFieldValueException Description copied from interface:VRMLNodeType
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
- 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
-
setValue
public void setValue(int index, float[] value, int numValid) throws InvalidFieldException, InvalidFieldValueException Description copied from interface:VRMLNodeType
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 not in range or not appropriate for this field
-
setValue
public void setValue(int index, String[] value, int numValid) throws InvalidFieldException, InvalidFieldValueException Description copied from interface:VRMLNodeType
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 knownInvalidFieldValueException
- 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(int index) 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.- Parameters:
index
- The index of the field that changed
-