org.jdesktop.wonderland.client.scenemanager
Class SceneManager

java.lang.Object
  extended by org.jdesktop.wonderland.client.scenemanager.SceneManager

public class SceneManager
extends java.lang.Object

Manages the global "selection" in Wonderland. The Selection Manager handles all sorts of interactions with Entities in the world. The selection manager sits above the basic input mechanism and adds interpretation in terms of "actions" in the Wonderland context.

  1. Selection: The selection of an Entity in the world. This includes selecting one or more Entities in the world. A selected Entity(s) will be indicated in some way. This also involves deselecting (clearing) any of the Entities.
  2. Context: A Context action is one that depends upon the set of Entities that are selected. Typically a menu pops up with further actions possible.
  3. Enter/Exit: An Enter/Exit action is where the pointer enters or exits an Entity, typically with the mouse pointer.
  4. Hover: A Hover action is where the pointer hovers over an Entity (typically by hovering the mouse). This includes the "start" hovering and the "stop" hovering.
  5. Activation: The activation of an Entity in the world. For example, when a user double-clicks on an Entity, it is activated.
Threads can register listeners on the scene manager for these actions. There are methods to fetch the collection of selected entities and the Entity where there is a hover. Threads can also manually clear the selected Entities.

The Selection Manager acts on individual Entities, so multiple Entities with a Cell can be individually selected. Threads can fetch the Cell object associated with an Entity via the getCellForEntity() method.

Which mouse and keyboard events correspond to the Selection Manager actions are controlled via a "selection policy" as defined by a class that implements the SceneManagerPolicy interface.

Author:
Jordan Slott

Field Summary
protected  org.jdesktop.mtgame.Entity hoverEntity
           
protected  long hoverStartTime
           
protected  java.util.Timer hoverTimer
           
 
Constructor Summary
SceneManager()
          Default Constructor
 
Method Summary
 void addSceneListener(EventListener listener)
          Adds a listener for scene events.
 void cleanup()
          Clean up this scene manager and remove all registered listeners
 void clearSelection()
          Clears out the currently selection set of entities.
static Cell getCellForEntity(org.jdesktop.mtgame.Entity entity)
          Convienence method that returns the cell associated with the Entity.
 org.jdesktop.mtgame.Entity getHoverEntity()
          Returns the Entity over which there is a hover, null if there is no hover.
static SceneManager getSceneManager()
          Returns a single instance of this class
 java.util.List<org.jdesktop.mtgame.Entity> getSelectedEntities()
          Returns the list of currently selected entitities in the order they were selected, or null if no entity is currently selected.
protected  void inputEvent(Event event)
          Provides a raw input event to process
 void postEvent(SceneEvent event)
          Posts a Scene Manager event to this system.
 void removeSceneListener(EventListener listener)
          Removes a listener for scene events.
protected  void setHoverEntity(org.jdesktop.mtgame.Entity hoverEntity)
          Sets the Entity over which there is hover.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

hoverEntity

protected org.jdesktop.mtgame.Entity hoverEntity

hoverTimer

protected java.util.Timer hoverTimer

hoverStartTime

protected long hoverStartTime
Constructor Detail

SceneManager

public SceneManager()
Default Constructor

Method Detail

cleanup

public void cleanup()
Clean up this scene manager and remove all registered listeners


getSceneManager

public static final SceneManager getSceneManager()
Returns a single instance of this class

Returns:
Single instance of this class.

inputEvent

protected void inputEvent(Event event)
Provides a raw input event to process


postEvent

public void postEvent(SceneEvent event)
Posts a Scene Manager event to this system. This method can be used to 'fake' such an event. This method will re-post the event to the input manager for others to handle.

Parameters:
event - The scene event to post to the system

clearSelection

public void clearSelection()
Clears out the currently selection set of entities.


getSelectedEntities

public java.util.List<org.jdesktop.mtgame.Entity> getSelectedEntities()
Returns the list of currently selected entitities in the order they were selected, or null if no entity is currently selected.

Returns:
The currently selected list of Entity objects

setHoverEntity

protected void setHoverEntity(org.jdesktop.mtgame.Entity hoverEntity)
Sets the Entity over which there is hover.

Parameters:
hoverEntity - The hover Entity, null to reset to none

getHoverEntity

public org.jdesktop.mtgame.Entity getHoverEntity()
Returns the Entity over which there is a hover, null if there is no hover.

Returns:
The Entity object over which there is a hover

getCellForEntity

public static Cell getCellForEntity(org.jdesktop.mtgame.Entity entity)
Convienence method that returns the cell associated with the Entity.

Returns:
The Cell associated with the currently selected Entity

addSceneListener

public void addSceneListener(EventListener listener)
Adds a listener for scene events.

Parameters:
listener - The scene event listener to add

removeSceneListener

public void removeSceneListener(EventListener listener)
Removes a listener for scene events.

Parameters:
listener - The scene event listener to remove


Open Wonderland - http://openwonderland.org