Package org.xj3d.impl.core.eventmodel
Class DefaultViewpointManager
java.lang.Object
org.xj3d.impl.core.eventmodel.DefaultViewpointManager
- All Implemented Interfaces:
ViewpointStatusListener
,ViewpointManager
public class DefaultViewpointManager
extends Object
implements ViewpointManager, ViewpointStatusListener
Default implementation of a manager for Viewpoint nodes.
Keeps track of all viewpoints, manages the viewpoint list based on the sets of active viewpoints. Next and previous commands will work on the currently active navigation layer.
Creating an instance of this class will automatically register it as viewpoint and navigation state listeners with the browser core. The end user is not required to do this.
- Version:
- $Revision: 1.15 $
- Author:
- Alan Hudson
-
Constructor Summary
ConstructorsConstructorDescriptionCreate a new, empty instance of the humanoid manager. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Add a listener for viewpoint status messages.void
clear()
Force clearing all currently managed nodes from this manager now.void
Go to the first declared viewpoint at the next available opportunity.void
firstViewpoint
(int layer) Go to the first declared viewpoint int the specified layer at the next available opportunity.Gets the viewpoints for the currently active layer.void
Go to the last declared viewpoint at the next available opportunity.void
lastViewpoint
(int layer) Go to the last declared viewpoint of the specified layer at the next available opportunity.void
Go to the next viewpoint at the next available opportunity.void
nextViewpoint
(int layer) Go to the next viewpoint at the next available opportunity.void
Go to the previous viewpoint at the next available opportunity.void
previousViewpoint
(int layer) Go to the previous viewpoint at the next available opportunity.void
Remove a listener for viewpoint status messages.void
Reset the current viewpoint.void
setErrorReporter
(org.j3d.util.ErrorReporter reporter) Register an error reporter with the engine so that any errors generated by the loading of script code can be reported in a nice, pretty fashion.void
setViewpoint
(VRMLViewpointNodeType viewpoint) Set the current viewpoint.void
shutdown()
Shutdown the node manager now.void
updateViewpoint
(long time) Update the viewpoint.void
viewpointAdded
(VRMLViewpointNodeType node, int layerId, boolean isDefault) Invoked when a viewpoint has been addedvoid
viewpointBound
(VRMLViewpointNodeType node, int layerId) Invoked when a viewpoint has been bound.void
viewpointLayerActive
(int layerId) The given layer is now made the active layer.void
viewpointLayerAdded
(int layerId) Notification of the addition of a valid layer ID to the current list.void
viewpointLayerRemoved
(int layerId) Notification that a Layer ID is no longer valid.void
viewpointRemoved
(VRMLViewpointNodeType node, int layerId) Invoked when a viewpoint has been removed
-
Constructor Details
-
DefaultViewpointManager
Create a new, empty instance of the humanoid manager.- Parameters:
core
- The browser core
-
-
Method Details
-
updateViewpoint
public void updateViewpoint(long time) Update the viewpoint. Called at the beginning of the event model.- Specified by:
updateViewpoint
in interfaceViewpointManager
- Parameters:
time
- The time.
-
setErrorReporter
public void setErrorReporter(org.j3d.util.ErrorReporter reporter) Register an error reporter with the engine so that any errors generated by the loading of script code can be reported in a nice, pretty fashion. Setting a value of null will clear the currently set reporter. If one is already set, the new value replaces the old.- Specified by:
setErrorReporter
in interfaceViewpointManager
- Parameters:
reporter
- The instance to use or null
-
setViewpoint
Set the current viewpoint.- Specified by:
setViewpoint
in interfaceViewpointManager
- Parameters:
viewpoint
- The new current viewpoint.
-
resetViewpoint
public void resetViewpoint()Reset the current viewpoint.- Specified by:
resetViewpoint
in interfaceViewpointManager
-
firstViewpoint
public void firstViewpoint()Go to the first declared viewpoint at the next available opportunity. This corresponds to the SAI Browser.firstViewpoint() call.- Specified by:
firstViewpoint
in interfaceViewpointManager
-
firstViewpoint
public void firstViewpoint(int layer) Go to the first declared viewpoint int the specified layer at the next available opportunity. This corresponds to the SAI Browser.firstViewpoint() call.- Specified by:
firstViewpoint
in interfaceViewpointManager
- Parameters:
layer
- The ID of the layer. Must be between 0 and the maximum layer number
-
lastViewpoint
public void lastViewpoint()Go to the last declared viewpoint at the next available opportunity. This corresponds to the SAI Browser.lastViewpoint() call.- Specified by:
lastViewpoint
in interfaceViewpointManager
-
lastViewpoint
public void lastViewpoint(int layer) Go to the last declared viewpoint of the specified layer at the next available opportunity. This corresponds to the SAI Browser.lastViewpoint() call.- Specified by:
lastViewpoint
in interfaceViewpointManager
- Parameters:
layer
- The ID of the layer. Must be between 0 and the maximum layer number
-
nextViewpoint
public void nextViewpoint()Go to the next viewpoint at the next available opportunity. It looks at the added list for the index of the current viewpoint and moves to the next index it can find. This corresponds to the SAI Browser.nextViewpoint() call.- Specified by:
nextViewpoint
in interfaceViewpointManager
-
nextViewpoint
public void nextViewpoint(int layer) Go to the next viewpoint at the next available opportunity. It looks at the added list for the index of the current viewpoint and moves to the next index it can find for the specific layer ID. This corresponds to the SAI Browser.previousViewpoint() call.- Specified by:
nextViewpoint
in interfaceViewpointManager
- Parameters:
layer
- The ID of the layer. Must be between 0 and the maximum layer number
-
previousViewpoint
public void previousViewpoint()Go to the previous viewpoint at the next available opportunity. It looks at the added list for the index of the current viewpoint and moves to the previous index it can find. This corresponds to the SAI Browser.previousViewpoint() call.- Specified by:
previousViewpoint
in interfaceViewpointManager
-
previousViewpoint
public void previousViewpoint(int layer) Go to the previous viewpoint at the next available opportunity. It looks at the added list for the index of the current viewpoint and moves to the previous index it can find for the specific layer ID. This corresponds to the SAI Browser.previousViewpoint() call.- Specified by:
previousViewpoint
in interfaceViewpointManager
- Parameters:
layer
- The ID of the layer. Must be between 0 and the maximum layer number
-
shutdown
public void shutdown()Shutdown the node manager now. If this is using any external resources it should remove those now as the entire application is about to die- Specified by:
shutdown
in interfaceViewpointManager
-
clear
public void clear()Force clearing all currently managed nodes from this manager now. This is used to indicate that a new world is about to be loaded and everything should be cleaned out now.- Specified by:
clear
in interfaceViewpointManager
-
addViewpointListener
Add a listener for viewpoint status messages. Adding the same listener instance more than once will be silently ignored. Null values are ignored.- Specified by:
addViewpointListener
in interfaceViewpointManager
- Parameters:
l
- The listener instance to add
-
removeViewpointListener
Remove a listener for viewpoint status messages. If this listener is not currently registered, the request will be silently ignored.- Specified by:
removeViewpointListener
in interfaceViewpointManager
- Parameters:
l
- The listener instance to remove
-
viewpointLayerAdded
public void viewpointLayerAdded(int layerId) Description copied from interface:ViewpointStatusListener
Notification of the addition of a valid layer ID to the current list. This layer is currently empty of viewpoints. Calls toViewpointStatusListener.viewpointAdded(org.web3d.vrml.nodes.VRMLViewpointNodeType, int, boolean)
will subsequently follow with all the viewpoints listed in this layer. It can be assumed that the layer is not currently the active layer. A separate notification is available for that.- Specified by:
viewpointLayerAdded
in interfaceViewpointStatusListener
- Parameters:
layerId
- The ID of the layer to be added
-
viewpointLayerRemoved
public void viewpointLayerRemoved(int layerId) Notification that a Layer ID is no longer valid. Any viewpoints that have been made available for that layer should now be removed from the layer. TheviewpointRemoved(org.web3d.vrml.nodes.VRMLViewpointNodeType, int)
callback will not be made for this case.- Specified by:
viewpointLayerRemoved
in interfaceViewpointStatusListener
- Parameters:
layerId
- The ID of the layer to be added
-
viewpointLayerActive
public void viewpointLayerActive(int layerId) The given layer is now made the active layer. If there is a viewpoint list being maintained per-layer then the UI can perform some sort of highlighting to indicate this. Viewpoints in other layers are still allowed to be bound by the user interface. If there was a previously active layer, ignore it.The code will guarantee that if the active layer is removed, then this method will be called first to set a different valid layer, before removing that layer ID.
If a value of -1 is provided, that means no layers are active and that we currently have a completely clear browser with no world loaded. The UI should act appropriately.
- Specified by:
viewpointLayerActive
in interfaceViewpointStatusListener
- Parameters:
layerId
- The ID of the layer to be made current or -1
-
viewpointAdded
Invoked when a viewpoint has been added- Specified by:
viewpointAdded
in interfaceViewpointStatusListener
- Parameters:
node
- The viewpointlayerId
- The ID of the layer the viewpoint is added toisDefault
- Is the node a default
-
viewpointRemoved
Invoked when a viewpoint has been removed- Specified by:
viewpointRemoved
in interfaceViewpointStatusListener
- Parameters:
node
- The viewpointlayerId
- The ID of the layer the viewpoint is removed from
-
viewpointBound
Invoked when a viewpoint has been bound.- Specified by:
viewpointBound
in interfaceViewpointStatusListener
- Parameters:
node
- The viewpointlayerId
- The ID of the layer the viewpoint is bound on
-
getActiveViewpoints
Description copied from interface:ViewpointManager
Gets the viewpoints for the currently active layer.- Specified by:
getActiveViewpoints
in interfaceViewpointManager
- Returns:
- A list of the viewpoint nodes for the currently active layer
-