controlP5
Class ControlP5

java.lang.Object
  extended by controlP5.ControlP5Base
      extended by controlP5.ControlP5
All Implemented Interfaces:
ControlP5Constants

public class ControlP5
extends ControlP5Base

controlP5 is a processing and java library for creating simple control GUIs.

+Example
/**
 * ControlP5basics
* The following example demonstrates the basic use of controlP5.
* After initializing controlP5 you can add controllers to controlP5. * Here we use three numberboxes, one slider and one textfield. * The numberbox with name numberboxC will trigger function numberboxC() * in the example below. Whenever controlP5 detects a function in your * sketch that corresponds to the name of a controller, it will forward * an event to that function. Any event triggered by a controller * will be forwarded to function controlEvent in your sketch.
* related examples ControlP5numberbox, ControlP5slider, ControlP5textfield
* by Andreas Schlegel 2010
* */ import controlP5.*; ControlP5 controlP5; public int myColorRect = 200; public int myColorBackground = 100; void setup() { size(400,400); frameRate(25); controlP5 = new ControlP5(this); controlP5.addNumberbox("numberboxA",myColorRect,100,140,100,14).setId(1); controlP5.addNumberbox("numberboxB",myColorBackground,100,180,100,14).setId(2); controlP5.addNumberbox("numberboxC",0,100,220,100,14).setId(3); controlP5.addSlider("sliderA",100,200,100,100,260,100,14).setId(4); controlP5.addTextfield("textA",100,290,100,20).setId(5); controlP5.controller("numberboxA").setMax(255); controlP5.controller("numberboxA").setMin(0); } void draw() { background(myColorBackground); fill(myColorRect); rect(0,0,width,100); } public void numberboxC(int theValue) { println("### got an event from numberboxC : "+theValue); } // a slider event will change the value of textfield textA public void sliderA(int theValue) { ((Textfield)controlP5.controller("textA")).setValue(""+theValue); } // for every change in textfield textA, this function will be called public void textA(String theValue) { println("### got an event from textA : "+theValue); } public void controlEvent(ControlEvent theEvent) { println("got a control event from controller with id "+theEvent.controller().id()); switch(theEvent.controller().id()) { case(1): // numberboxA myColorRect = (int)(theEvent.controller().value()); break; case(2): // numberboxB myColorBackground = (int)(theEvent.controller().value()); break; } }

Field Summary
 CColor color
           
 ControlWindow controlWindow
           
static boolean DEBUG
          use this static variable to turn DEBUG on or off.
static int grixel
           
static boolean isApplet
           
static ControlWindowKeyHandler keyHandler
           
static processing.core.PApplet papplet
           
static int standard56
           
static int standard58
           
static int synt24
           
static java.lang.String VERSION
           
 
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
ControlP5(processing.core.PApplet theParent)
          instantiate controlP5.
ControlP5(processing.core.PApplet theParent, ControlFont theControlFont)
           
 
Method Summary
 void addListener(ControlListener theListener)
           
 ControllerGroup begin()
           
 ControllerGroup begin(ControllerGroup theGroup)
           
 ControllerGroup begin(ControllerGroup theGroup, int theX, int theY)
           
 ControllerGroup begin(ControlWindow theWindow)
           
 ControllerGroup begin(ControlWindow theWindow, int theX, int theY)
           
 ControllerGroup begin(int theX, int theY)
           
 ControlBroadcaster controlbroadcaster()
           
 Controller controller(java.lang.String theName)
          get a controller by name.
 void disableKeys()
          Deprecated. use disableShortcuts()
 void disableShortcuts()
          disable shortcuts such as alt-h for hiding/showing controllers
 void dispose()
          disposes and clears all controlP5 elements.
 void draw()
           
 void enableKeys()
          Deprecated. use enableShortcuts()
 void enableShortcuts()
           
 ControllerGroup end()
           
 ControllerGroup end(ControllerGroup theGroup)
           
 java.lang.String filePath()
          get the current file path where your controlP5 setup will be save to on your local disk.
