controlP5
Class Controller

java.lang.Object
  extended by controlP5.Controller
All Implemented Interfaces:
CDrawable, ControllerInterface, ControlP5Constants
Direct Known Subclasses:
Bang, Button, Knob, Matrix, MultiList, Numberbox, Radio, Range, Slider, Textfield, Textlabel, Toggle

public abstract class Controller
extends java.lang.Object
implements ControllerInterface, CDrawable, ControlP5Constants

Controller is an abstract class that is extended by any available controller within controlP5. this is the full documentation list for all methods available for a controller. An event triggered by a controller will be forwarded to the main program. If a void controlEvent(ControlEvent theEvent) {} method is available, this method will be called.

A Controller can pass a change in value to the main program in 3 different ways: (1) add method controlEvent(ControlEvent theEvent) to your sketch. ControlP5 will automatically detect this method and will used it to forward any controlEvent triggered by a controller - you can disable forwarding by using setBroadcast(false) (see setBroadcast) (2) each controller requires a unique name when being create. In case an existing name is used for a newly created Controller, the existing one will be overwritten. each unique name can be used to automatically link a controller to either a method or a field within your program.

See Also:
Bang, Button, Knob, Matrix, MultiList, Numberbox, Radio, ScrollList, Slider, Textarea, Textfield, Textlabel, Toggle, ControlGroup, ControlBehavior, ControlEvent

Field Summary
static int MOVE
           
static int PRESSED
           
static int RELEASE
           
 
Fields inherited from interface controlP5.ControlP5Constants
acceptClassList, ALT, ARRAY, BACKSPACE, BOOLEAN, CONTROL, DECREASE, DELETE, DOWN, ENTER, ESCAPE, eventMethod, FIELD, FLOAT, HALF_PI, HIDE, INCREASE, INTEGER, INVALID, KEYCONTROL, LEFT, LOAD, MENU, METHOD, PI, PRINT, RESET, RIGHT, SAVE, SHIFT, STRING, SWITCH_BACK, SWITCH_FORE, TAB, TWO_PI, UP, VERBOSE
 
