Class BaseSurfaceLayoutNode
java.lang.Object
org.web3d.vrml.renderer.common.nodes.AbstractNode
org.web3d.vrml.renderer.common.nodes.surface.BaseSurfaceChildNode
org.web3d.vrml.renderer.common.nodes.surface.BaseSurfaceLayoutNode
- All Implemented Interfaces:
VRMLNode
,FrameStateListener
,VRMLNodeType
,VRMLSurfaceChildNodeType
,VRMLSurfaceLayoutListener
,VRMLSurfaceLayoutNodeType
- Direct Known Subclasses:
BaseBorderLayout
,BaseGridLayout
,BaseGroupLayout
,BaseXYLayout
public abstract class BaseSurfaceLayoutNode
extends BaseSurfaceChildNode
implements VRMLSurfaceLayoutNodeType, VRMLSurfaceLayoutListener
Base implementation of any surface layout node.
The implementation does not define the windowChanged method because it assumes the derived class has all the specific information about the required rules to update and place the children.
- Version:
- $Revision: 1.12 $
- Author:
- Justin Couch
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final String
Message for when the node in setValue() is not a Appearanceprotected static final String
Message for when the proto is not a Appearanceprotected static final int
The field index for cycleIntervalprotected static final int
The last field index used by this classprotected VRMLNodeType[]
The value of the children exposedFieldFields inherited from class org.web3d.vrml.renderer.common.nodes.surface.BaseSurfaceChildNode
FIELD_BBOX_SIZE, FIELD_VISIBLE, LAST_SURFACE_CHILD_INDEX, listener, parentVisibility, screenBounds, screenLocation, vfBboxSize, vfVisible
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
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
BaseSurfaceLayoutNode
(String name) Construct a new default Overlay object -
Method Summary
Modifier and TypeMethodDescriptionprotected void
appendNode
(VRMLNodeType node) Add a child node to the current list.Get the list of current relationships used by this node.getFieldValue
(int index) Get the value of a field.int
Get the primary type 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
setChildren
(VRMLNodeType[] kids) Set the drawable content of this node to the surface.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, VRMLNodeType child) Set the value of the field at the given index as an array of nodes.void
setValue
(int index, VRMLNodeType[] children, int numValid) Set the value of the field at the given index as an array of nodes.void
setVisible
(boolean state) Set the visibility state of the surface.void
surfaceResized
(int width, int height) Notification that its size has changed.protected void
Convenience method to update the children node(s) to the new positions.void
windowChanged
(int x, int y, int width, int height) Set the new window size, requesting that the layout implementation rebuild and re-evaluate all of the items it contains.Methods inherited from class org.web3d.vrml.renderer.common.nodes.surface.BaseSurfaceChildNode
copy, fireSizeChange, getBboxSize, getParentVisible, getRealBounds, isVisible, setBboxSize, setLayoutListener, setLocation, setValue, setValue
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, 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
Methods inherited from interface org.web3d.vrml.nodes.VRMLSurfaceChildNodeType
getBboxSize, getParentVisible, getRealBounds, isVisible, setLayoutListener, setLocation
-
Field Details
-
FIELD_CHILDREN
protected static final int FIELD_CHILDRENThe field index for cycleInterval- See Also:
-
LAST_LAYOUT_INDEX
protected static final int LAST_LAYOUT_INDEXThe last field index used by this class- See Also:
-
BAD_PROTO_MSG
Message for when the proto is not a Appearance- See Also:
-
BAD_NODE_MSG
Message for when the node in setValue() is not a Appearance- See Also:
-
vfChildren
The value of the children exposedField
-
-
Constructor Details
-
BaseSurfaceLayoutNode
Construct a new default Overlay object- Parameters:
name
-
-
-
Method Details
-
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
- Overrides:
setVisible
in classBaseSurfaceChildNode
- 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.- Specified by:
setParentVisible
in interfaceVRMLSurfaceChildNodeType
- Overrides:
setParentVisible
in classBaseSurfaceChildNode
- Parameters:
state
- true to make this node visible, false to hide
-
setChildren
Set the drawable content of this node to the surface. If value is set to null, then it clears all the renderable list and nothing is show. The nodes provided must beVRMLSurfaceChildNodeType
orVRMLProtoInstance
.- Specified by:
setChildren
in interfaceVRMLSurfaceLayoutNodeType
- Parameters:
kids
- The list of new children to render- Throws:
InvalidFieldValueException
- The nodes are not one of the required types.
-
getChildren
Get the list of current relationships used by this node. If none are defined, this returns a null value. be aVRMLProtoInstance
.- Specified by:
getChildren
in interfaceVRMLSurfaceLayoutNodeType
- Returns:
- The list of current relationships or null
-
windowChanged
public void windowChanged(int x, int y, int width, int height) Set the new window size, requesting that the layout implementation rebuild and re-evaluate all of the items it contains. If this layout is a child of another layout, the size set will be the allocated size for the child window. The location is in standard 2D screen coordinates of the top-left corner.After setting the screen bounds, this will call
updateManagedNodes()
.- Specified by:
windowChanged
in interfaceVRMLSurfaceLayoutNodeType
- Parameters:
x
- The x location of the window in pixelsy
- The y location of the window in pixelswidth
- The width of the window in pixelsheight
- The height of the window in pixels
-
surfaceResized
public void surfaceResized(int width, int height) Notification that its size has changed. Values shall not be negative.- Specified by:
surfaceResized
in interfaceVRMLSurfaceLayoutListener
- Parameters:
width
- The new width of the surfaceheight
- The new height of the surface
-
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 classBaseSurfaceChildNode
-
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
- Overrides:
getPrimaryType
in classBaseSurfaceChildNode
- 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 classBaseSurfaceChildNode
- 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 classBaseSurfaceChildNode
- 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 an array of nodes. This would be used to set MFNode field types.- Specified by:
setValue
in interfaceVRMLNodeType
- Overrides:
setValue
in classAbstractNode
- Parameters:
index
- The index of destination field to setchild
- 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 an array of nodes. This would be used to set MFNode field types.- Specified by:
setValue
in interfaceVRMLNodeType
- Overrides:
setValue
in classAbstractNode
- Parameters:
index
- The index of destination field to setchildren
- 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 know
-
updateManagedNodes
protected void updateManagedNodes()Convenience method to update the children node(s) to the new positions. The position may have changed because the window size changed, or the layout node settings have changed. The default implementation does nothing, but is called when the screen size changed. Derived classes should override this to do something useful. -
appendNode
Add a child node to the current list. This is only called during the setup process. Once setupFinished has been called, this method will not be called again. Ok for derived class to override.- Parameters:
node
- The new node to add
-