sky.monome.behavior
Class Toggle


java.lang.Object

  extended by sky.monome.behavior.StaticBehavior

      extended by sky.monome.behavior.Toggle

All Implemented Interfaces:
Behavior

public class Toggle
extends StaticBehavior

Toggle behavior. This behavior change its state by pressing the button, in a bistable manner.

Author:
PJ Skyman

Nested Class Summary
static class Toggle.ToggleType
          Type of behavior.
 
Field Summary
protected  boolean on
          Indicates if the state of this behavior is actually on.
protected  Toggle.ToggleType toggleType
          Type of behavior.
 
Fields inherited from class sky.monome.behavior.StaticBehavior
ledButtonCouple
 
Constructor Summary
Toggle()
          Constructs a toggle behavior with the default type ToggleType.INITIALIZED_OFF.
Toggle(Toggle.ToggleType toggleType)
          Constructs a toggle behavior with the specified type.
 
Method Summary
 void init()
          Initializes this behavior and the registered led/button couple.
 boolean isOn()
          Indicates if this toggle is currently on.
 void notify(ButtonEvent.ButtonAction buttonAction)
          Notifies this behavior that an action on the button is performed.
 
Methods inherited from class sky.monome.behavior.StaticBehavior
getLedButtonCouple, setLedButtonCouple
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

on


protected boolean on
Indicates if the state of this behavior is actually on.


toggleType


protected final Toggle.ToggleType toggleType
Type of behavior.

Constructor Detail

Toggle


public Toggle()
Constructs a toggle behavior with the default type ToggleType.INITIALIZED_OFF.


Toggle


public Toggle(Toggle.ToggleType toggleType)
Constructs a toggle behavior with the specified type.

Parameters:
toggleType - Type of behavior to adopt.
Method Detail

notify


public void notify(ButtonEvent.ButtonAction buttonAction)

            throws MonomeException
Notifies this behavior that an action on the button is performed.

Parameters:
buttonAction - Button action that is performed.
Throws:
MonomeException - When the led state can't be modified.

isOn


public boolean isOn()
Indicates if this toggle is currently on.

Returns:
true if this toggle is currently on, false otherwise.

init


public void init()
Initializes this behavior and the registered led/button couple. Only led/button couples should call this method, and should call it only one time.