net.jinx.action.input.robot
Class ToggleButtonControl

java.lang.Object
  extended by net.jinx.action.input.robot.AbstractControl
      extended by net.jinx.action.input.robot.ButtonControl
          extended by net.jinx.action.input.robot.ToggleButtonControl
All Implemented Interfaces:
Control

public abstract class ToggleButtonControl
extends ButtonControl

ToggleButtonControl is an extension of ButtonControl that when pressed flip-flops back and forth from on to off and back again. The act of pressing it changes it's on/off state.

API Stability: Alpha.


Field Summary
 
Fields inherited from interface net.jinx.action.input.robot.Control
TYPE_AXIS, TYPE_BUTTON, TYPE_SLIDER, TYPE_TOGGLE
 
Constructor Summary
protected ToggleButtonControl(java.lang.String name, boolean toggled)
          Constructs a new ToggleButtonControl with the given name.
 
Method Summary
 int getType()
          Overriden to return Control.TYPE_TOGGLE.
 boolean isOn()
          Returns the result of isToggled().
 boolean isToggled()
          Determines whether or not this ToggleButtonControl is currently toggled.
protected  void pressed()
          Calls toggle().
protected  void released()
          Does nothing.
 void setToggled(boolean toggled)
          Sets the state of this ToggleButtonControl.
 void toggle()
          Triggers a state change for this ToggleButtonControl.
protected abstract  void toggled()
          Called when this ToggleButtonControl has changed state.
 
Methods inherited from class net.jinx.action.input.robot.ButtonControl
isPressed, setValue, valueChange
 
Methods inherited from class net.jinx.action.input.robot.AbstractControl
getName, getValue
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ToggleButtonControl

protected ToggleButtonControl(java.lang.String name,
                              boolean toggled)
Constructs a new ToggleButtonControl with the given name.

Parameters:
name - the name to use for this Control.
toggled - the initial state.
Method Detail

isOn

public boolean isOn()
Returns the result of isToggled().

Overrides:
isOn in class ButtonControl
Returns:
true if this ToggleButtonControl is currently toggled.

setToggled

public void setToggled(boolean toggled)
Sets the state of this ToggleButtonControl. If toggled is different from the current toggle state, this will call toggled().

Parameters:
toggled - the new state.

isToggled

public boolean isToggled()
Determines whether or not this ToggleButtonControl is currently toggled.

Returns:
true if this ToggleButtonControl is currently toggled.

toggle

public void toggle()
Triggers a state change for this ToggleButtonControl.


pressed

protected void pressed()
Calls toggle().

Specified by:
pressed in class ButtonControl

released

protected void released()
Does nothing.

Specified by:
released in class ButtonControl

getType

public int getType()
Overriden to return Control.TYPE_TOGGLE.

Specified by:
getType in interface Control
Overrides:
getType in class AbstractControl
Returns:
Control.TYPE_TOGGLE.

toggled

protected abstract void toggled()
Called when this ToggleButtonControl has changed state.