org.tigris.gef.base
Class ModeImpl

java.lang.Object
  extended by org.tigris.gef.base.ModeImpl
All Implemented Interfaces:
java.awt.event.KeyListener, java.awt.event.MouseListener, java.awt.event.MouseMotionListener, java.io.Serializable, java.util.EventListener, Mode
Direct Known Subclasses:
FigModifyingModeImpl

public class ModeImpl
extends java.lang.Object
implements Mode, java.io.Serializable, java.awt.event.KeyListener, java.awt.event.MouseListener, java.awt.event.MouseMotionListener

This is the default implementation for the basic interface of all modes. It provides basic functionality for initializing the mode and handling its parameters. All of the methods can be overwritten, but this is not always necessary.

See Also:
Mode, FigModifyingModeImpl, Serialized Form

Field Summary
protected  java.util.Hashtable _args
          Arguments to this mode.
 
Constructor Summary
ModeImpl()
          Construct a new ModeImpl instance without any parameters.
ModeImpl(java.util.Hashtable parameters)
          Construct a new Mode instance with the given parameters as its initial parameters
 
Method Summary
 boolean canExit()
          Some Mode's should never be exited, but by default any Mode can exit.
 void done()
          When a Mode handles a certain event that indicates that the user wants to exit that Mode (e.g., a mouse up event after a drag in ModeCreateEdge) the Mode calls done to make switching to another Mode possible.
 java.lang.Object getArg(java.lang.String s)
           
 java.util.Hashtable getArgs()
           
 void init(java.util.Hashtable parameters)
          Modes may need some parameters in order to work properly.
 void keyPressed(java.awt.event.KeyEvent ke)
           
 void keyReleased(java.awt.event.KeyEvent ke)
           
 void keyTyped(java.awt.event.KeyEvent ke)
           
 void leave()
          Modes can be finished before completed for some reasons.
 void mouseClicked(java.awt.event.MouseEvent me)
           
 void mouseDragged(java.awt.event.MouseEvent me)
           
 void mouseEntered(java.awt.event.MouseEvent me)
           
 void mouseExited(java.awt.event.MouseEvent me)
           
 void mouseMoved(java.awt.event.MouseEvent me)
           
 void mousePressed(java.awt.event.MouseEvent me)
           
 void mouseReleased(java.awt.event.MouseEvent me)
           
 void setArg(java.lang.String key, java.lang.Object value)
           
 void setArgs(java.util.Hashtable args)
           
 void start()
          When the user performs the first AWT Event that indicate that they want to do some work in this mode, then change the global next mode.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_args

protected java.util.Hashtable _args
Arguments to this mode. These are usually set just after the mode is created via the init method and used later.

Constructor Detail

ModeImpl

public ModeImpl(java.util.Hashtable parameters)
Construct a new Mode instance with the given parameters as its initial parameters


ModeImpl

public ModeImpl()
Construct a new ModeImpl instance without any parameters. This constructor is needed because some Cmd-Classes can only call Class.newInstance which does not pass constructor arguments.

See Also:
CmdSetMode
Method Detail

setArgs

public void setArgs(java.util.Hashtable args)
Specified by:
setArgs in interface Mode

setArg

public void setArg(java.lang.String key,
                   java.lang.Object value)
Specified by:
setArg in interface Mode

getArgs

public java.util.Hashtable getArgs()
Specified by:
getArgs in interface Mode

getArg

public java.lang.Object getArg(java.lang.String s)
Specified by:
getArg in interface Mode

done

public void done()
When a Mode handles a certain event that indicates that the user wants to exit that Mode (e.g., a mouse up event after a drag in ModeCreateEdge) the Mode calls done to make switching to another Mode possible.

Specified by:
done in interface Mode

start

public void start()
When the user performs the first AWT Event that indicate that they want to do some work in this mode, then change the global next mode.

Specified by:
start in interface Mode

canExit

public boolean canExit()
Some Mode's should never be exited, but by default any Mode can exit. Mode's which return false for canExit() will not be popped from a ModeManager.

Specified by:
canExit in interface Mode
See Also:
ModeManager

init

public void init(java.util.Hashtable parameters)
Modes may need some parameters in order to work properly. With this method, a Mode can be inititalized with a unspecified number of parameters. Call this method first, before using a Mode.

Specified by:
init in interface Mode

leave

public void leave()
Modes can be finished before completed for some reasons. This method lets the mode be finished from any state it is in.


keyPressed

public void keyPressed(java.awt.event.KeyEvent ke)
Specified by:
keyPressed in interface java.awt.event.KeyListener

keyReleased

public void keyReleased(java.awt.event.KeyEvent ke)
Specified by:
keyReleased in interface java.awt.event.KeyListener

keyTyped

public void keyTyped(java.awt.event.KeyEvent ke)
Specified by:
keyTyped in interface java.awt.event.KeyListener

mouseMoved

public void mouseMoved(java.awt.event.MouseEvent me)
Specified by:
mouseMoved in interface java.awt.event.MouseMotionListener

mouseDragged

public void mouseDragged(java.awt.event.MouseEvent me)
Specified by:
mouseDragged in interface java.awt.event.MouseMotionListener

mouseClicked

public void mouseClicked(java.awt.event.MouseEvent me)
Specified by:
mouseClicked in interface java.awt.event.MouseListener

mousePressed

public void mousePressed(java.awt.event.MouseEvent me)
Specified by:
mousePressed in interface java.awt.event.MouseListener

mouseReleased

public void mouseReleased(java.awt.event.MouseEvent me)
Specified by:
mouseReleased in interface java.awt.event.MouseListener

mouseExited

public void mouseExited(java.awt.event.MouseEvent me)
Specified by:
mouseExited in interface java.awt.event.MouseListener

mouseEntered

public void mouseEntered(java.awt.event.MouseEvent me)
Specified by:
mouseEntered in interface java.awt.event.MouseListener