net.tmachine.gpg.hue
Class HUDManager

java.lang.Object
  extended bynet.tmachine.gpg.hue.HUDManager
All Implemented Interfaces:
java.util.EventListener, java.awt.event.MouseListener, java.awt.event.MouseMotionListener

public class HUDManager
extends java.lang.Object
implements java.awt.event.MouseListener, java.awt.event.MouseMotionListener

The main Model and Controller (in MVC terms) for managing the HUDs system.

Keeps track of all HUDS, and contains the preferred methods for changing their state (allowing you to hook into just one place to capture state changes etc, e.g. for propagation to listeners)


Field Summary
protected  java.util.LinkedList activeHUDGroupsStack
           
protected  java.util.HashMap allHUDs
           
protected  ContextManager context
           
protected  javax.swing.JComponent display
           
protected  java.util.ArrayList inputListeningHUDs
          HUD instances that are currently listening for any input events
 
Constructor Summary
HUDManager()
          You MUST call setDisplayComponent before using this new instance
 
Method Summary
 void activateHUD(HUD h)
          Activates the HUD; since a HUD cannot be invisible and active, it is implicitly made visible at the same time; active HUDs receive input events, e.g mouse movement and keyboard presses.
 void addHUD(HUD h)
          Adds the HUD to the set of current HUDs, and sets the HUD's reference to it's parent manager to point to this instance
 void deActivateHUD(HUD h)
          De-activates the HUD, so that it gets NO input events, and cannot respond as a tool/control Inactive HUDs can still paint, if they are also visible.
 void exitExclusiveActiveHUD()
          Restores all the previously active HUDs to their active state
 java.util.ArrayList getActiveHUDs()
          Only returns HUDs that are both active and visible (assumes that invisible HUDs, which cannot give feedback on what the user is doing, should not be counted active - but leaves them "isActive() == true" so that as soon as they are made visible again they will automatically become active)
 java.util.ArrayList getAllHUDs()
          Fetches all HUDs, regardless of status
 ContextManager getContext()
          The context that HUDs can query to find out e.g the most recent cursor co-ordinates
 java.util.ArrayList getVisibleHUDs()
          Fetches only HUDs that are visible, i.e are being painted to the main renderer
 void hideHUD(HUD h)
          Renders the supplied HUD invisible, i.e it doesn't participate in repaints
 void mouseClicked(java.awt.event.MouseEvent e)
          Delegates to all the currently active HUDs that are listening to inputs
 void mouseDragged(java.awt.event.MouseEvent e)
          Delegates to all the currently active HUDs that are listening to inputs
 void mouseEntered(java.awt.event.MouseEvent e)
          Delegates to all the currently active HUDs that are listening to inputs
 void mouseExited(java.awt.event.MouseEvent e)
          Delegates to all the currently active HUDs that are listening to inputs
 void mouseMoved(java.awt.event.MouseEvent e)
          Delegates to all the currently active HUDs that are listening to inputs
 void mousePressed(java.awt.event.MouseEvent e)
          Delegates to all the currently active HUDs that are listening to inputs
 void mouseReleased(java.awt.event.MouseEvent e)
          Delegates to all the currently active HUDs that are listening to inputs
 void repaint()
          Callback for HUDs to instruct the manager that they have changed their paint state and need a repaint of the main renderer
 void setContext(ContextManager cm)
           
 void setDisplayComponent(javax.swing.JComponent c)
          Informs this class which display component is the main renderer
 void setExclusiveActiveHUD(HUD h)
          Enables a HUD to temporarily mask out all currently active HUD's in favour of one in particular; once that HUD has completed it's action, it should call exitExclusiveHUD to re-enable all previously active HUDs.
 void showHUD(HUD h)
          Renders the supplied HUD visible, i.e it's paint callback is invoked on all repaints
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

display

protected javax.swing.JComponent display

context

protected ContextManager context

inputListeningHUDs

protected java.util.ArrayList inputListeningHUDs
HUD instances that are currently listening for any input events


activeHUDGroupsStack

protected java.util.LinkedList activeHUDGroupsStack

allHUDs

protected java.util.HashMap allHUDs
Constructor Detail

HUDManager

public HUDManager()
You MUST call setDisplayComponent before using this new instance

See Also:
setDisplayComponent(JComponent)
Method Detail

repaint

public void repaint()
Callback for HUDs to instruct the manager that they have changed their paint state and need a repaint of the main renderer


getContext

