sky.monome.behavior
Class DynamicBehavior

java.lang.Object
  extended by sky.monome.behavior.DynamicBehavior
All Implemented Interfaces:
Behavior
Direct Known Subclasses:
BlinkingLight, BlinkingLightOnPush

public abstract class DynamicBehavior
extends java.lang.Object
implements Behavior

Behavior that can make animation in time, like blinking effect. All subclasses of this class should start the internal thread at the initialization by calling DynamicBehavior.startThread() method.

Author:
PJ Skyman
See Also:
Behavior.init()

Nested Class Summary
static class DynamicBehavior.DynamicBehaviorType
          Type of dynamicity.
 
Field Summary
protected  DynamicBehavior.DynamicBehaviorType dynamicBehaviorType
          Type of dynamicity.
protected  LedButtonCouple ledButtonCouple
          Registered led/button couple.
protected  java.lang.Thread thread
          Thread that is responsible for animate this behavior.
 
Constructor Summary
DynamicBehavior(DynamicBehavior.DynamicBehaviorType dynamicBehaviorType)
          Constructs a dynamic behavior with the specified type of dynamicity.
 
Method Summary
abstract  void action()
          Invoked when the behavior must execute its perpetual or one-time action.
 LedButtonCouple getLedButtonCouple()
          Returns the led/button couple registered with this behavior.
 void setLedButtonCouple(LedButtonCouple ledButtonCouple)
          Modifies the led/button couple registered with this behavior.
protected  void startThread()
          Starts the activity of this dynamic behavior.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface sky.monome.behavior.Behavior
init, notify
 

Field Detail

dynamicBehaviorType

protected final DynamicBehavior.DynamicBehaviorType dynamicBehaviorType
Type of dynamicity.


ledButtonCouple

protected LedButtonCouple ledButtonCouple
Registered led/button couple.


thread

protected final java.lang.Thread thread
Thread that is responsible for animate this behavior.

Constructor Detail

DynamicBehavior

public DynamicBehavior(DynamicBehavior.DynamicBehaviorType dynamicBehaviorType)
Constructs a dynamic behavior with the specified type of dynamicity.

Parameters:
dynamicBehaviorType - Type of dynamicity to adopt in this behavior.
Method Detail

action

public abstract void action()
                     throws java.lang.InterruptedException,
                            MonomeException
Invoked when the behavior must execute its perpetual or one-time action.

Throws:
java.lang.InterruptedException - When the virtual machine stops while a sleep operation.
MonomeException - When the action can't be executed without any error. Typically, led state modifications can raise this exception.

getLedButtonCouple

public LedButtonCouple getLedButtonCouple()
Returns the led/button couple registered with this behavior.

Specified by:
getLedButtonCouple in interface Behavior
Returns:
The led/button couple registered with this behavior.

setLedButtonCouple

public void setLedButtonCouple(LedButtonCouple ledButtonCouple)
                        throws MonomeException
Modifies the led/button couple registered with this behavior. Note that the behavior can be registered with only one led/button couple in its whole life. If you attempt to register a second led/button couple, so a MonomeException is raised.

Specified by:
setLedButtonCouple in interface Behavior
Parameters:
ledButtonCouple - New led/button couple to register with this behavior.
Throws:
MonomeException - When this behavior is already registered with a led/button couple when this method is called.

startThread

protected void startThread()
Starts the activity of this dynamic behavior.