com.groovemanager.gui.custom.mc909
Class Mc909Pad

java.lang.Object
  extended by com.groovemanager.gui.custom.CustomComposite
      extended by com.groovemanager.gui.custom.mc909.Mc909Pad
All Implemented Interfaces:
KeyboardKey

public class Mc909Pad
extends CustomComposite
implements KeyboardKey

A Mc909Pad is an implementation of the KeyboardKey the gives a visual representation of one pad of the Roland MC-909. It can be wrapped into a Mc909Key to have a black or white key surrounding the pad just like on the MC-909 itself.

Author:
Manu Robledo

Field Summary
static int BLACK
          Constant value for a pad being surrounded by a white key
private  boolean hold
          If this value is true, a pad has to be clicked a second time to be released. otherwise it will be released on mouse release.
private  int key
          The Key value assigned to this pad
private static int LINE_WIDTH
          Constant for the line width
private  java.util.ArrayList listeners
          The KeyboardKeyListeners registered with this pad
private  org.eclipse.swt.graphics.Color padColor
          The Color for the pad when it is not pressed
private  boolean pressed
          true, if this pad is currently pressed, false otherwise
private  org.eclipse.swt.graphics.Color pressedColor
          The Color for the pad when it is pressed
private  int type
          The type of this Pad (either BLACK or WHITE
static int WHITE
          Constant value for a pad being surrounded by a white key
 
Fields inherited from interface com.groovemanager.gui.custom.KeyboardKey
A, AIS, B, C, CIS, D, DIS, E, F, FIS, G, GIS, OCTAVE_0, OCTAVE_1, OCTAVE_2, OCTAVE_3, OCTAVE_4, OCTAVE_5, OCTAVE_6, OCTAVE_7, OCTAVE_8, OCTAVE_9, OCTAVE_MINUS_1
 
Constructor Summary
Mc909Pad(org.eclipse.swt.widgets.Composite parent, int type, int key)
          Construct a new Mc909Pad
 
Method Summary
 void addKeyListener(KeyboardKeyListener listener)
          Add a KeyListener that will be notified, when this key is pressed or released
protected  org.eclipse.swt.widgets.Composite createComposite(org.eclipse.swt.widgets.Composite parent, int style)
          This method is to be overwritten by concrete subclasses to create the real contents of this CustomComposite
 boolean getHold()
           
 int getKey()
          Get the note value represented by this key.
protected  int[] getListenerTypes()
          For all types of listeners that should be possible to add to this Composite directly, the corresponding SWT.* constant should be contained in the returned Array.
protected  int getPossibleStyles()
          Get a combination of all allowed SWT.* style constants
 boolean isPressed()
          Return whether this key is currently pressed or not
 void press()
          Press this key.
 void release()
          Release this key.y
 void removeKeyListener(KeyboardKeyListener listener)
          Remove a previously registeres KeyListener from this key
 void setHold(boolean hold)
           
 
Methods inherited from class com.groovemanager.gui.custom.CustomComposite
addListener, checkStyle, getComposite, getData, getListeners, getParent, removeListener, setData, setLayoutData
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

BLACK

public static int BLACK
Constant value for a pad being surrounded by a white key


hold

private boolean hold
If this value is true, a pad has to be clicked a second time to be released. otherwise it will be released on mouse release.


key

private final int key
The Key value assigned to this pad


LINE_WIDTH

private static final int LINE_WIDTH
Constant for the line width

See Also:
Constant Field Values

listeners

private java.util.ArrayList listeners
The KeyboardKeyListeners registered with this pad


padColor

private final org.eclipse.swt.graphics.Color padColor
The Color for the pad when it is not pressed


pressed

private boolean pressed
true, if this pad is currently pressed, false otherwise


pressedColor

private final org.eclipse.swt.graphics.Color pressedColor
The Color for the pad when it is pressed


type

private final int type
The type of this Pad (either BLACK or WHITE


WHITE

public static int WHITE
Constant value for a pad being surrounded by a white key

Constructor Detail

Mc909Pad

public Mc909Pad(org.eclipse.swt.widgets.Composite parent,
                int type,
                int key)
Construct a new Mc909Pad

Parameters:
parent - The parent Composite
type - The pad type (either BLACK or WHITE)
key - The key value assigned to this pad from 0 to 127
Method Detail

addKeyListener

public void addKeyListener(KeyboardKeyListener listener)
Description copied from interface: KeyboardKey
Add a KeyListener that will be notified, when this key is pressed or released

Specified by:
addKeyListener in interface KeyboardKey
Parameters:
listener - The KeyListener to add
See Also:
KeyboardKey.addKeyListener(com.groovemanager.gui.custom.KeyboardKeyListener)

createComposite

protected org.eclipse.swt.widgets.Composite createComposite(org.eclipse.swt.widgets.Composite parent,
                                                            int style)
Description copied from class: CustomComposite
This method is to be overwritten by concrete subclasses to create the real contents of this CustomComposite

Specified by:
createComposite in class CustomComposite
Parameters:
parent - The parent Composite under which this Composite should be created
style - Combination of valid SWT.* style constants
Returns:
The new created main composite
See Also:
CustomComposite.createComposite(org.eclipse.swt.widgets.Composite, int)

getHold

public boolean getHold()
Specified by:
getHold in interface KeyboardKey
See Also:
KeyboardKey.getHold()

getKey

public int getKey()
Description copied from interface: KeyboardKey
Get the note value represented by this key.

Specified by:
getKey in interface KeyboardKey
Returns:
The note value of this key in the range from 0 (OCTAVE_MINUS_1 + C) to 127 (OCTAVE_9 + G.
See Also:
KeyboardKey.getKey()

getListenerTypes

protected int[] getListenerTypes()
Description copied from class: CustomComposite
For all types of listeners that should be possible to add to this Composite directly, the corresponding SWT.* constant should be contained in the returned Array.

Specified by:
getListenerTypes in class CustomComposite
Returns:
An Array of SWT.* constants defining the set of listeners types applicable to this Composite
See Also:
CustomComposite.getListenerTypes()

getPossibleStyles

protected int getPossibleStyles()
Description copied from class: CustomComposite
Get a combination of all allowed SWT.* style constants

Specified by:
getPossibleStyles in class CustomComposite
Returns:
A combination of all allowed style constants, for example SWT.BORDER | SWT.LEFT | SWT.BORDER
See Also:
CustomComposite.getPossibleStyles()

isPressed

public boolean isPressed()
Description copied from interface: KeyboardKey
Return whether this key is currently pressed or not

Specified by:
isPressed in interface KeyboardKey
Returns:
true if the key has recently been pressed and since then not been released, false otherwise
See Also:
KeyboardKey.isPressed()

press

public void press()
Description copied from interface: KeyboardKey
Press this key.

Specified by:
press in interface KeyboardKey
See Also:
KeyboardKey.press()

release

public void release()
Description copied from interface: KeyboardKey
Release this key.y

Specified by:
release in interface KeyboardKey
See Also:
KeyboardKey.release()

removeKeyListener

public void removeKeyListener(KeyboardKeyListener listener)
Description copied from interface: KeyboardKey
Remove a previously registeres KeyListener from this key

Specified by:
removeKeyListener in interface KeyboardKey
Parameters:
listener - The KeyListener to remove
See Also:
KeyboardKey.removeKeyListener(com.groovemanager.gui.custom.KeyboardKeyListener)

setHold

public void setHold(boolean hold)
Specified by:
setHold in interface KeyboardKey
See Also:
KeyboardKey.setHold(boolean)