org.tigris.gef.base
Class ModeManager

java.lang.Object
  extended by org.tigris.gef.base.ModeManager
All Implemented Interfaces:
java.awt.event.KeyListener, java.awt.event.MouseListener, java.awt.event.MouseMotionListener, java.io.Serializable, java.util.EventListener

public class ModeManager
extends java.lang.Object
implements java.io.Serializable, java.awt.event.MouseListener, java.awt.event.MouseMotionListener, java.awt.event.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. The Modes must be of type FigModifyingMode, because Editor can only deal with such Modes.

See Also:
Serialized Form

Field Summary
protected  javax.swing.event.EventListenerList _listeners
           
 Editor editor
          The Editor that owns this ModeManager.
 
Constructor Summary
ModeManager(Editor ed)
          Construct a ModeManager with no modes.
 
Method Summary
 void addModeChangeListener(ModeChangeListener listener)
           
 void checkModeTransitions(java.awt.event.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
 boolean includes(java.lang.Class modeClass)
           
 void keyPressed(java.awt.event.KeyEvent ke)
          Pass events to all modes in order, until one consumes it.
 void keyReleased(java.awt.event.KeyEvent ke)
          Pass events to all modes in order, until one consumes it.
 void keyTyped(java.awt.event.KeyEvent ke)
          Pass events to all modes in order, until one consumes it.
 void leaveAll()
          Finish all modes immediately.
 void mouseClicked(java.awt.event.MouseEvent me)
          Pass events to all modes in order, until one consumes it.
 void mouseDragged(java.awt.event.MouseEvent me)
          Pass events to all modes in order, until one consumes it.
 void mouseEntered(java.awt.event.MouseEvent me)
          Pass events to all modes in order, until one consumes it.
 void mouseExited(java.awt.event.MouseEvent me)
          Pass events to all modes in order, until one consumes it.
 void mouseMoved(java.awt.event.MouseEvent me)
          Pass events to all modes in order, until one consumes it.
 void mousePressed(java.awt.event.MouseEvent me)
          Pass events to all modes in order, until one consumes it.
 void mouseReleased(java.awt.event.MouseEvent me)
          Pass events to all modes in order, until one consumes it.
 void paint(java.awt.Graphics g)
          Paint each mode in the stack: bottom to top.
 FigModifyingMode pop()
          Remove the topmost Mode if it can exit.
 void popAll()
          Remove all Modes that can exit.
 void push(FigModifyingMode newMode)
          Add the given Mode to the stack if 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
 FigModifyingMode 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 javax.swing.event.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


top

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


push

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


pop

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


popAll

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


includes

public boolean includes(java.lang.Class modeClass)

leaveAll

public void leaveAll()
Finish all modes immediately.


keyTyped

public void keyTyped(java.awt.event.KeyEvent ke)
Pass events to all modes in order, until one consumes it.

Specified by:
keyTyped in interface java.awt.event.KeyListener

keyReleased

public void keyReleased(java.awt.event.KeyEvent ke)
Pass events to all modes in order, until one consumes it.

Specified by:
keyReleased in interface java.awt.event.KeyListener

keyPressed

public void keyPressed(java.awt.event.KeyEvent ke)
Pass events to all modes in order, until one consumes it.

Specified by:
keyPressed in interface java.awt.event.KeyListener

mouseMoved

public void mouseMoved(java.awt.event.MouseEvent me)
Pass events to all modes in order, until one consumes it.

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

mouseDragged

public void mouseDragged(java.awt.event.MouseEvent me)
Pass events to all modes in order, until one consumes it.

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

mouseClicked

public void mouseClicked(java.awt.event.MouseEvent me)
Pass events to all modes in order, until one consumes it.

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

mousePressed

public void mousePressed(java.awt.event.MouseEvent me)
Pass events to all modes in order, until one consumes it.

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

mouseReleased

public void mouseReleased(java.awt.event.MouseEvent me)
Pass events to all modes in order, until one consumes it.

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

mouseEntered

public void mouseEntered(java.awt.event.MouseEvent me)
Pass events to all modes in order, until one consumes it.

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

mouseExited

public void mouseExited(java.awt.event.MouseEvent me)
Pass events to all modes in order, until one consumes it.

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

checkModeTransitions

public void checkModeTransitions(java.awt.event.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(java.awt.Graphics g)
Paint each mode in the stack: bottom to top.