public ContextManager getContext()
The context that HUDs can query to find out e.g the most recent cursor co-ordinates

Returns:

setContext

public void setContext(ContextManager cm)

setDisplayComponent

public void setDisplayComponent(javax.swing.JComponent c)
Informs this class which display component is the main renderer

Parameters:
c -

addHUD

public void addHUD(HUD h)
Adds the HUD to the set of current HUDs, and sets the HUD's reference to it's parent manager to point to this instance

Parameters:
h -

getAllHUDs

public java.util.ArrayList getAllHUDs()
Fetches all HUDs, regardless of status

Returns:

getVisibleHUDs

public java.util.ArrayList getVisibleHUDs()
Fetches only HUDs that are visible, i.e are being painted to the main renderer

Returns:

hideHUD

public void hideHUD(HUD h)
Renders the supplied HUD invisible, i.e it doesn't participate in repaints

See Also:
showHUD(HUD)

showHUD

public void showHUD(HUD h)
Renders the supplied HUD visible, i.e it's paint callback is invoked on all repaints

See Also:
hideHUD(HUD)

deActivateHUD

public void deActivateHUD(HUD h)
De-activates the HUD, so that it gets NO input events, and cannot respond as a tool/control Inactive HUDs can still paint, if they are also visible.

See Also:
activateHUD(HUD)

activateHUD

public void activateHUD(HUD h)
Activates the HUD; since a HUD cannot be invisible and active, it is implicitly made visible at the same time; active HUDs receive input events, e.g mouse movement and keyboard presses.

See Also:
deActivateHUD(HUD), showHUD(HUD)

getActiveHUDs

public java.util.ArrayList getActiveHUDs()
Only returns HUDs that are both active and visible (assumes that invisible HUDs, which cannot give feedback on what the user is doing, should not be counted active - but leaves them "isActive() == true" so that as soon as they are made visible again they will automatically become active)

Returns:

setExclusiveActiveHUD

public void setExclusiveActiveHUD(HUD h)
Enables a HUD to temporarily mask out all currently active HUD's in favour of one in particular; once that HUD has completed it's action, it should call exitExclusiveHUD to re-enable all previously active HUDs.

This is a convenient way of making tools that e.g. need to engage in a multiple-stage dialog with the user within the edit window, without risking propagating input events to other HUDS.

This is typically used for complex actions, such as creating a 3D object: the gesture that triggers the create action within the main renderer will mask out everything else because it needs to exclusively capture the next few clicks (e.g. one drag to set size in one plane, followed by a click or release, then a second drag or move followed by a click to set the size in the perpendicular plane, since a 3D object cannot easily be sized using a 2D mouse cursor without this multiple-stage interaction).

Parameters:
h - the HUD to make active whilst all others are masked out
See Also:
exitExclusiveActiveHUD()

exitExclusiveActiveHUD

public void exitExclusiveActiveHUD()
Restores all the previously active HUDs to their active state

See Also:
setExclusiveActiveHUD(HUD)

mouseClicked

public void mouseClicked(java.awt.event.MouseEvent e)
Delegates to all the currently active HUDs that are listening to inputs

Specified by:
mouseClicked in interface java.awt.event.MouseListener

mouseDragged

public void mouseDragged(java.awt.event.MouseEvent e)
Delegates to all the currently active HUDs that are listening to inputs

Specified by:
mouseDragged in interface java.awt.event.MouseMotionListener

mouseEntered

public void mouseEntered(java.awt.event.MouseEvent e)
Delegates to all the currently active HUDs that are listening to inputs

Specified by:
mouseEntered in interface java.awt.event.MouseListener

mouseExited

public void mouseExited(java.awt.event.MouseEvent e)
Delegates to all the currently active HUDs that are listening to inputs

Specified by:
mouseExited in interface java.awt.event.MouseListener

mouseMoved

public void mouseMoved(java.awt.event.MouseEvent e)
Delegates to all the currently active HUDs that are listening to inputs

Specified by:
mouseMoved in interface java.awt.event.MouseMotionListener

mousePressed

public void mousePressed(java.awt.event.MouseEvent e)
Delegates to all the currently active HUDs that are listening to inputs

Specified by:
mousePressed in interface java.awt.event.MouseListener

mouseReleased

public void mouseReleased(java.awt.event.MouseEvent e)
Delegates to all the currently active HUDs that are listening to inputs

Specified by:
mouseReleased in interface java.awt.event.MouseListener