Class BaseSurfaceChildNode
java.lang.Object
org.web3d.vrml.renderer.common.nodes.AbstractNode
org.web3d.vrml.renderer.common.nodes.layout.BaseSurfaceChildNode
- All Implemented Interfaces:
VRMLNode
,FrameStateListener
,VRMLNodeType
,VRMLSurfaceChildNodeType
- Direct Known Subclasses:
BaseImage2D
,BaseSurfaceLayoutNode
,BaseText2D
Base implementation of any surface child node.
All surface child nodes start with an automatically sized bounding box and are visible.
- Version:
- $Revision: 1.2 $
- Author:
- Justin Couch
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final int
The field index for bboxSizeprotected static final int
The field index for visibleprotected static final int
The last field index used by this classprotected VRMLSurfaceLayoutListener
The listener for resize eventsprotected boolean
The visibility state of the parent node.protected Rectangle
The real bounds of this objectprotected float[]
The real position of the overlay in screen coordinatesprotected float[]
The user-supplied bounding box size fieldprotected boolean
exposedField SFBool visibleFields 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
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
BaseSurfaceChildNode
(String name) Construct a new default Overlay object -
Method Summary
Modifier and TypeMethodDescriptionprotected void
copy
(VRMLSurfaceChildNodeType node) Set the fields of the overlay child node that has the fields set based on the fields of the passed in node.protected void
fireSizeChange
(int width, int height) Send an event to the listener with the new size information.float[]
Get the value of the 2D bounding box size of this overlay.getFieldValue
(int index) Get the value of a field.boolean
Request the node's current parent visibility state.int
Get the primary type of this node.Get the current value of the 2D bounding box of this overlay.boolean
Get the current visibility state of this node.void
sendRoute
(double time, int srcIndex, VRMLNodeType destNode, int destIndex) Send a routed value from this node to the given destination node.void
setBboxSize
(float[] bbox) Convenience method to check on the raw value of the bbox to make sure it is OK.void
Set the layout listener for this node.void
setLocation
(int x, int y) Tell this overlay that it's position in window coordinates has been changed to this new value.void
setParentVisible
(boolean state) Notification from the parent node about this node's visibility state.void
Notification that the construction phase of this node has finished.void
setValue
(int index, boolean value) Set the value of the field at the given index as a boolean.void
setValue
(int index, float[] value, int numValid) Set the value of the field at the given index as a boolean.void
setVisible
(boolean state) Set the visibility state of the surface.Methods inherited from class org.web3d.vrml.renderer.common.nodes.AbstractNode
addNodeListener, allEventsComplete, checkNodeType, checkSecondaryType, checkSecondaryType, clearRemovedLayerIds, fireFieldChanged, getLayerIds, getMetadataObject, getRefCount, getRemovedLayerIds, getSecondaryType, getUserData, getVRMLNodeName, hasFieldChanged, isDEF, isSetupFinished, notifyExternProtoLoaded, removeNodeListener, setDEF, setErrorReporter, setFrameStateManager, setMetadataObject, setUserData, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setVersion, throwInitOnlyWriteException, throwInputOnlyWriteException, throwInvalidNodeException, throwInvalidProtoException, throwOutputOnlyWriteException, updateRefCount, updateRefs
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.web3d.vrml.nodes.FrameStateListener
allEventsComplete
Methods inherited from interface org.web3d.vrml.lang.VRMLNode
getFieldDeclaration, getFieldIndex, getNodeFieldIndices, getNumFields, getSecondaryType, 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, setValue, setValue, setValue, updateRefCount
-
Field Details
-
FIELD_VISIBLE
protected static final int FIELD_VISIBLEThe field index for visible- See Also:
-
FIELD_BBOX_SIZE
protected static final int FIELD_BBOX_SIZEThe field index for bboxSize- See Also:
-
LAST_SURFACE_CHILD_INDEX
protected static final int LAST_SURFACE_CHILD_INDEXThe last field index used by this class- See Also:
-
vfVisible
protected boolean vfVisibleexposedField SFBool visible -
screenLocation
protected float[] screenLocationThe real position of the overlay in screen coordinates -
vfBboxSize
protected float[] vfBboxSizeThe user-supplied bounding box size field -
screenBounds
The real bounds of this object -
listener
The listener for resize events -
parentVisibility
protected boolean parentVisibilityThe visibility state of the parent node. Defaults to true
-
-
Constructor Details
-
BaseSurfaceChildNode
Construct a new default Overlay object- Parameters:
name
-
-
-
Method Details
-
copy
Set the fields of the overlay child node that has the fields set based on the fields of the passed in node.- Parameters:
node
- The node to copy info from
-
isVisible
public boolean isVisible()Get the current visibility state of this node.- Specified by:
isVisible
in interfaceVRMLSurfaceChildNodeType
- Returns:
- true if the node is current visible, false otherwise
-
setVisible
public void setVisible(boolean state) Set the visibility state of the surface. A non-visible surface will still take events and update, just not be rendered.- Specified by:
setVisible
in interfaceVRMLSurfaceChildNodeType
- Parameters:
state
- true to make this node visible, false to hide
-
setParentVisible
public void setParentVisible(boolean state) Notification from the parent node about this node's visibility state. Used to control the rendering so that if a parent is not visible it can inform this node that it is also not visible without needing to stuff with the local visibility state. This implementation does nothing, but derived classes may wish to do something with it.- Specified by:
setParentVisible
in interfaceVRMLSurfaceChildNodeType
- Parameters:
state
- true to make this node visible, false to hide
-
getParentVisible
public boolean getParentVisible()Request the node's current parent visibility state. Mainly used for proto copying.- Specified by:
getParentVisible
in interfaceVRMLSurfaceChildNodeType
- Returns:
- true if parent visible, false otherwise
-
getBboxSize
public float[] getBboxSize()Get the value of the 2D bounding box size of this overlay. The bounds are given in pixel coordinates relative to the center of this overlay. Although the return values are always floats, the values will alway be integer based and will not contain fractional values.- Specified by:
getBboxSize
in interfaceVRMLSurfaceChildNodeType
- Returns:
- The current bounds
-
getRealBounds
Get the current value of the 2D bounding box of this overlay. The bounds are given in pixel coordinates relative to the top left corner.- Specified by:
getRealBounds
in interfaceVRMLSurfaceChildNodeType
- Returns:
- The current bounds [x, y, width, height]
-
setLocation
public void setLocation(int x, int y) Tell this overlay that it's position in window coordinates has been changed to this new value. The position is always that of the top-left corner of the bounding box in screen coordinate space.- Specified by:
setLocation
in interfaceVRMLSurfaceChildNodeType
- Parameters:
x
- The x location of the window in pixelsy
- The y location of the window in pixels
-
setLayoutListener
Set the layout listener for this node. Setting a value of null clears the current listener instance.- Specified by:
setLayoutListener
in interfaceVRMLSurfaceChildNodeType
- Parameters:
l
- The new listener to use or null
-
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
-
getFieldValue
Get the value of a field. If the field is a primitive type, it will return a class representing the value. For arrays or nodes it will return the instance directly.- Specified by:
getFieldValue
in interfaceVRMLNodeType
- Overrides:
getFieldValue
in classAbstractNode
- Parameters:
index
- The index of the field to change.- Returns:
- The class representing the field value
- Throws:
InvalidFieldException
- The field index is not known
-
sendRoute
Send a routed value from this node to the given destination node. The route should use the appropriate setValue() method of the destination node. It should not attempt to cast the node up to a higher level. Routing should also follow the standard rules for the loop breaking and other appropriate rules for the specification.- Specified by:
sendRoute
in interfaceVRMLNodeType
- Overrides:
sendRoute
in classAbstractNode
- Parameters:
time
- The time that this route occurred (not necessarily epoch time. Should be treated as a relative value only)srcIndex
- The index of the field in this node that the value should be sent fromdestNode
- The node reference that we will be sending the value todestIndex
- The index of the field in the destination node that the value should be sent to.
-
setupFinished
public void setupFinished()Notification that the construction phase of this node has finished. If the node would like to do any internal processing, such as setting up geometry, then go for it now.- Specified by:
setupFinished
in interfaceVRMLNodeType
- Overrides:
setupFinished
in classAbstractNode
-
setValue
Set the value of the field at the given index as a boolean. This would be used to set SFBool 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 know
-
setValue
Set the value of the field at the given index as a boolean. This would be used to set SFVec3f 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 fieldInvalidFieldAccessException
- The call is attempting to write to a field that does not permit writing now
-
fireSizeChange
protected void fireSizeChange(int width, int height) Send an event to the listener with the new size information.- Parameters:
width
- The new width to useheight
- The new height to use
-
setBboxSize
public void setBboxSize(float[] bbox) throws InvalidFieldValueException, InvalidFieldAccessException Convenience method to check on the raw value of the bbox to make sure it is OK.- Parameters:
bbox
- The bounding box to check- Throws:
InvalidFieldValueException
- Value out of specInvalidFieldAccessException
- The call is attempting to write to a field that does not permit writing now
-