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 TypeMethodDescriptionvoidAdd a listener for viewpoint status messages.voidclear()Force clearing all currently managed nodes from this manager now.voidGo to the first declared viewpoint at the next available opportunity.voidfirstViewpoint(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.voidGo to the last declared viewpoint at the next available opportunity.voidlastViewpoint(int layer) Go to the last declared viewpoint of the specified layer at the next available opportunity.voidGo to the next viewpoint at the next available opportunity.voidnextViewpoint(int layer) Go to the next viewpoint at the next available opportunity.voidGo to the previous viewpoint at the next available opportunity.voidpreviousViewpoint(int layer) Go to the previous viewpoint at the next available opportunity.voidRemove a listener for viewpoint status messages.voidReset the current viewpoint.voidsetErrorReporter(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.voidsetViewpoint(VRMLViewpointNodeType viewpoint) Set the current viewpoint.voidshutdown()Shutdown the node manager now.voidupdateViewpoint(long time) Update the viewpoint.voidviewpointAdded(VRMLViewpointNodeType node, int layerId, boolean isDefault) Invoked when a viewpoint has been addedvoidviewpointBound(VRMLViewpointNodeType node, int layerId) Invoked when a viewpoint has been bound.voidviewpointLayerActive(int layerId) The given layer is now made the active layer.voidviewpointLayerAdded(int layerId) Notification of the addition of a valid layer ID to the current list.voidviewpointLayerRemoved(int layerId) Notification that a Layer ID is no longer valid.voidviewpointRemoved(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:
updateViewpointin 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:
setErrorReporterin interfaceViewpointManager- Parameters:
reporter- The instance to use or null
-
setViewpoint
Set the current viewpoint.- Specified by:
setViewpointin interfaceViewpointManager- Parameters:
viewpoint- The new current viewpoint.
-
resetViewpoint
public void resetViewpoint()Reset the current viewpoint.- Specified by:
resetViewpointin 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:
firstViewpointin 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:
firstViewpointin 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:
lastViewpointin 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:
lastViewpointin 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:
nextViewpointin 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:
nextViewpointin 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:
previousViewpointin 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:
previousViewpointin 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:
shutdownin 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:
clearin 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:
addViewpointListenerin 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:
removeViewpointListenerin interfaceViewpointManager- Parameters:
l- The listener instance to remove
-
viewpointLayerAdded
public void viewpointLayerAdded(int layerId) Description copied from interface:ViewpointStatusListenerNotification 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:
viewpointLayerAddedin 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:
viewpointLayerRemovedin 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:
viewpointLayerActivein interfaceViewpointStatusListener- Parameters:
layerId- The ID of the layer to be made current or -1
-
viewpointAdded
Invoked when a viewpoint has been added- Specified by:
viewpointAddedin 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:
viewpointRemovedin 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:
viewpointBoundin interfaceViewpointStatusListener- Parameters:
node- The viewpointlayerId- The ID of the layer the viewpoint is bound on
-
getActiveViewpoints
Description copied from interface:ViewpointManagerGets the viewpoints for the currently active layer.- Specified by:
getActiveViewpointsin interfaceViewpointManager- Returns:
- A list of the viewpoint nodes for the currently active layer
-