sky.monome
Class LedButtonCouple

java.lang.Object
  extended by sky.monome.Component
      extended by sky.monome.LedButtonCouple
All Implemented Interfaces:
ButtonManager<LedButtonCouple>
Direct Known Subclasses:
Pad.PadGroup.Lure

public class LedButtonCouple
extends Component
implements ButtonManager<LedButtonCouple>

Couple of a led and a button on the Monome device.

Author:
PJ Skyman

Nested Class Summary
static class LedButtonCouple.ButtonState
          Button state.
static class LedButtonCouple.LedState
          Led state.
 
Field Summary
protected  Behavior behavior
          Behavior of this led.
protected  LedButtonCouple.ButtonState buttonState
          State of this button.
protected  LedButtonCouple.LedState ledState
          State of this led.
protected  LedStateModificationLayer ledStateModificationLayer
          Modification layer for the led state of this led.
 
Fields inherited from class sky.monome.Component
container, eventListenerList, lockObject, name, x, y
 
Constructor Summary
LedButtonCouple(java.lang.String name, Container container, int x, int y)
          Deprecated. Since SkyMonome v1.2, all components register themselves inside their container, so you don't need to specify the container by calling this constructor.
LedButtonCouple(java.lang.String name, Container container, int x, int y, Behavior behavior)
          Deprecated. Since SkyMonome v1.2, all components register themselves inside their container, so you don't need to specify the container by calling this constructor.
LedButtonCouple(java.lang.String name, Container container, int x, int y, BehaviorFactory behaviorFactory)
          Deprecated. Since SkyMonome v1.2, all components register themselves inside their container, so you don't need to specify the container by calling this constructor.
LedButtonCouple(java.lang.String name, int x, int y)
          Constructs a led/button couple with the specified name and specified coordinates.
LedButtonCouple(java.lang.String name, int x, int y, Behavior behavior)
          Constructs a led/button couple with the specified name, specified coordinates and the specified behavior.
LedButtonCouple(java.lang.String name, int x, int y, BehaviorFactory behaviorFactory)
          Constructs a led/button couple with the specified name, specified coordinates and the specified behavior factory.
 
Method Summary
 void addButtonListener(ButtonListener<LedButtonCouple> buttonListener)
          Adds the specified listener to the listeners list of this button.
 boolean canHaveParentContainer()
          Indicates whether this led/button couple can have a parent container in the Monome assembling tree.
 void doClick()
          Programmatically does a click on this led/button couple.
 void fireButtonActionned(LedButtonCouple buttonManager, ButtonEvent.ButtonAction buttonAction)
          Notifies all the listeners that a new button action occured.
 int getAbsoluteX()
          Returns the absolute X-coordinate of this led/button couple.
 int getAbsoluteY()
          Returns the absolute Y-coordinate of this led/button couple.
 Behavior getBehavior()
          Returns the behavior of this led.
 java.awt.Rectangle getBounds()
          Returns the bounds of this led/button couple in the local context of its container.
 ButtonListener<LedButtonCouple>[] getButtonListeners()
          Returns an array of all listeners contained in the listeners list of this button.
 LedButtonCouple.ButtonState getButtonState()
          Returns the state of this button.
 LedButtonCouple.LedState getLedState()
          Returns the state of this led.
 Monome getMonome()
          Returns the logical Monome device that contains this led/button couple.
 void initLedState(boolean ledState)
          Initializes the state of this led.
 boolean isVisible()
          Indicates whether this led/button couple is actually visible.
 void notify(OSCMessageDigester messageDigester)
          Notifies this led/button couple that a message comes from the Monome device.
 void removeButtonListener(ButtonListener<LedButtonCouple> buttonListener)
          Removes the specified listener from the listeners list of this button.
protected  void setButtonState(LedButtonCouple.ButtonState buttonState)
          Modifies the state of this button.
 void setLedState(LedButtonCouple.LedState ledState, boolean mustRefresh)
          Modifies the state of this led.
 java.lang.String toString()
          Returns a string representation of this led/button couple.
 void writeOn(Frame frame)
          Writes this led on the specified frame in order to refresh the Monome device.
 
Methods inherited from class sky.monome.Component
getContainer, getLockObject, getName, getX, getY
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

buttonState

protected LedButtonCouple.ButtonState buttonState
State of this button.


ledState

protected LedButtonCouple.LedState ledState
State of this led.


behavior

protected final Behavior behavior
Behavior of this led.


ledStateModificationLayer