Method Summary
 CVector3f absolutePosition()
          get the absolute position of a controller.
 void add(ControllerInterface theElement)
           
 void addListener(ControlListener theListener)
          add a listener to the controller.
 float[] arrayValue()
           
 ControlBehavior behavior()
          get the behavior of the controller.
 Label captionLabel()
           
 void changeValue(float theValue)
          set the value of the controller without sending the broadcast event.
 CColor color()
           
 void continuousUpdateEvents()
          continuousUpdateEvents is used for internal updates of a controller.
 ControlWindow controlWindow()
           
 float defaultValue()
          returns the default value.
 void disableSprite()
           
 void draw(processing.core.PApplet theApplet)
           
 void enableSprite()
           
 ControlP5XMLElement getAsXML()
           
 CColor getColor()
           
 int getHeight()
           
 Tab getTab()
          get the instance of the tab the controller belongs to.
 int getWidth()
           
 ControlWindow getWindow()
          get the control window of the controller
 void hide()
          hide the controller, make it invisible.
 int id()
          get the id of the controller.
 void init()
           
 boolean isBroadcast()
          check if broadcasting is enabled or disabled for a controller.
 boolean isInside()
          returns true or false and indicates if the mouse is inside the area of a controller.
 boolean isMousePressed()
          returns true or false if the mouse has been pressed.
 boolean isUpdate()
          enable the update function for a controller.
 boolean isVisible()
          check if the controller is visible.
 boolean isXMLsavable()
           
 void keyEvent(java.awt.event.KeyEvent theEvent)
           
 java.lang.String label()
          get the label of the controller.
 int listenerSize()
           
 float max()
           
 float min()
           
 void moveTo(ControlGroup theGroup)
           
 void moveTo(ControlGroup theGroup, Tab theTab, ControlWindow theControlWindow)
           
 void moveTo(ControlWindow theControlWindow)
          move a controller to the default tab of a control window - other than the main window.
 void moveTo(ControlWindow theControlWindow, java.lang.String theTabName)
           
 void moveTo(processing.core.PApplet theApplet)
          move a controller to the default tab inside the main window.
 void moveTo(processing.core.PApplet theApplet, java.lang.String theTabName)
          move a controller to a defined tab inside the main window.
 void moveTo(java.lang.String theTabName)
          move a controller to another tab.
 void moveTo(Tab theTab)
          move a controller to another tab indicated by parameter theTab.
 java.lang.String name()
          returns the name of the controller.
 ControllerInterface parent()
          get the parent of a controller.
 CVector3f position()
          get the position of a controller.
 void remove()
          remove a controller from controlP5.
 void remove(ControllerInterface theElement)
           
 void removeBehavior()
          remove the behavior from the controller.
 void removeListener(ControlListener theListener)
          remove a listener from the controller.
 void setArrayValue(float[] theArray)
           
 void setBehavior(ControlBehavior theBehavior)
          with setBehavior you can add a ControlBehavior to a controller.
 void setBroadcast(boolean theFlag)
          Use setBroadcast to enable and disable the broadcasting of changes in a controller's value.
 void setCaptionLabel(java.lang.String theLabel)
          set or change the content of the caption label of a controller.
 void setColorActive(int theColor)
          set the color for the controller while active.
 void setColorBackground(int theColor)
          set the background color of the controller.
 void setColorForeground(int theColor)
          set the foreground color of the controller.
 void setColorLabel(int theColor)
          set the color of the text label of the controller.
 void setColorValue(int theColor)
          set the color of the value label of the controller.
 void setDecimalPrecision(int theValue)
          sets the decimal precision of a controller's float value displayed.
 void setDefaultValue(float theValue)
          set the default value.
 void setGroup(ControllerGroup theGroup)
           
 void setGroup(java.lang.String theName)
          set the group of the controller.
 Controller setHeight(int theHeight)
           
 void setId(int theId)
          set the id of the controller.
 void setLabel(java.lang.String theLabel)
          set the label of the controller.
 void setLabelVisible(boolean theValue)
          show or hide the labels of a controller.
 void setMax(float theValue)
          set the maximum level of the Controller.
 void setMin(float theValue)
          set the minimum level of the Controller.
 boolean setMousePressed(boolean theStatus)
           
 void setMoveable(boolean theValue)
          enable or prevent the controller to be moveable.
 void setParent(ControllerInterface theParent)
          set the parent of a parent of a controller.
 void setPosition(float theX, float theY)
          set the position of a controller.
 void setSprite(ControllerSprite theSprite)
           
 void setTab(ControlWindow theWindow, java.lang.String theName)
           
 void setTab(java.lang.String theName)
          set the tab of the controller.
 void setUpdate(boolean theFlag)
          disable the update function for a controller.
abstract  void setValue(float theValue)
          set the value of the controller.
 void setValueLabel(java.lang.String theLabel)
          set or change the value of the value label of a controller.
 void setVisible(boolean theFlag)
          set the visibility of a controller.
 Controller setWidth(int theWidth)
           
 ControlWindow setWindow(ControlWindow theWindow)
          Deprecated.  
 void setWindow(processing.core.PApplet theApplet)
          Deprecated.  
 void show()
          show the controller.
 java.lang.String stringValue()
          set the current string value of a controller.
 void trigger()
          Deprecated.  
 void update()
          updates the value of the controller without having to set the value explicitly.
 void updateAbsolutePosition()
           
 void updateEvents()
          updateEvents is used for internal updates of a controller.
 void updateInternalEvents(processing.core.PApplet theApplet)
          TODO
 float value()
          get the current value of the controller.
 Label valueLabel()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface controlP5.ControllerInterface
addToXMLElement
 

