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 intprotected static final intprotected static final String[]An empty list of URL fields for initializationprotected static final intIndex of the backUrl fieldprotected static final intIndex of the bottomUrl fieldprotected static final intIndex of the frontUrl fieldprotected static final intIndex of the groundAngle fieldprotected static final intIndex of the groundColor fieldprotected static final intIndex of the leftUrl fieldprotected static final intIndex of the rightUrl fieldprotected static final intIndex of the skyAngle fieldprotected static final intIndex of the skyColor fieldprotected static final intIndex of the topUrl fieldprotected static final intIndex of the topUrl fieldprotected static final intprotected static final intprotected booleanFlag indicating a spec version thresholdprotected static final intThe last field index used by this classprotected static final intprotected String[]List of loaded URI stringsprotected int[]The state of the load for the various fieldsprotected static final intprotected static final intThe number of fields implementedprotected intNumber of valid values in vfGroundAngleprotected intNumber of valid values in vfGroundColorprotected intNumber of valid values in vfSkyAngleprotected intNumber of valid values in vfSkyColorprotected static final intprotected static final intprotected static final intprotected static final int[]The array of fields that need URL contentprotected booleanFlag 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 floatSFFloat transparencyprotected StringThe 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, vfIsBoundFields 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
ConstructorsModifierConstructorDescriptionprotectedCreate a new, default instance of this class.protectedBaseBackground(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 for URL changes.booleancheckValidContentType(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 voidfireContentStateChanged(int index) Send a notification to the registered listeners that the content state has been changed.protected voidfireUrlChanged(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.intgetFieldIndex(String fieldName) Get the index of the given field name.getFieldValue(int index) Get the value of a field.voidgetGroundValues(float[] color, float[] angle) Fetch the color and angles for the ground values.intgetLoadState(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).intGet the number of fields defined for this node.intGet the number of valid ground color values that are currently defined.intGet 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.intGet the primary type of this node.int[]Get the secondary type of this node.voidgetSkyValues(float[] color, float[] angle) Fetch the color and angles for the sky values.floatGet 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.voidRemove a listener from this node instance for the content state changes.voidRemove a listener from this node instance for URL changes.voidsendRoute(double time, int srcIndex, VRMLNodeType destNode, int destIndex) Send a routed value from this node to the given destination node.voidsetLoadedURI(int fieldIdx, String uri) Notify the node which URL was used to load the content.voidsetLoadState(int index, int state) Set the load state of the node.voidsetTransparency(float val) Set the transparency of the background.voidNotification that the construction phase of this node has finished.voidsetValue(int index, float value) Set the value of the field at the given index as a float.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.voidsetVersion(int major, int minor, boolean isStatic) Set the version of VRML that this node should represent.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.BaseBindableNode
addBindableNodeListener, copy, fireIsBoundChanged, getBindTime, getIsBound, removeBindableNodeListener, setBind, setOnStack, setValue, setVRMLClockMethods 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, 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.nodes.VRMLBindableNodeType
addBindableNodeListener, getBindTime, getIsBound, removeBindableNodeListener, setBind, setOnStackMethods inherited from interface org.web3d.vrml.nodes.VRMLMultiExternalNodeType
setContentMethods inherited from interface org.web3d.vrml.lang.VRMLNode
getUserData, getVRMLNodeName, isDEF, setErrorReporter, setUserDataMethods 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:VRMLBackgroundNodeTypeGet the transparency of the background.- Specified by:
getTransparencyin interfaceVRMLBackgroundNodeType- Returns:
- the transparency of the background
-
setTransparency
public void setTransparency(float val) Description copied from interface:VRMLBackgroundNodeTypeSet the transparency of the background.- Specified by:
setTransparencyin interfaceVRMLBackgroundNodeType- Parameters:
val- The transparency value
-
getNumSkyColors
public int getNumSkyColors()Description copied from interface:VRMLBackgroundNodeTypeGet the number of valid sky color values that are currently defined.- Specified by:
getNumSkyColorsin interfaceVRMLBackgroundNodeType- Returns:
- The number of values
-
getNumGroundColors
public int getNumGroundColors()Description copied from interface:VRMLBackgroundNodeTypeGet the number of valid ground color values that are currently defined.- Specified by:
getNumGroundColorsin interfaceVRMLBackgroundNodeType- Returns:
- The number of values
-
getSkyValues
public void getSkyValues(float[] color, float[] angle) Description copied from interface:VRMLBackgroundNodeTypeFetch the color and angles for the sky values.- Specified by:
getSkyValuesin 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:VRMLBackgroundNodeTypeFetch the color and angles for the ground values.- Specified by:
getGroundValuesin 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:VRMLMultiExternalNodeTypeGet 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:
getUrlFieldIndexesin interfaceVRMLMultiExternalNodeType- Returns:
- A list of field indexes requiring textures
-
getUrl
Description copied from interface:VRMLMultiExternalNodeTypeGet 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:
getUrlin 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:VRMLMultiExternalNodeTypeAsk the state of the load of this node. The value will be one of the constants defined above.- Specified by:
getLoadStatein 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:VRMLMultiExternalNodeTypeSet the load state of the node. The value must be one of the constants defined above.- Specified by:
setLoadStatein 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:VRMLMultiExternalNodeTypeCheck 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:
checkValidContentTypein 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:VRMLMultiExternalNodeTypeGet 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:
getPreferredClassTypesin 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:VRMLMultiExternalNodeTypeNotify 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 interfaceVRMLMultiExternalNodeType- Parameters:
fieldIdx- The field index that was loadeduri- The URI used to load this content
-
addUrlListener
Description copied from interface:VRMLExternalNodeTypeAdd a listener to this node instance for URL changes. 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
Description copied from interface:VRMLExternalNodeTypeRemove a listener from this node instance for URL changes. 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
Description copied from interface:VRMLExternalNodeTypeAdd 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
Description copied from interface:VRMLExternalNodeTypeRemove 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
-
setWorldUrl
Description copied from interface:VRMLExternalNodeTypeSet 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
Description copied from interface:VRMLExternalNodeTypeGet the world URL so set for this node.- Specified by:
getWorldUrlin interfaceVRMLExternalNodeType- Returns:
- url The world URL.
-
setVersion
public void setVersion(int major, int minor, boolean isStatic) Description copied from interface:VRMLNodeSet the version of VRML that this node should represent. Different versions have different capabilities, even within the same node.- Specified by:
setVersionin interfaceVRMLNode- Overrides:
setVersionin 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:VRMLNodeTypeNotification 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:
setupFinishedin interfaceVRMLNodeType- Overrides:
setupFinishedin classAbstractNode
-
getFieldIndex
Description copied from interface:VRMLNodeGet 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()Description copied from interface:VRMLNodeGet 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:
getNodeFieldIndicesin interfaceVRMLNode- Returns:
- The list of field indices that correspond to SF/MFnode fields or null if none
-
getFieldDeclaration
Description copied from interface:VRMLNodeGet 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()Description copied from interface:VRMLNodeGet the number of fields defined for this node.- Specified by:
getNumFieldsin interfaceVRMLNode- Returns:
- The number of fields.
-
getPrimaryType
public int getPrimaryType()Description copied from interface:VRMLNodeGet 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()Description copied from class:BaseBindableNodeGet the secondary type of this node. Replaces the instanceof mechanism for use in switch statements.- Specified by:
getSecondaryTypein interfaceVRMLNode- Overrides:
getSecondaryTypein classBaseBindableNode- Returns:
- The secondary type
-
getFieldValue
Description copied from class:BaseBindableNodeGet 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 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:BaseBindableNodeSend 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 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:VRMLNodeTypeSet the value of the field at the given index as a float. This would be used to set SFFloat 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 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:VRMLNodeTypeSet 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 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:VRMLNodeTypeSet 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:
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
-
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
-