protected LedStateModificationLayer ledStateModificationLayer
Modification layer for the led state of this led.

Constructor Detail

LedButtonCouple

@Deprecated
public LedButtonCouple(java.lang.String name,
                                  Container container,
                                  int x,
                                  int y)
                throws MonomeException
Deprecated. Since SkyMonome v1.2, all components register themselves inside their container, so you don't need to specify the container by calling this constructor.

Constructs a led/button couple with the specified name and specified coordinates and contained by the specified container. The default LightOnPush behavior is used.

Parameters:
name - Name of this led/button couple.
container - Container which contains this led/button couple.
x - X-coordinate of this led/button couple in the local context of its container.
y - Y-coordinate of this led/button couple in the local context of its container.
Throws:
MonomeException - When the led/button couple can't initialize itself.

LedButtonCouple

public LedButtonCouple(java.lang.String name,
                       int x,
                       int y)
                throws MonomeException
Constructs a led/button couple with the specified name and specified coordinates. The default LightOnPush behavior is used.

Parameters:
name - Name of this led/button couple.
x - X-coordinate of this led/button couple in the local context of its container.
y - Y-coordinate of this led/button couple in the local context of its container.
Throws:
MonomeException - When the led/button couple can't initialize itself.
Since:
SkyMonome v1.2

LedButtonCouple

@Deprecated
public LedButtonCouple(java.lang.String name,
                                  Container container,
                                  int x,
                                  int y,
                                  Behavior behavior)
                throws MonomeException
Deprecated. Since SkyMonome v1.2, all components register themselves inside their container, so you don't need to specify the container by calling this constructor.

Constructs a led/button couple with the specified name, specified coordinates and the specified behavior and contained by the specified container.

Parameters:
name - Name of this led/button couple.
container - Container which contains this led/button couple.
x - X-coordinate of this led/button couple in the local context of its container.
y - Y-coordinate of this led/button couple in the local context of its container.
behavior - Behavior of this led.
Throws:
MonomeException - When the led/button couple can't initialize itself.

LedButtonCouple

public LedButtonCouple(java.lang.String name,
                       int x,
                       int y,
                       Behavior behavior)
                throws MonomeException
Constructs a led/button couple with the specified name, specified coordinates and the specified behavior.

Parameters:
name - Name of this led/button couple.
x - X-coordinate of this led/button couple in the local context of its container.
y - Y-coordinate of this led/button couple in the local context of its container.
behavior - Behavior of this led.
Throws:
MonomeException - When the led/button couple can't initialize itself.
Since:
SkyMonome v1.2

LedButtonCouple

@Deprecated
public LedButtonCouple(java.lang.String name,
                                  Container container,
                                  int x,
                                  int y,
                                  BehaviorFactory behaviorFactory)
                throws MonomeException
Deprecated. Since SkyMonome v1.2, all components register themselves inside their container, so you don't need to specify the container by calling this constructor.

Constructs a led/button couple with the specified name, specified coordinates and the specified behavior factory and contained by the specified container.

Parameters:
name - Name of this led/button couple.
container - Container which contains this led/button couple.
x - X-coordinate of this led/button couple in the local context of its container.
y - Y-coordinate of this led/button couple in the local context of its container.
behaviorFactory - Factory for the behavior of this led.
Throws:
MonomeException - When the led/button couple can't initialize itself, or when the behavior factory can't operate successfully.
Since:
SkyMonome v1.1

LedButtonCouple

public LedButtonCouple(java.lang.String name,
                       int x,
                       int y,
                       BehaviorFactory behaviorFactory)
                throws MonomeException
Constructs a led/button couple with the specified name, specified coordinates and the specified behavior factory.

Parameters:
name - Name of this led/button couple.
x - X-coordinate of this led/button couple in the local context of its container.
y - Y-coordinate of this led/button couple in the local context of its container.
behaviorFactory - Factory for the behavior of this led.
Throws:
MonomeException - When the led/button couple can't initialize itself, or when the behavior factory can't operate successfully.
Since:
SkyMonome v1.2
Method Detail

getMonome

public Monome getMonome()
Returns the logical Monome device that contains this led/button couple. The logical Monome device is always at the top of the Monome assembling tree.

Specified by:
getMonome in class Component
Returns:
The logical Monome device that contains this led/button couple.

getBehavior

public Behavior getBehavior()
Returns the behavior of this led.

Returns:
The behavior of this led.

getLedState

public LedButtonCouple.LedState getLedState()
Returns the state of this led.

Returns:
The state of this led.