Field Detail

MOVE

public static final int MOVE
See Also:
Constant Field Values

RELEASE

public static final int RELEASE
See Also:
Constant Field Values

PRESSED

public static final int PRESSED
See Also:
Constant Field Values
Method Detail

init

public final void init()
Specified by:
init in interface ControllerInterface

setBehavior

public void setBehavior(ControlBehavior theBehavior)
with setBehavior you can add a ControlBehavior to a controller. A ControlBehavior can be used to e.g. automatically change state, function, position, etc.

Parameters:
theBehavior - ControlBehavior

removeBehavior

public void removeBehavior()
remove the behavior from the controller.


behavior

public ControlBehavior behavior()
get the behavior of the controller.

Returns:
ControlBehavior

defaultValue

public float defaultValue()
returns the default value.

Returns:
float

setDefaultValue

public void setDefaultValue(float theValue)
set the default value.

Parameters:
theValue - float

setMoveable

public void setMoveable(boolean theValue)
enable or prevent the controller to be moveable. By default a controller is moveable.

Parameters:
theValue - boolean

setLabelVisible

public void setLabelVisible(boolean theValue)
show or hide the labels of a controller.

Parameters:
theValue - boolean

setBroadcast

public void setBroadcast(boolean theFlag)
Use setBroadcast to enable and disable the broadcasting of changes in a controller's value. By default any value changes are forwarded to function controlEvent inside your program. use setBroadcast(false) to disable forwarding.

Parameters:
theFlag - boolean

isBroadcast

public boolean isBroadcast()
check if broadcasting is enabled or disabled for a controller. Every event relevant for a value change will be broadcasted to any of the value-listeners. By default broadcasting for a controller is enabled.

Returns:
boolean

position

public CVector3f position()
get the position of a controller. e.g. Controller.position().x();

Specified by:
position in interface ControllerInterface
Returns:
CVector3f

setPosition

public void setPosition(float theX,
                        float theY)
set the position of a controller. The position of a controller is relative.

Specified by:
setPosition in interface ControllerInterface
Parameters:
theX - float
theY - float

absolutePosition

public CVector3f absolutePosition()
get the absolute position of a controller. if a controller is the child of another controller, the absolute position is the sum of its parent(s) position(s).

Specified by:
absolutePosition in interface ControllerInterface
Returns:
CVector3f

updateAbsolutePosition

public void updateAbsolutePosition()
Specified by:
updateAbsolutePosition in interface ControllerInterface

continuousUpdateEvents

public final void continuousUpdateEvents()
continuousUpdateEvents is used for internal updates of a controller. this method is final and can't be overwritten.

Specified by:
continuousUpdateEvents in interface ControllerInterface

updateEvents

public final void updateEvents()
updateEvents is used for internal updates of a controller. this method is final and can't be overwritten.

Specified by:
updateEvents in interface ControllerInterface

updateInternalEvents

public void updateInternalEvents(processing.core.PApplet theApplet)
TODO

Specified by:
updateInternalEvents in interface ControllerInterface
See Also:
ControllerInterface.updateInternalEvents

draw

public void draw(processing.core.PApplet theApplet)
Specified by:
draw in interface CDrawable
Specified by:
draw in interface ControllerInterface
Parameters:
theApplet - PApplet

add

public void add(ControllerInterface theElement)
Specified by:
add in interface ControllerInterface
Parameters:
theElement - ControllerInterface

remove

public void remove(ControllerInterface theElement)
Specified by:
remove in interface ControllerInterface
Parameters:
theElement - ControllerInterface

remove

public void remove()
remove a controller from controlP5.

Specified by:
remove in interface ControllerInterface

name

public java.lang.String name()
returns the name of the controller.

Specified by:
name in interface ControllerInterface
Returns:
String

moveTo

