uci.gef
Class ModeManager

java.lang.Object
  |
  +--uci.gef.ModeManager

public class ModeManager
extends Object
implements Serializable, MouseListener, MouseMotionListener, KeyListener

ModeManager keeps track of all the Modes for a given Editor. Events are passed to the Modes for handling. The submodes are prioritized according to their order on a stack, i.e., the last Mode added gets the first chance to handle an Event.

See Also:
Serialized Form

Field Summary
 Editor _editor
          The Editor that owns this ModeManager.
protected  EventListenerList _listeners
           
 
Constructor Summary
ModeManager(Editor ed)
          Construct a ModeManager with no modes.
 
Method Summary
 void addModeChangeListener(ModeChangeListener listener)
           
 void checkModeTransitions(InputEvent ie)
          Check for events that should cause transitions from one Mode to another or otherwise change the ModeManager.
protected  void fireModeChanged()
           
 Editor getEditor()
          Get the parent Editor of this ModeManager
 Vector getModes()
          Reply the stack of Mode's.
 boolean includes(Class modeClass)
           
 void keyPressed(KeyEvent ke)
          Pass events to all modes in order, until one consumes it.
 void keyReleased(KeyEvent ke)
          Do nothing, this event are not passed to the Modes.
 void keyTyped(KeyEvent ke)
          Pass events to all modes in order, until one consumes it.
 void mouseClicked(MouseEvent me)
          Pass events to all modes in order, until one consumes it.
 void mouseDragged(MouseEvent me)
          Pass events to all modes in order, until one consumes it.
 void mouseEntered(MouseEvent me)
          Pass events to all modes in order, until one consumes it.
 void mouseExited(MouseEvent me)
          Pass events to all modes in order, until one consumes it.
 void mouseMoved(MouseEvent me)
          Pass events to all modes in order, until one consumes it.
 void mousePressed(MouseEvent me)
          Pass events to all modes in order, until one consumes it.
 void mouseReleased(MouseEvent me)
          Pass events to all modes in order, until one consumes it.
 void paint(Graphics g)
          Paint each mode in the stack: bottom to top.
 Mode pop()
          Remove the topmost Mode iff it can exit.
 void popAll()
          Remove all Modes that can exit.
 void push(Mode newMode)
          Add the given Mode to the stack iff another instance of the same class is not already on the stack.
 void removeModeChangeListener(ModeChangeListener listener)
           
 void setEditor(Editor w)
          Set the parent Editor of this ModeManager
 void setModes(Vector newModes)
          Set the entire stack of Mode's.
 Mode top()
          Reply the top (first) Mode.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_editor

public Editor _editor
The Editor that owns this ModeManager.

_listeners

protected EventListenerList _listeners
Constructor Detail

ModeManager

public ModeManager(Editor ed)
Construct a ModeManager with no modes.
Method Detail

setEditor

public void setEditor(Editor w)
Set the parent Editor of this ModeManager

getEditor

public Editor getEditor()
Get the parent Editor of this ModeManager

getModes

public Vector getModes()
Reply the stack of Mode's.

setModes

public void setModes(Vector newModes)
Set the entire stack of Mode's.

top

public Mode top()
Reply the top (first) Mode.

push

public void push(Mode newMode)
Add the given Mode to the stack iff another instance of the same class is not already on the stack.

pop

public Mode pop()
Remove the topmost Mode iff it can exit.

popAll

public void popAll()
Remove all Modes that can exit.

includes

public boolean includes(Class modeClass)

keyTyped

public void keyTyped(KeyEvent ke)
Pass events to all modes in order, until one consumes it.
Specified by:
keyTyped in interface KeyListener

keyReleased

public void keyReleased(KeyEvent ke)
Do nothing, this event are not passed to the Modes.
Specified by:
keyReleased in interface KeyListener

keyPressed

public void keyPressed(KeyEvent ke)
Pass events to all modes in order, until one consumes it.
Specified by:
keyPressed in interface KeyListener

mouseMoved

public void mouseMoved(MouseEvent me)
Pass events to all modes in order, until one consumes it.
Specified by:
mouseMoved in interface MouseMotionListener

mouseDragged

public void mouseDragged(MouseEvent me)
Pass events to all modes in order, until one consumes it.
Specified by:
mouseDragged in interface MouseMotionListener

mouseClicked

public void mouseClicked(MouseEvent me)
Pass events to all modes in order, until one consumes it.
Specified by:
mouseClicked in interface MouseListener

mousePressed

public void mousePressed(MouseEvent me)
Pass events to all modes in order, until one consumes it.
Specified by:
mousePressed in interface MouseListener

mouseReleased

public void mouseReleased(MouseEvent me)
Pass events to all modes in order, until one consumes it.
Specified by:
mouseReleased in interface MouseListener

mouseEntered

public void mouseEntered(MouseEvent me)
Pass events to all modes in order, until one consumes it.
Specified by:
mouseEntered in interface MouseListener

mouseExited

public void mouseExited(MouseEvent me)
Pass events to all modes in order, until one consumes it.
Specified by:
mouseExited in interface MouseListener

checkModeTransitions

public void checkModeTransitions(InputEvent ie)
Check for events that should cause transitions from one Mode to another or otherwise change the ModeManager. Really this should be specified in a subclass of ModeManager, because ModeManager should not make assumptions about the look-and-feel of all future applications. Needs-More-Work: I would like to put the transition from ModeSelect to ModeModify here, but there are too many interactions, so that code is still in ModeSelect.

addModeChangeListener

public void addModeChangeListener(ModeChangeListener listener)

removeModeChangeListener

public void removeModeChangeListener(ModeChangeListener listener)

fireModeChanged

protected void fireModeChanged()

paint

public void paint(Graphics g)
Paint each mode in the stack: bottom to top.