controlP5
Class Matrix

java.lang.Object
  extended by controlP5.Controller
      extended by controlP5.Matrix
All Implemented Interfaces:
CDrawable, ControllerInterface, ControlP5Constants

public class Matrix
extends Controller

a matrix is a 2d array with one pointer that traverses through the matrix with a timed interval. if an item of a matrix-column is active, the x and y position of the corresponding cell will trigger an event. see the example for more information. TODO add multi-cells access to the vertical axis

+Example
/**
 * ControlP5 Matrix
 * click into the blue box, the matrix, to activate and deactivate
 * cells of the matrix. A matrix can be used for example
 * a sequencer, a drum machine.
 *
 * by andreas schlegel, 2009
 */
import controlP5.*;

ControlP5 controlP5;

int myColorBackground = color(0,0,0);

void setup() {
  size(600,400);
  frameRate(30);
  controlP5 = new ControlP5(this);
  controlP5.addMatrix("someMatrix", 20, 20, 10, 10, 400, 300);
}

void draw() {
  background(myColorBackground);
}


void keyPressed() {
  controlP5.controller("someMatrix").setValue(256);
}

void controlEvent(ControlEvent theEvent) {
  println("## controlEvent / id:"+theEvent.controller().id()+"\n"+
      "name:"+theEvent.controller().name()+"\n"+
      "label:"+theEvent.controller().label()+"\n"+
      "value:"+theEvent.controller().value()+"\n"+
      "matrixValue x:"+Matrix.getX(theEvent.controller().value())+"\n"+
      "matrixValue y:"+Matrix.getY(theEvent.controller().value())+"\n"      
      );
}

Field Summary
 
Fields inherited from interface controlP5.ControlP5Constants
acceptClassList, ACTIVE, ALT, ARC, ARRAY, BACKSPACE, BOOLEAN, BOTTOM, CENTER, CONTROL, controlEventClass, CUSTOM, DECREASE, DEFAULT, DELETE, DOWN, ELLIPSE, ENTER, ESCAPE, EVENT, eventMethod, FIELD, FLOAT, HALF_PI, HIDE, HIGHLIGHT, HORIZONTAL, IMAGE, INCREASE, INTEGER, INVALID, KEYCONTROL, LEFT, LINE, LOAD, MENU, METHOD, MOVE, OVER, PI, PRESSED, PRINT, RELEASE, RESET, RIGHT, SAVE, SHIFT, SPRITE, STRING, SWITCH, SWITCH_BACK, SWITCH_FORE, TAB, TOP, TWO_PI, UP, VERBOSE, VERTICAL
 
Constructor Summary
Matrix(ControlP5 theControlP5, ControllerGroup theParent, java.lang.String theName, int theCellX, int theCellY, int theX, int theY, int theWidth, int theHeight)
           
 
Method Summary
 void addToXMLElement(ControlP5XMLElement theElement)
           
 int getInterval()
           
static int getX(float thePosition)
           
static int getX(int thePosition)
           
static int getY(float thePosition)
           
static int getY(int thePosition)
           
 void mousePressed()
           
 void mouseReleased()
           
 void set(int theX, int theY, boolean theValue)
          set the state of a particular cell in a matrix.
 void setInterval(int theInterval)
          set the speed of intervals in millis iterating through the matrix.
 void setValue(float theValue)
          set the value of the controller.
 void update()
          updates the value of the controller without having to set the value explicitly.
 void updateDisplayMode(int theMode)
           
 void updateInternalEvents(processing.core.PApplet theApplet)
          TODO
 
Methods inherited from class controlP5.Controller
absolutePosition, add, addListener, arrayValue, behavior, captionLabel, changeValue, color, continuousUpdateEvents, controlWindow, defaultValue, disableSprite, draw, enableSprite, getAsXML, getColor, getHeight, getPickingColor, getSprite, getTab, getWidth, getWindow, hide, id, init, isBroadcast, isInside, isLock, isMousePressed, isMoveable, isUpdate, isUserInteraction, isVisible, isXMLsavable, keyEvent, label, linebreak, listenerSize, lock, max, min, moveTo, moveTo, moveTo, moveTo, moveTo, moveTo, moveTo, moveTo, moveTo, name, parent, plugTo, plugTo, position, remove, remove, removeBehavior, removeListener, setArrayValue, setBehavior, setBroadcast, setCaptionLabel, setColor, setColorActive, setColorBackground, setColorCaptionLabel, setColorForeground, setColorLabel, setColorValue, setColorValueLabel, setDecimalPrecision, setDefaultValue, setDisplay, setDisplay, setGroup, setGroup, setHeight, setId, setImage, setImage, setImages, setImages, setLabel, setLabelVisible, setLock, setMax, setMin, setMousePressed, setMoveable, setParent, setPosition, setSize, setSize, setSprite, setTab, setTab, setUpdate, setUserInteraction, setValueLabel, setVisible, setWidth, setWindow, setWindow, show, stringValue, toString, trigger, unlock, unplugFrom, unplugFrom, updateAbsolutePosition, updateEvents, updateSize, value, valueLabel
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Matrix

public Matrix(ControlP5 theControlP5,
              ControllerGroup theParent,
              java.lang.String theName,
              int theCellX,
              int theCellY,
              int theX,
              int theY,
              int theWidth,
              int theHeight)
Method Detail

setInterval

public void setInterval(int theInterval)
set the speed of intervals in millis iterating through the matrix.

Parameters:
theInterval - int

getInterval

public int getInterval()

updateInternalEvents

public void updateInternalEvents(processing.core.PApplet theApplet)
Description copied from class: Controller
TODO

Specified by:
updateInternalEvents in interface ControllerInterface
Overrides:
updateInternalEvents in class Controller
See Also:
ControllerInterfalce.updateInternalEvents

mousePressed

public void mousePressed()

mouseReleased

public void mouseReleased()

setValue

public void setValue(float theValue)
Description copied from class: Controller
set the value of the controller.

Specified by:
setValue in class Controller
Parameters:
theValue - float

update

public void update()
Description copied from class: Controller
updates the value of the controller without having to set the value explicitly. update does not visually update the controller. the updating status can be set with setUpdate(true/false) and checked with isUpdate(). setUpdate ( )

Specified by:
update in interface ControllerInterface
Overrides:
update in class Controller

set

public void set(int theX,
                int theY,
                boolean theValue)
set the state of a particular cell in a matrix. use true or false for parameter theValue

Parameters:
theX -
theY -
theValue -

getX

public static int getX(int thePosition)

getY

public static int getY(int thePosition)

getX

public static int getX(float thePosition)

getY

public static int getY(float thePosition)

addToXMLElement

public void addToXMLElement(ControlP5XMLElement theElement)
Parameters:
theElement - ControlP5XMLElement

updateDisplayMode

public void updateDisplayMode(int theMode)


processing library controlP5 by Andreas Schlegel. (c) 2010