public void moveTo(java.lang.String theTabName)
move a controller to another tab. The tab is defined by parameter theTabName. if controlP5 can't find a tab with such name, controlP5 will create this tab and add it to the main window.

Parameters:
theTabName - String

moveTo

public void moveTo(Tab theTab)
move a controller to another tab indicated by parameter theTab.

Parameters:
theTab -

moveTo

public void moveTo(processing.core.PApplet theApplet)
move a controller to the default tab inside the main window.

Parameters:
theApplet -

moveTo

public void moveTo(processing.core.PApplet theApplet,
                   java.lang.String theTabName)
move a controller to a defined tab inside the main window.

Parameters:
theApplet -
theTabName -

moveTo

public void moveTo(ControlWindow theControlWindow)
move a controller to the default tab of a control window - other than the main window.

Parameters:
theControlWindow -

moveTo

public void moveTo(ControlWindow theControlWindow,
                   java.lang.String theTabName)

moveTo

public void moveTo(ControlGroup theGroup,
                   Tab theTab,
                   ControlWindow theControlWindow)
Specified by:
moveTo in interface ControllerInterface
Parameters:
theGroup - ControlGroup
theTab - Tab
theControlWindow - ControlWindow

moveTo

public void moveTo(ControlGroup theGroup)

setTab

public void setTab(java.lang.String theName)
set the tab of the controller.

Parameters:
theName - String

setTab

public void setTab(ControlWindow theWindow,
                   java.lang.String theName)

setGroup

public void setGroup(java.lang.String theName)
set the group of the controller.

Parameters:
theName - String

setGroup

public void setGroup(ControllerGroup theGroup)

setWindow

public void setWindow(processing.core.PApplet theApplet)
Deprecated. 

Parameters:
theApplet - PApplet

setWindow

public ControlWindow setWindow(ControlWindow theWindow)
Deprecated. 

Parameters:
theWindwo - ControlWindow

getTab

public Tab getTab()
get the instance of the tab the controller belongs to.

Specified by:
getTab in interface ControllerInterface
Returns:
Tab

setParent

public final void setParent(ControllerInterface theParent)
set the parent of a parent of a controller. this method is only meant for internal use.this method is final and can't be overwritten.

Parameters:
theParent - ControllerInterface

parent

public ControllerInterface parent()
get the parent of a controller.

Returns:

getWindow

public ControlWindow getWindow()
get the control window of the controller

Specified by:
getWindow in interface ControllerInterface
Returns:
ControlWindow

isInside

public boolean isInside()
returns true or false and indicates if the mouse is inside the area of a controller.

Returns:
boolean

isMousePressed

public boolean isMousePressed()
returns true or false if the mouse has been pressed.

Returns:

setMousePressed

public final boolean setMousePressed(boolean theStatus)
Specified by:
setMousePressed in interface ControllerInterface
Parameters:
theStatus - boolean
Returns:
boolean

keyEvent

public void keyEvent(java.awt.event.KeyEvent theEvent)
Specified by:
keyEvent in interface ControllerInterface
Parameters:
KeyEvent - theEvent

setId

public void setId(int theId)
set the id of the controller.

Specified by:
setId in interface ControllerInterface
Parameters:
int - theId

id

public int id()
get the id of the controller.

Specified by:
id in interface ControllerInterface
Returns:
int

setValue

public abstract void setValue(float theValue)
set the value of the controller.

Parameters:
theValue - float

setArrayValue

public void setArrayValue(float[] theArray)

changeValue

public final void changeValue(float theValue)
set the value of the controller without sending the broadcast event. this function is final.

Parameters:
theValue - float

update

public void update()
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

setUpdate

public void setUpdate(boolean theFlag)
disable the update function for a controller.

Specified by:
setUpdate in interface ControllerInterface
Parameters:
theFlag - boolean

isUpdate

public boolean isUpdate()
enable the update function for a controller.

Specified by:
isUpdate in interface ControllerInterface
Returns:
boolean

trigger