initLedState

public void initLedState(boolean ledState)
Initializes the state of this led. This method is exclusively made for use in behaviors.

Parameters:
ledState - Initial state to give to this led.

setLedState

public void setLedState(LedButtonCouple.LedState ledState,
                        boolean mustRefresh)
                 throws MonomeException
Modifies the state of this led.

Parameters:
ledState - New state to give to this led, among LedState.ON and LedState.OFF.
mustRefresh - true if the Monome device must be updated immediately, false otherwise.
Throws:
MonomeException - When the Monome device can't be updated.

getButtonState

public LedButtonCouple.ButtonState getButtonState()
Returns the state of this button.

Returns:
The state of this button.

setButtonState

protected void setButtonState(LedButtonCouple.ButtonState buttonState)
Modifies the state of this button. Warning ! Only internal listener methods must call this method. Otherwise, chaotic behaviors must appear.

Parameters:
buttonState - state New state of this button, among ButtonState.BUTTON_PUSHED and ButtonState.BUTTON_RELEASED.

addButtonListener

public void addButtonListener(ButtonListener<LedButtonCouple> buttonListener)
Adds the specified listener to the listeners list of this button.

Specified by:
addButtonListener in interface ButtonManager<LedButtonCouple>
Parameters:
buttonListener - Listener to add to the listeners list of this button.

removeButtonListener

public void removeButtonListener(ButtonListener<LedButtonCouple> buttonListener)
Removes the specified listener from the listeners list of this button.

Specified by:
removeButtonListener in interface ButtonManager<LedButtonCouple>
Parameters:
buttonListener - Listener to remove from the listeners list of this button.

getButtonListeners

public ButtonListener<LedButtonCouple>[] getButtonListeners()
Returns an array of all listeners contained in the listeners list of this button.

Specified by:
getButtonListeners in interface ButtonManager<LedButtonCouple>
Returns:
An array of all listeners contained in the listeners list of this button.

fireButtonActionned

public void fireButtonActionned(LedButtonCouple buttonManager,
                                ButtonEvent.ButtonAction buttonAction)
Notifies all the listeners that a new button action occured.

Specified by:
fireButtonActionned in interface ButtonManager<LedButtonCouple>
Parameters:
buttonManager - Button manager that triggered the button event.
buttonAction - Button action performed on the specified button manager.

notify

public void notify(OSCMessageDigester messageDigester)
            throws MonomeException
Notifies this led/button couple that a message comes from the Monome device.

Specified by:
notify in class Component
Parameters:
messageDigester - Message digester that prepares and encapsulates the message for an easy access of informations contained in the message.
Throws:
MonomeException - When a problem has occured when treating the message. By example, a led/button couple can treat a message by lighting on the led, and lighting on a led is a potentially risked operation.

doClick

public void doClick()
             throws MonomeException
Programmatically does a click on this led/button couple.

Throws:
MonomeException - Only with a few behaviors, when a led state can't be modified, by example.
Since:
SkyMonome v1.1

writeOn

public void writeOn(Frame frame)
Writes this led on the specified frame in order to refresh the Monome device. Once this frame is completed, it is sent to the Monome device.

Specified by:
writeOn in class Component
Parameters:
frame - Frame in which this led must write its led state.
See Also:
Monome.refresh()

getAbsoluteX

public int getAbsoluteX()
Returns the absolute X-coordinate of this led/button couple.

Specified by:
getAbsoluteX in class Component
Returns:
The absolute X-coordinate of this led/button couple.

getAbsoluteY

public int getAbsoluteY()
Returns the absolute Y-coordinate of this led/button couple.

Specified by:
getAbsoluteY in class Component
Returns:
The absolute Y-coordinate of this led/button couple.

isVisible

public boolean isVisible()
Indicates whether this led/button couple is actually visible.

Specified by:
isVisible in class Component
Returns:
true if this led/button couple is actually visible, false otherwise.

toString

public java.lang.String toString()
Returns a string representation of this led/button couple.

Specified by:
toString in class Component
Returns:
A string representation of this led/button couple.

canHaveParentContainer

public boolean canHaveParentContainer()
Indicates whether this led/button couple can have a parent container in the Monome assembling tree.

Specified by:
canHaveParentContainer in class Component
Returns:
Always true.

getBounds

public java.awt.Rectangle getBounds()
Returns the bounds of this led/button couple in the local context of its container.

Specified by:
getBounds in class Component
Returns:
The bounds of this led/button couple in the local context of its container.