static ControlFont getControlFont()
           
 ControllerInterface[] getControllerList()
           
 ControllerGroup getGroup(java.lang.String theGroupName)
          get a group by name.
 ControlListener getListener(int theIndex)
           
 Tab getTab(ControlWindow theWindow, java.lang.String theName)
          get a tab by name from a specific controlwindow.
 Tab getTab(java.lang.String theName)
          get a tab by name.
 ControllerGroup group(java.lang.String theGroupName)
          get a group by name
 void hide()
          hide all controllers and tabs in your sketch.
 boolean isAutoDraw()
          check if the autoDraw function for the main window is enabled(true) or disabled(false).
 void isMoveable()
          check if controllers are moveable
 boolean isUpdate()
           
 boolean isVisible()
           
 boolean load(java.lang.String theFileName)
          load an xml file, containing a controlP5 setup
 void lock()
          Deprecated.  
static java.util.logging.Logger logger()
           
 void register(ControllerInterface theController)
           
 void remove(java.lang.String theString)
          remove a controlP5 element such as a controller, group, or tab by name.
 void removeListener(ControlListener theListener)
           
 boolean save()
          save controlP5 settings to your local disk or to a remote server.
 boolean save(java.lang.String theFilePath)
          save controlP5 settings to your local disk or to a remote server.
 void setAutoDraw(boolean theFlag)
          by default controlP5 draws any controller on top of any drawing done in the draw() function (this doesnt apply to P3D where controlP5.draw() has to be called manually in the sketch's draw() function ).
 void setAutoInitialization(boolean theFlag)
          autoInitialization can be very handy when it comes to initializing values, e.g.
 void setColorActive(int theColor)
          set the active state color of tabs and controllers.
 void setColorBackground(int theColor)
          set the backgorund color of tabs and controllers.
 void setColorForeground(int theColor)
          set the foreground color of tabs and controllers.
 void setColorLabel(int theColor)
          set the label color of tabs and controllers.
 void setColorValue(int theColor)
          set the value color of controllers.
 boolean setControlFont(ControlFont theControlFont)
           
 boolean setControlFont(processing.core.PFont thePFont)
           
 boolean setControlFont(processing.core.PFont thePFont, int theFontSize)
           
 void setFilePath(java.lang.String theFilePath)
          set the path / filename of the xml file your controlP5 setup will be saved to.
 void setMoveable(boolean theFlag)
          disable Controllers to be moved around.
 void setTabEventsActive(boolean theFlag)
           
 void setUpdate(boolean theFlag)
           
 void setUrlPath(java.lang.String theUrlPath)
          you can set an url an e.g.
 void setUrlPath(java.lang.String theUrlPath, java.lang.String theFilename)
          you can set an url e.g.
 void show()
          show all controllers and tabs in your sketch.
 Tab tab(ControlWindow theWindow, java.lang.String theName)
          get a tab by name from a specific controlwindow.
 Tab tab(java.lang.String theName)
          get a tab by name.
 void trigger()
          Deprecated.  
 void unlock()
          Deprecated.  
 void update()
           
 java.lang.String urlPath()
          get the current url path where your controlP5 setup will be save to a remote server e.g.
 java.lang.String version()
          get the current version of controlP5
 ControlWindow window(processing.core.PApplet theApplet)
           
 ControlWindow window(java.lang.String theWindowName)
          get a ControlWindow by name.
 
Methods inherited from class controlP5.ControlP5Base
addBang, addButton, addButton, addButton, addChart, addCheckBox, addColorPicker, addControlWindow, addControlWindow, addControlWindow, addControlWindow, addControlWindow, addDropdownList, addGroup, addGroup, addKnob, addKnob, addListBox, addMatrix, addMultiList, addNumberbox, addNumberbox, addNumberbox, addRadio, addRadio, addRadioButton, addRange, addRange, addScrollList, addSlider, addSlider, addSlider, addSlider2D, addSlider2D, addTab, addTab, addTab, addTextarea, addTextfield, addTextlabel, addToggle, addToggle, addToggle
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

controlWindow

public ControlWindow controlWindow

color

public CColor color

standard58

public static final int standard58
See Also:
Constant Field Values

standard56

public static final int standard56
See Also:
Constant Field Values

synt24

public static final int synt24
See Also:
Constant Field Values

grixel

public static final int grixel
See Also:
Constant Field Values

keyHandler

public static ControlWindowKeyHandler keyHandler

papplet

public static processing.core.PApplet papplet

VERSION

public static final java.lang.String VERSION
See Also:
Constant Field Values

isApplet

public static boolean isApplet

DEBUG

public static boolean DEBUG
use this static variable to turn DEBUG on or off.

Constructor Detail

ControlP5

public ControlP5(processing.core.PApplet theParent)
instantiate controlP5.

Parameters:
theParent - PApplet

ControlP5

public ControlP5(processing.core.PApplet theParent,
                 ControlFont theControlFont)
Method Detail

setTabEventsActive

public void setTabEventsActive(boolean theFlag)

setAutoInitialization

public void setAutoInitialization(boolean theFlag)
autoInitialization can be very handy when it comes to initializing values, e.g. you load a set of controllers from an xml file, then the values that are attached to the controllers will be reset to its state saved in the xml file. to turn of auto intialization, call setAutoInitialization(false) right after initializing controlP5 and before creating any controller.

Parameters:
theFlag - boolean

setAutoDraw

public void setAutoDraw(boolean theFlag)
by default controlP5 draws any controller on top of any drawing done in the draw() function (this doesnt apply to P3D where controlP5.draw() has to be called manually in the sketch's draw() function ). to turn off the auto drawing of controlP5, use controlP5.setAutoDraw(false). now you can call controlP5.draw() any time whenever controllers should be drawn into the sketch.

Parameters:
theFlag - boolean

isAutoDraw

public boolean isAutoDraw()
check if the autoDraw function for the main window is enabled(true) or disabled(false).

Returns:
boolean

controlbroadcaster

public ControlBroadcaster controlbroadcaster()
Returns:
ControlBroadcaster

addListener

public void addListener(ControlListener theListener)

removeListener

public void removeListener(ControlListener theListener)

getListener

public ControlListener getListener(int theIndex)

tab

public Tab tab(java.lang.String theName)
get a tab by name.

Parameters:
theName - String
Returns:
Tab

getTab

public Tab getTab(java.lang.String theName)
get a tab by name.

Parameters:
theName - String
Returns:
Tab

tab

public Tab tab(ControlWindow theWindow,
               java.lang.String theName)
get a tab by name from a specific controlwindow.

Parameters:
theWindow - ControlWindow
theName - String
Returns:
Tab

getTab

public Tab getTab(ControlWindow theWindow,
                  java.lang.String theName)
get a tab by name from a specific controlwindow.

Parameters:
theWindow - ControlWindow
theName - String
Returns:
Tab

register

public void register(ControllerInterface theController)
Parameters:
theController - ControllerInterface

getControllerList

public ControllerInterface[] getControllerList()

remove

public void remove(java.lang.String theString)
remove a controlP5 element such as a controller, group, or tab by name.

Parameters:
theString - String

controller

public Controller controller(java.lang.String theName)
get a controller by name. you will have to cast the controller.

Parameters:
theName - String
Returns:
Controller

group

public ControllerGroup group(java.lang.String theGroupName)
get a group by name

Parameters:
theGroupName - String
Returns:
ControllerGroup

getGroup

public ControllerGroup getGroup(java.lang.String theGroupName)
get a group by name.

Parameters:
theGroupName - String
Returns:
ControllerGroup

draw

public void draw()

window

public ControlWindow window(processing.core.PApplet theApplet)

window

public ControlWindow window(java.lang.String theWindowName)
get a ControlWindow by name.

Parameters:
theName - String
Returns:
ControlWindow ControlWindow

setFilePath

public void setFilePath(java.lang.String theFilePath)
set the path / filename of the xml file your controlP5 setup will be saved to.

Parameters:
theFilename - String setUrlPath ( ) save ( ) load ( ) loadUrl ( )

setUrlPath

public void setUrlPath(java.lang.String theUrlPath)
you can set an url an e.g. index.php file on a server where you want to save your controlP5 setup to.

Parameters:
theUrlPath - String setFilePath ( ) loadUrl ( ) load ( ) save ( )

setUrlPath

public void setUrlPath(java.lang.String theUrlPath,
                       java.lang.String theFilename)
you can set an url e.g. an index.php file on a server where you want to save your controlP5 setup to.

Parameters:
theUrlPath - String
theFilename - String setFilePath ( ) loadUrl ( ) load ( ) save ( )

filePath

public java.lang.String filePath()
get the current file path where your controlP5 setup will be save to on your local disk.

Returns:
String

urlPath

public java.lang.String urlPath()
get the current url path where your controlP5 setup will be save to a remote server e.g. a webserver.

Returns:
String

setColorActive

public void setColorActive(int theColor)
set the active state color of tabs and controllers.

Parameters:
theColor - int

setColorForeground

public void setColorForeground(int theColor)
set the foreground color of tabs and controllers.

Parameters:
theColor - int

setColorBackground

public void setColorBackground(int theColor)
set the backgorund color of tabs and controllers.

Parameters:
theColor - int

setColorLabel

public void setColorLabel(int theColor)
set the label color of tabs and controllers.

Parameters:
theColor - int

setColorValue

public void setColorValue(int theColor)
set the value color of controllers.

Parameters:
theColor - int

setMoveable

public void setMoveable(boolean theFlag)
disable Controllers to be moved around. Other key events are still available like ALT-h to hide and show the controllers To disable all key events, use disableKeys()


isMoveable

public void isMoveable()
check if controllers are moveable


lock

public void lock()
Deprecated. 

lock ControlP5 to disable moving Controllers around. Other key events are still available like ALT-h to hide and show the controllers To disable all key events, use disableKeys() use setMoveable(false) instead


unlock

public void unlock()
Deprecated. 

unlock ControlP5 to enable moving Controllers around. use setMoveable(true) instead


save

public boolean save(java.lang.String theFilePath)
save controlP5 settings to your local disk or to a remote server. a file controlP5.xml will be written to the data folder of your sketch. you can set another file path with method setFilePath(). to save a file to a remote server set the url with setUrlPath() e.g. setUrlPath("http://yourdomain.com/controlP5/upload.php");

Parameters:
theFilename - String
Returns:
boolean setFilePath ( ) setUrlPath ( ) load ( ) loadUrl ( )

save

public boolean save()
save controlP5 settings to your local disk or to a remote server. a file controlP5.xml will be written to the data folder of your sketch. you can set another file path with method setFilePath(). to save a file to a remote server set the url with setUrlPath() e.g. setUrlPath("http://yourdomain.com/controlP5/upload.php");

Returns:
boolean load ( ) setUrlPath ( ) setFilePath ( )

load

public boolean load(java.lang.String theFileName)
load an xml file, containing a controlP5 setup

Parameters:
theFileName -

version

public java.lang.String version()
get the current version of controlP5

Returns:
String

show

public void show()
show all controllers and tabs in your sketch.


isVisible

public boolean isVisible()

hide

public void hide()
hide all controllers and tabs in your sketch.


update

public void update()

isUpdate

public boolean isUpdate()

setUpdate

public void setUpdate(boolean theFlag)

trigger

public void trigger()
Deprecated. 

forces each available controller to broadcast its value. deprecated. use .update() instead.


setControlFont

public boolean setControlFont(ControlFont theControlFont)

setControlFont

public boolean setControlFont(processing.core.PFont thePFont,
                              int theFontSize)

setControlFont

public boolean setControlFont(processing.core.PFont thePFont)

getControlFont

public static ControlFont getControlFont()

disableKeys

public void disableKeys()
Deprecated. use disableShortcuts()


enableKeys

public void enableKeys()
Deprecated. use enableShortcuts()


disableShortcuts

public void disableShortcuts()
disable shortcuts such as alt-h for hiding/showing controllers


enableShortcuts

public void enableShortcuts()

begin

public ControllerGroup begin()

begin

public ControllerGroup begin(ControllerGroup theGroup)

begin

public ControllerGroup begin(int theX,
                             int theY)

begin

public ControllerGroup begin(ControllerGroup theGroup,
                             int theX,
                             int theY)

begin

public ControllerGroup begin(ControlWindow theWindow)

begin

public ControllerGroup begin(ControlWindow theWindow,
                             int theX,
                             int theY)

end

public ControllerGroup end(ControllerGroup theGroup)

end

public ControllerGroup end()

dispose

public void dispose()
disposes and clears all controlP5 elements. When running in applet mode, opening new tabs or switching to another tab causes the applet to call dispose(). therefore dispose() is disabled when running ing applet mode. TODO implement better dispose handling for applets.


logger

public static java.util.logging.Logger logger()


processing library controlP5 by Andreas Schlegel. (c) 2010