public void trigger()
Deprecated. 

trigger the event of a controller. deprecated. use .update() instead.


value

public float value()
get the current value of the controller.

Specified by:
value in interface ControllerInterface
Returns:
float

stringValue

public java.lang.String stringValue()
set the current string value of a controller.

Specified by:
stringValue in interface ControllerInterface
Returns:
String

arrayValue

public float[] arrayValue()

color

public CColor color()
Specified by:
color in interface ControllerInterface
Returns:
CColor

getColor

public CColor getColor()

setLabel

public void setLabel(java.lang.String theLabel)
set the label of the controller.

Specified by:
setLabel in interface ControllerInterface
Parameters:
theLabel - String

setCaptionLabel

public void setCaptionLabel(java.lang.String theLabel)
set or change the content of the caption label of a controller.

Parameters:
theLabel -

setValueLabel

public void setValueLabel(java.lang.String theLabel)
set or change the value of the value label of a controller. (this is cheating, but maybe useful for some cases.)

Parameters:
theLabel -

label

public java.lang.String label()
get the label of the controller.

Returns:
String

addListener

public void addListener(ControlListener theListener)
add a listener to the controller.

Parameters:
theListener - ControlListener

removeListener

public void removeListener(ControlListener theListener)
remove a listener from the controller.

Parameters:
theListener - ControlListener

listenerSize

public int listenerSize()
Returns:
int

isVisible

public boolean isVisible()
check if the controller is visible.

Specified by:
isVisible in interface ControllerInterface
Returns:
boolean

setVisible

public void setVisible(boolean theFlag)
set the visibility of a controller.

Parameters:
theFlag - boolean

hide

public void hide()
hide the controller, make it invisible.

Specified by:
hide in interface ControllerInterface

show

public void show()
show the controller. make it visible.

Specified by:
show in interface ControllerInterface

setColorActive

public void setColorActive(int theColor)
set the color for the controller while active.

Specified by:
setColorActive in interface ControllerInterface
Parameters:
theColor - int

setColorForeground

public void setColorForeground(int theColor)
set the foreground color of the controller.

Specified by:
setColorForeground in interface ControllerInterface
Parameters:
theColor - int

setColorBackground

public void setColorBackground(int theColor)
set the background color of the controller.

Specified by:
setColorBackground in interface ControllerInterface
Parameters:
theColor - int

setColorLabel

public void setColorLabel(int theColor)
set the color of the text label of the controller.

Specified by:
setColorLabel in interface ControllerInterface
Parameters:
theColor - int

setColorValue

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

Specified by:
setColorValue in interface ControllerInterface
Parameters:
theColor - int

captionLabel

public Label captionLabel()

valueLabel

public Label valueLabel()

max

public float max()
Returns:
float

min

public float min()
Returns:
float

setMin

public void setMin(float theValue)
set the minimum level of the Controller.

Parameters:
theValue - float

setMax

public void setMax(float theValue)
set the maximum level of the Controller.

Parameters:
theValue - float

setWidth

public Controller setWidth(int theWidth)

setHeight

public Controller setHeight(int theHeight)

getWidth

public int getWidth()

getHeight

public int getHeight()

setDecimalPrecision

public void setDecimalPrecision(int theValue)
sets the decimal precision of a controller's float value displayed. the precision does not apply to the returned float value.

Parameters:
theValue -

controlWindow

public ControlWindow controlWindow()

setSprite

public void setSprite(ControllerSprite theSprite)

enableSprite

public void enableSprite()

disableSprite

public void disableSprite()

isXMLsavable

public boolean isXMLsavable()
Specified by:
isXMLsavable in interface ControllerInterface
Returns:
boolean

getAsXML

public ControlP5XMLElement getAsXML()
Specified by:
getAsXML in interface ControllerInterface
Returns:
ControlP5XMLElement


processing library controlP5 by Andreas Schlegel. (c) 2010