de.matthiasmann.twl.model
Class SimpleButtonModel

java.lang.Object
  extended by de.matthiasmann.twl.model.SimpleButtonModel
All Implemented Interfaces:
ButtonModel
Direct Known Subclasses:
ToggleButtonModel

public class SimpleButtonModel
extends java.lang.Object
implements ButtonModel

A simple button model. Supported state bit: hover, armed, pressed.


Field Summary
protected  java.lang.Runnable[] actionCallbacks
           
protected  int state
           
protected static int STATE_MASK_ARMED
           
protected static int STATE_MASK_DISABLED
           
protected static int STATE_MASK_HOVER
           
protected static int STATE_MASK_PRESSED
           
protected  java.lang.Runnable[] stateCallbacks
           
 
Constructor Summary
SimpleButtonModel()
           
 
Method Summary
 void addActionCallback(java.lang.Runnable callback)
           
 void addStateCallback(java.lang.Runnable callback)
           
protected  void buttonAction()
           
 void connect()
          Called when the Button is placed in the GUI tree.
 void disconnect()
          Called when the Button is no longer part of the GUI tree.
 void fireActionCallback()
           
protected  void fireStateCallback()
           
 boolean hasActionCallbacks()
           
 boolean isArmed()
           
 boolean isEnabled()
           
 boolean isHover()
           
 boolean isPressed()
           
 boolean isSelected()
           
 void removeActionCallback(java.lang.Runnable callback)
           
 void removeStateCallback(java.lang.Runnable callback)
           
 void setArmed(boolean armed)
           
 void setEnabled(boolean enabled)
           
 void setHover(boolean hover)
           
 void setPressed(boolean pressed)
           
 void setSelected(boolean selected)
           
protected  void setStateBit(int mask, boolean set)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

STATE_MASK_HOVER

protected static final int STATE_MASK_HOVER
See Also:
Constant Field Values

STATE_MASK_PRESSED

protected static final int STATE_MASK_PRESSED
See Also:
Constant Field Values

STATE_MASK_ARMED

protected static final int STATE_MASK_ARMED
See Also:
Constant Field Values

STATE_MASK_DISABLED

protected static final int STATE_MASK_DISABLED
See Also:
Constant Field Values

actionCallbacks

protected java.lang.Runnable[] actionCallbacks

stateCallbacks

protected java.lang.Runnable[] stateCallbacks

state

protected int state
Constructor Detail

SimpleButtonModel

public SimpleButtonModel()
Method Detail

isSelected

public boolean isSelected()
Specified by:
isSelected in interface ButtonModel

isPressed

public boolean isPressed()
Specified by:
isPressed in interface ButtonModel

isArmed

public boolean isArmed()
Specified by:
isArmed in interface ButtonModel

isHover

public boolean isHover()
Specified by:
isHover in interface ButtonModel

isEnabled

public boolean isEnabled()
Specified by:
isEnabled in interface ButtonModel

setSelected

public void setSelected(boolean selected)
Specified by:
setSelected in interface ButtonModel

setPressed

public void setPressed(boolean pressed)
Specified by:
setPressed in interface ButtonModel

setArmed

public void setArmed(boolean armed)
Specified by:
setArmed in interface ButtonModel

setHover

public void setHover(boolean hover)
Specified by:
setHover in interface ButtonModel

setEnabled

public void setEnabled(boolean enabled)
Specified by:
setEnabled in interface ButtonModel

buttonAction

protected void buttonAction()

setStateBit

protected void setStateBit(int mask,
                           boolean set)

fireStateCallback

protected void fireStateCallback()

fireActionCallback

public void fireActionCallback()
Specified by:
fireActionCallback in interface ButtonModel

addActionCallback

public void addActionCallback(java.lang.Runnable callback)
Specified by:
addActionCallback in interface ButtonModel

removeActionCallback

public void removeActionCallback(java.lang.Runnable callback)
Specified by:
removeActionCallback in interface ButtonModel

hasActionCallbacks

public boolean hasActionCallbacks()
Specified by:
hasActionCallbacks in interface ButtonModel

addStateCallback

public void addStateCallback(java.lang.Runnable callback)
Specified by:
addStateCallback in interface ButtonModel

removeStateCallback

public void removeStateCallback(java.lang.Runnable callback)
Specified by:
removeStateCallback in interface ButtonModel

connect

public void connect()
Description copied from interface: ButtonModel
Called when the Button is placed in the GUI tree. Callbacks to other models should only be installed after this call.

Specified by:
connect in interface ButtonModel

disconnect

public void disconnect()
Description copied from interface: ButtonModel
Called when the Button is no longer part of the GUI tree. Callbacks to other models should be removed.

Specified by:
disconnect in interface ButtonModel