|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.ObjectcontrolP5.Controller
controlP5.Toggle
public class Toggle
a toggle can have two states, true and false, where true has the value 1 and false is 0.
/** * ControlP5 Toggle * by andreas schlegel, 2009 */ import controlP5.*; ControlP5 controlP5; int myColorBackground = color(0,0,0); boolean toggleValue = true; void setup() { size(400,400); smooth(); controlP5 = new ControlP5(this); controlP5.addToggle("toggle",false,100,160,20,20); controlP5.addToggle("toggleValue",true,100,240,100,20).setMode(ControlP5.SWITCH); } void draw() { background(myColorBackground); if(toggleValue==true) { fill(0,255,0); } else { fill(255,0,0); } rect(0,0,width,100); } void toggle(boolean theFlag) { if(theFlag==true) { myColorBackground = color(100); } else { myColorBackground = color(0); } println("a toggle event."); }
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 | |
---|---|
Toggle(ControlP5 theControlP5,
Tab theParent,
java.lang.String theName,
float theValue,
float theX,
float theY,
int theWidth,
int theHeight)
|
Method Summary | |
---|---|
void |
addToXMLElement(ControlP5XMLElement theElement)
|
void |
draw(processing.core.PApplet theApplet)
the default draw function for each controller extending superclass Controller. |
boolean |
getState()
|
float |
internalValue()
|
Controller |
linebreak()
|
void |
mousePressed()
|
void |
setInternalValue(float theInternalValue)
by default a toggle returns 0 (for off) and 1 (for on). |
void |
setMode(int theMode)
set the visual mode of a Toggle. |
void |
setState(boolean theFlag)
set the state of the toggle, which can be true or false. |
void |
setValue(boolean theValue)
|
void |
setValue(float theValue)
set the value of the controller. |
void |
toggle()
switch the state of a toggle. |
void |
update()
updates the value of the controller without having to set the value explicitly. |
void |
updateDisplayMode(int theState)
|
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public Toggle(ControlP5 theControlP5, Tab theParent, java.lang.String theName, float theValue, float theX, float theY, int theWidth, int theHeight)
theControlP5
- ControlP5theParent
- TabtheName
- StringtheValue
- floattheX
- floattheY
- floattheWidth
- inttheHeight
- intMethod Detail |
---|
public void draw(processing.core.PApplet theApplet)
Controller
draw
in interface CDrawable
draw
in interface ControllerInterface
draw
in class Controller
theApplet
- PAppletControllerDisplay
public void mousePressed()
public void setValue(float theValue)
Controller
setValue
in class Controller
theValue
- floatpublic void setValue(boolean theValue)
public void update()
Controller
update
in interface ControllerInterface
update
in class Controller
public void setState(boolean theFlag)
theFlag
- booleanpublic boolean getState()
public void toggle()
public void setMode(int theMode)
theMode
- public void addToXMLElement(ControlP5XMLElement theElement)
theElement
- ControlP5XMLElementpublic void setInternalValue(float theInternalValue)
theInternalValue
- public float internalValue()
public Controller linebreak()
linebreak
in class Controller
public void updateDisplayMode(int theState)
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |