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 a pointer that traverses through the matrix in 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 and notify the program. see the ControlP5matrix example for more information.

+Example
/**
* ControlP5 Matrix
*
* A matrix can be used for example as a sequencer, a drum machine.
*
* find a list of public methods available for the Matrix Controller
* at the bottom of this sketch.
*
* by Andreas Schlegel, 2012
* www.sojamo.de/libraries/controlp5
*
*/

import controlP5.*;

ControlP5 cp5;

Dong[][] d;
int nx = 10;
int ny = 10;

void setup() {
  size(700, 400);
  
  cp5 = new ControlP5(this);
  
  cp5.addMatrix("myMatrix")
     .setPosition(50, 100)
     .setSize(200, 200)
     .setGrid(nx, ny)
     .setGap(10, 1)
     .setInterval(200)
     .setMode(ControlP5.MULTIPLES)
     ;
  
  // use setMode to change the cell-activation which by 
  // default is ControlP5.SINGLE_ROW, 1 active cell per row, 
  // but can be changed to ControlP5.SINGLE_COLUMN or 
  // ControlP5.MULTIPLES
  
  d = new Dong[nx][ny];
  for(int x = 0;x

Field Summary
 
Fields inherited from class controlP5.Controller
autoHeight, autoSpacing, autoWidth
 
Fields inherited from interface controlP5.ControlP5Constants
acceptClassList, ACTION_BROADCAST, ACTION_ENTER, ACTION_LEAVE, ACTION_PRESSED, ACTION_RELEASED, ACTION_RELEASEDOUTSIDE, ACTIVE, ALL, ALT, ARC, ARRAY, BACKSPACE, BASELINE, BITFONT, BOOLEAN, BOTTOM, BOTTOM_OUTSIDE, CAPTIONLABEL, CENTER, COMMANDKEY, CONTROL, controlEventClass, CUSTOM, DECREASE, DEFAULT, DELETE, DONE, DOWN, ELLIPSE, ENTER, ESCAPE, EVENT, eventMethod, FADEIN, FADEOUT, FIELD, FLOAT, HALF_PI, HIDE, HIGHLIGHT, HORIZONTAL, IDLE, IMAGE, INACTIVE, INCREASE, INTEGER, INVALID, KEYCONTROL, LEFT, LEFT_OUTSIDE, LINE, LOAD, MENU, METHOD, MOVE, MULTIPLES, OVER, PI, PRESSED, PRINT, RELEASE, RESET, RIGHT, RIGHT_OUTSIDE, SAVE, SHIFT, SINGLE, SINGLE_COLUMN, SINGLE_ROW, SPRITE, STRING, SWITCH, SWITCH_BACK, SWITCH_FORE, TAB, TOP, TOP_OUTSIDE, TRANSITION_WAIT_FADEIN, TWO_PI, UP, VALUELABEL, VERBOSE, VERTICAL, WAIT
 
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
 Matrix clear()
           
 boolean get(int theX, int theY)
           
 int[][] getCells()
           
 int getInterval()
           
 int getMode()
           
static int getX(float thePosition)
           
static int getX(int thePosition)
           
static int getY(float thePosition)
           
static int getY(int thePosition)
           
 void mousePressed()
           
 void mouseReleased()
           
 Matrix plugTo(java.lang.Object theObject)
           
 Matrix plugTo(java.lang.Object theObject, java.lang.String thePlugName)
           
 void remove()
          removes a controller from controlP5.
 Matrix set(int theX, int theY, boolean theValue)
          set the state of a particular cell inside a matrix.
 Matrix setCells(int[][] theCells)
           
 Matrix setGap(int theX, int theY)
           
 Matrix setGrid(int theCellX, int theCellY)
           
 Matrix setInterval(int theInterval)
          set the speed of intervals in millis iterating through the matrix.
 Matrix setMode(int theMode)
          use setMode to change the cell-activation which by default is ControlP5.SINGLE_ROW, 1 active cell per row, but can be changed to ControlP5.SINGLE_COLUMN or ControlP5.MULTIPLES
 Matrix setValue(float theValue)
           
 Matrix update()
          updates the value of the controller without having to set the value explicitly.
 Matrix updateDisplayMode(int theMode)
           
 Matrix updateInternalEvents(processing.core.PApplet theApplet)
          a method for putting input events like e.g.
 
Methods inherited from class controlP5.Controller
add, addCallback, addListener, align, bringToFront, bringToFront, changeValue, getAbsolutePosition, getAddress, getArrayValue, getArrayValue, getBehavior, getCaptionLabel, getColor, getControllerPlugList, getControlWindow, getDecimalPrecision, getDefaultValue, getHeight, getId, getLabel, getMax, getMin, getName, getParent, getPickingColor, getPosition, getProperty, getProperty, getStringValue, getTab, getValue, getValueLabel, getWidth, getWindow, hide, init, isActive, isBroadcast, isInside, isLabelVisible, isListening, isLock, isMouseOver, isMousePressed, isMoveable, isUpdate, isVisible, keyEvent, linebreak, listen, listenerSize, lock, moveTo, moveTo, moveTo, moveTo, moveTo, moveTo, moveTo, moveTo, moveTo, plugTo, plugTo, registerProperty, registerProperty, registerTooltip, remove, removeBehavior, removeCallback, removeCallback, removeListener, removeProperty, removeProperty, setAbsolutePosition, setAddress, setArrayValue, setArrayValue, setBehavior, setBroadcast, setCaptionLabel, setColor, setColorActive, setColorBackground, setColorCaptionLabel, setColorForeground, setColorValueLabel, setDecimalPrecision, setDefaultValue, setGroup, setGroup, setHeight, setId, setImage, setImage, setImages, setImages, setImages, setLabelVisible, setLock, setMax, setMin, setMouseOver, setMousePressed, setMoveable, setParent, setPosition, setPosition, setSize, setSize, setStringValue, setTab, setTab, setUpdate, setValueLabel, setView, setView, setVisible, setWidth, show, unlock, unplugFrom, unplugFrom, unregisterTooltip, updateAbsolutePosition, updateEvents, updateSize
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface controlP5.ControllerInterface
continuousUpdateEvents, draw, parent, setColorLabel, setColorValue, setLabel
 
Methods inherited from interface controlP5.CDrawable
draw
 

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

clear

public Matrix clear()

get

public boolean get(int theX,
                   int theY)

getCells

public int[][] getCells()

getInterval

public int getInterval()

getMode

public int getMode()

getX

public static int getX(float thePosition)

getX

public static int getX(int thePosition)

getY

public static int getY(float thePosition)

getY

public static int getY(int thePosition)

mousePressed

public void mousePressed()

mouseReleased

public void mouseReleased()

plugTo

public Matrix plugTo(java.lang.Object theObject)
Overrides:
plugTo in class Controller
Returns:
Controller

plugTo

public Matrix plugTo(java.lang.Object theObject,
                     java.lang.String thePlugName)
Overrides:
plugTo in class Controller

remove

public void remove()
Description copied from class: Controller
removes a controller from controlP5.

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

set

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

Parameters:
theX -
theY -
theValue -
Returns:
Matrix

setCells

public Matrix setCells(int[][] theCells)

setGap

public Matrix setGap(int theX,
                     int theY)

setGrid

public Matrix setGrid(int theCellX,
                      int theCellY)

setInterval

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

Parameters:
theInterval - int
Returns:
Matrix

setMode

public Matrix setMode(int theMode)
use setMode to change the cell-activation which by default is ControlP5.SINGLE_ROW, 1 active cell per row, but can be changed to ControlP5.SINGLE_COLUMN or ControlP5.MULTIPLES

Parameters:
theMode - return Matrix

setValue

public Matrix setValue(float theValue)
Specified by:
setValue in interface ControllerInterface
Specified by:
setValue in class Controller
Parameters:
theValue - float

update

public Matrix 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().

Specified by:
update in interface ControllerInterface
Overrides:
update in class Controller
Returns:
Controller
See Also:
Controller.setUpdate(boolean), Controller.isUpdate()

updateDisplayMode

public Matrix updateDisplayMode(int theMode)

updateInternalEvents

public Matrix updateInternalEvents(processing.core.PApplet theApplet)
Description copied from interface: ControllerInterface
a method for putting input events like e.g. mouse or keyboard events and queries. this has been taken out of the draw method for better overwriting capability.

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


processing library controlP5 by Andreas Schlegel. (c) 2012