|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.ObjectcontrolP5.ControlP5Base
controlP5.ControlP5
public class ControlP5
controlP5 is a processing and java library for creating simple control GUIs.
/** * 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 |
---|
public ControlWindow controlWindow
public CColor color
public static final int standard58
public static final int standard56
public static final int synt24
public static final int grixel
public static ControlWindowKeyHandler keyHandler
public static processing.core.PApplet papplet
public static final java.lang.String VERSION
public static boolean isApplet
public static boolean DEBUG
Constructor Detail |
---|
public ControlP5(processing.core.PApplet theParent)
theParent
- PAppletpublic ControlP5(processing.core.PApplet theParent, ControlFont theControlFont)
Method Detail |
---|
public void setTabEventsActive(boolean theFlag)
public void setAutoInitialization(boolean theFlag)
theFlag
- booleanpublic void setAutoDraw(boolean theFlag)
theFlag
- booleanpublic boolean isAutoDraw()
public ControlBroadcaster controlbroadcaster()
public void addListener(ControlListener theListener)
public void removeListener(ControlListener theListener)
public ControlListener getListener(int theIndex)
public Tab tab(java.lang.String theName)
theName
- String
public Tab getTab(java.lang.String theName)
theName
- String
public Tab tab(ControlWindow theWindow, java.lang.String theName)
theWindow
- ControlWindowtheName
- String
public Tab getTab(ControlWindow theWindow, java.lang.String theName)
theWindow
- ControlWindowtheName
- String
public void register(ControllerInterface theController)
theController
- ControllerInterfacepublic ControllerInterface[] getControllerList()
public void remove(java.lang.String theString)
theString
- Stringpublic Controller controller(java.lang.String theName)
theName
- String
public ControllerGroup group(java.lang.String theGroupName)
theGroupName
- String
public ControllerGroup getGroup(java.lang.String theGroupName)
theGroupName
- String
public void draw()
public ControlWindow window(processing.core.PApplet theApplet)
public ControlWindow window(java.lang.String theWindowName)
theName
- String
public void setFilePath(java.lang.String theFilePath)
theFilename
- String setUrlPath ( ) save ( ) load ( ) loadUrl ( )public void setUrlPath(java.lang.String theUrlPath)
theUrlPath
- String setFilePath ( ) loadUrl ( ) load ( ) save ( )public void setUrlPath(java.lang.String theUrlPath, java.lang.String theFilename)
theUrlPath
- StringtheFilename
- String setFilePath ( ) loadUrl ( ) load ( ) save ( )public java.lang.String filePath()
public java.lang.String urlPath()
public void setColorActive(int theColor)
theColor
- intpublic void setColorForeground(int theColor)
theColor
- intpublic void setColorBackground(int theColor)
theColor
- intpublic void setColorLabel(int theColor)
theColor
- intpublic void setColorValue(int theColor)
theColor
- intpublic void setMoveable(boolean theFlag)
public void isMoveable()
public void lock()
public void unlock()
public boolean save(java.lang.String theFilePath)
theFilename
- String
public boolean save()
public boolean load(java.lang.String theFileName)
theFileName
- public java.lang.String version()
public void show()
public boolean isVisible()
public void hide()
public void update()
public boolean isUpdate()
public void setUpdate(boolean theFlag)
public void trigger()
public boolean setControlFont(ControlFont theControlFont)
public boolean setControlFont(processing.core.PFont thePFont, int theFontSize)
public boolean setControlFont(processing.core.PFont thePFont)
public static ControlFont getControlFont()
public void disableKeys()
public void enableKeys()
public void disableShortcuts()
public void enableShortcuts()
public ControllerGroup begin()
public ControllerGroup begin(ControllerGroup theGroup)
public ControllerGroup begin(int theX, int theY)
public ControllerGroup begin(ControllerGroup theGroup, int theX, int theY)
public ControllerGroup begin(ControlWindow theWindow)
public ControllerGroup begin(ControlWindow theWindow, int theX, int theY)
public ControllerGroup end(ControllerGroup theGroup)
public ControllerGroup end()
public void dispose()
public static java.util.logging.Logger logger()
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |