# Controller (Javadocs: controlP5)
Date: 2014-04-27

controlP5

## Class Controller<T>

- java.lang.Object
- - controlP5.Controller<T>

All Implemented Interfaces:
  CDrawable, ControllerInterface<T>, ControlP5Constants

Direct Known Subclasses:
  Bang, BoundingBox, Button, Chart, ColorWheel, Knob, Matrix, MultiList, Numberbox, Range, ScrollableList, Slider, Slider2D, Textfield, Textlabel, Toggle

    public abstract class Controller<T>
    extends java.lang.Object
    implements ControllerInterface<T>, 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 notify the main program in 2 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) `setBroadcast(boolean)`
- (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`, `RadioButton`, `ListBox`, `Slider`, `Textarea`, `Textfield`, `Textlabel`, `Toggle`, `ControlGroup`, `ControlBehavior`, `ControlEvent`

+Example
  `

      /**
       * ControlP5 Basics
       *
       * 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, 2011
       * www.sojamo.de/libraries/controlp5
       *
       */

      import controlP5.*;

      ControlP5 cp5;
      public int myColorRect = 200;
      public int myColorBackground = 100;

      void setup() {
        size(400, 400);
        noStroke();

        cp5 = new ControlP5(this);

        // create a slider
        // parameters:
        // name, minValue, maxValue, defaultValue, x, y, width, height
        cp5.addSlider("sliderA", 100, 200, 100, 100, 260, 100, 14);

        // create 3 numberboxes and assign an id for each
        cp5.addNumberbox("numberboxA", myColorRect, 100, 140, 100, 14).setId(1);
        cp5.addNumberbox("numberboxB", myColorBackground, 100, 180, 100, 14).setId(2);
        cp5.addNumberbox("numberboxC", 0, 100, 220, 100, 14).setId(3);

        // create a texfield
        cp5.addTextfield("textA", 100, 290, 100, 20);

        // change individual settings for a controller
        cp5.getController("numberboxA").setMax(255);
        cp5.getController("numberboxA").setMin(0);
      }

      void draw() {
        background(myColorBackground);
        fill(myColorRect);
        rect(0, 0, width, 100);
      }

      // events from controller numberboxC are received here
      public void numberboxC(int theValue) {
        println("### got an event from numberboxC : "+theValue);
      }

      // an event from slider sliderA will change the value of textfield textA here
      public void sliderA(int theValue) {
        Textfield txt = ((Textfield)cp5.getController("textA"));
        txt.setValue(""+theValue);
      }

      // for every change (a textfield event confirmed with a return) in textfield textA,
      // function textA will be invoked
      public void textA(String theValue) {
        println("### got an event from textA : "+theValue);
      }

      // function controlEvent will be invoked with every value change
      // in any registered controller
      public void controlEvent(ControlEvent theEvent) {
        println("got a control event from controller with id "+theEvent.getId());
        switch(theEvent.getId()) {
          case(1): // numberboxA is registered with id 1
          myColorRect = (int)(theEvent.getController().getValue());
          break;
          case(2):  // numberboxB is registered with id 2
          myColorBackground = (int)(theEvent.getController().getValue());
          break;
        }
      }

  `

### Field Summary

Fields
`static int` `autoHeight`
`static processing.core.PVector` `autoSpacing`
`static int` `autoWidth`

### Fields inherited from interface controlP5.ControlP5Constants

`acceptClassList, ACTION_BROADCAST, ACTION_CLICK, ACTION_DRAG, ACTION_ENTER, ACTION_EXIT, ACTION_LEAVE, ACTION_MOVE, ACTION_PRESS, ACTION_PRESSED, ACTION_RELEASE, ACTION_RELEASED, ACTION_RELEASEDOUTSIDE, ACTION_WHEEL, ACTIVE, ALL, ALT, AQUA, ARC, ARRAY, BACKSPACE, BASELINE, BITFONT, BLACK, BLUE, BOOLEAN, BOTTOM, BOTTOM_OUTSIDE, CAPTIONLABEL, CENTER, CHECKBOX, COMMANDKEY, CONTROL, controlEventClass, CUSTOM, DECREASE, DEFAULT, DELETE, DONE, DOWN, DROPDOWN, ELLIPSE, ENTER, ESCAPE, EVENT, eventMethod, FADEIN, FADEOUT, FIELD, FLOAT, FUCHSIA, GRAY, GREEN, grixel, HALF_PI, HIDE, HIGHLIGHT, HORIZONTAL, IDLE, IMAGE, INACTIVE, INCREASE, INTEGER, INVALID, J2D, KEYCONTROL, LEFT, LEFT_OUTSIDE, LIME, LINE, LIST, LOAD, MAROON, MENU, METHOD, MOVE, MULTI, MULTIPLES, NAVY, OLIVE, ORANGE, OVER, P2D, P3D, PI, PRESSED, PRINT, PURPLE, RED, RELEASE, RESET, RIGHT, RIGHT_OUTSIDE, SAVE, SHIFT, SILVER, SINGLE, SINGLE_COLUMN, SINGLE_ROW, SPRITE, standard56, standard58, STRING, SWITCH, SWITCH_BACK, SWITCH_FORE, synt24, TAB, TEAL, THEME_A, THEME_CP52014, THEME_CP5BLUE, THEME_RED, THEME_RETRO, THEME_WHITE, TOP, TOP_OUTSIDE, TRANSITION_WAIT_FADEIN, TREE, TWO_PI, UP, VALUELABEL, VERBOSE, VERTICAL, WAIT, WHITE, YELLOW`

### Constructor Summary

Constructors
Constructor and Description
`Controller(ControlP5 theControlP5, java.lang.String theName)` Convenience constructor to extend Controller.

### Method Summary

Methods
`T` `add(ControllerInterface<?> theElement)`
`T` `addCallback(CallbackListener theListener)`
`T` `addListener(ControlListener theListener)`
`T` `align(int theCaptionX, int theCaptionY, int theValueX, int theValueY)`
`T` `bringToFront()`
`T` `bringToFront(ControllerInterface<?> theController)`
`T` `changeValue(float theValue)` sets the value of the controller without sending the broadcast event.
`void` `continuousUpdateEvents()` continuousUpdateEvents is used for internal updates of a controller.
`void` `draw(processing.core.PGraphics theGraphics)` the default draw function for each controller extending superclass Controller.
`processing.core.PVector` `getAbsolutePosition()`
`java.lang.String` `getAddress()`
`float[]` `getArrayValue()` returns the current float array value of a controller.
`float` `getArrayValue(int theIndex)`
`ControlBehavior` `getBehavior()`
`Label` `getCaptionLabel()`
`CColor` `getColor()`
`java.util.List<ControllerPlug>` `getControllerPlugList()`
`ControlWindow` `getControlWindow()`
`int` `getDecimalPrecision()`
`float` `getDefaultValue()`
`int` `getHeight()`
`int` `getId()` returns the id of a controller, by default the id is -1.
`java.lang.String` `getInfo()`
`java.lang.String` `getLabel()` returns the controller's caption label text.
`float` `getMax()` returns the maximum value of the controller.
`float` `getMin()` returns the minimum value of the controller.
`java.lang.String` `getName()` returns the index name of the controller.
`ControllerInterface<?>` `getParent()` returns the parent of a controller.
`int` `getPickingColor()`
`Pointer` `getPointer()`
`processing.core.PVector` `getPosition()` get the position of a controller.
`ControllerProperty` `getProperty(java.lang.String thePropertyName)`
`ControllerProperty` `getProperty(java.lang.String theSetter, java.lang.String theGetter)`
`java.lang.String` `getStringValue()`
`Tab` `getTab()` get the instance of the tab the controller belongs to.
`float` `getValue()`
`Label` `getValueLabel()`
`ControllerView<T>` `getView()`
`int` `getWidth()`
`ControlWindow` `getWindow()` returns the control window of the controller
`T` `hide()`
`void` `init()`
`boolean` `isActive()` checks if a controller is active.
`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` `isLabelVisible()`
`boolean` `isListening()` returns true or false for the current listening status.
`boolean` `isLock()`
`boolean` `isMouseOver()` check if the mouse is within this particular controller.
`boolean` `isMousePressed()` returns true or false if the mouse has is pressed.
`boolean` `isMoveable()` checks if a controller is moveable.
`boolean` `isUpdate()` enables the update function for a controller.
`boolean` `isUserInteraction()`
`boolean` `isVisible()`
`void` `keyEvent(processing.event.KeyEvent theEvent)`
`T` `linebreak()`
`T` `listen(boolean theValue)` enables a controller to listen to changes made to the variable linked to the controller.
`int` `listenerSize()`
`T` `lock()` disables the controller to be moved, or changed or controlled by the user.
`T` `moveTo(ControlGroup<?> theGroup)`
`T` `moveTo(ControllerGroup<?> theGroup)`
`T` `moveTo(ControllerGroup<?> theGroup, Tab theTab, ControlWindow theControlWindow)`
`T` `moveTo(ControlWindow theControlWindow)` moves the controller to the default tab of a control window - other than the main window.
`T` `moveTo(ControlWindow theControlWindow, java.lang.String theTabName)`
`T` `moveTo(processing.core.PApplet theApplet)` moves the controller to the default tab inside the main window.
`T` `moveTo(processing.core.PApplet theApplet, java.lang.String theTabName)` moves the controller to a tab inside the main window.
`T` `moveTo(java.lang.String theTabName)` moves the controller to another tab.
`T` `moveTo(Tab theTab)` moves the controller to another tab.
`T` `plugTo(java.lang.Object theObject)`
`T` `plugTo(java.lang.Object[] theObjects)` plugs the controller to a list of objects
`T` `plugTo(java.lang.Object[] theObjects, java.lang.String theName)`
`T` `plugTo(java.lang.Object theObject, java.lang.String theName)`
`T` `registerProperty(java.lang.String thePropertyName)`
`T` `registerProperty(java.lang.String theSetter, java.lang.String theGetter)`
`T` `registerTooltip(java.lang.String theText)` adds a tooltip to a controller, by default the tooltip is disabled.
`void` `remove()` removes a controller from controlP5.
`T` `remove(ControllerInterface<?> theElement)`
`T` `removeBehavior()`
`T` `removeCallback()`
`T` `removeCallback(CallbackListener theListener)`
`T` `removeListener(ControlListener theListener)`
`T` `removeProperty(java.lang.String thePropertyName)`
`T` `removeProperty(java.lang.String theSetter, java.lang.String theGetter)`
`T` `setAbsolutePosition(processing.core.PVector thePVector)`
`T` `setAddress(java.lang.String theAddress)`
`T` `setArrayValue(float[] theArray)`
`T` `setArrayValue(int theIndex, float theValue)`
`T` `setBehavior(ControlBehavior theBehavior)` with setBehavior you can add a ControlBehavior to a controller.
`T` `setBroadcast(boolean theFlag)` Use setBroadcast to enable and disable the broadcasting of changes in a controller's value.
`T` `setCaptionLabel(java.lang.String theLabel)` sets the content of the caption label of a controller.
`T` `setColor(CColor theColor)`
`T` `setColorActive(int theColor)`
`T` `setColorBackground(int theColor)`
`T` `setColorCaptionLabel(int theColor)`
`T` `setColorForeground(int theColor)`
`T` `setColorValueLabel(int theColor)`
`T` `setDecimalPrecision(int theValue)` sets the decimal precision of a controller's float value displayed.
`T` `setDefaultValue(float theValue)` set the default value.
`T` `setGroup(ControllerGroup<?> theGroup)`
`T` `setGroup(java.lang.String theName)` sets the group of the controller.
`T` `setHeight(int theHeight)`
`T` `setId(int theId)` set the id of a controller.
`T` `setImage(processing.core.PImage theImage)`
`T` `setImage(processing.core.PImage theImage, int theState)`
`T` `setImages(processing.core.PImage... imgs)`
`T` `setImages(processing.core.PImage theImageDefault, processing.core.PImage theImageOver, processing.core.PImage theImageActive)` by default controllers use simple shapes, to replace these shapes with images, use setImages().
`T` `setImages(processing.core.PImage theImageDefault, processing.core.PImage theImageOver, processing.core.PImage theImageActive, processing.core.PImage theImageHighlight)`
`T` `setLabelVisible(boolean theValue)` show or hide the labels of a controller.
`T` `setLock(boolean theValue)` sets the lock status of the controller
`T` `setMax(float theValue)` sets the maximum value of the Controller.
`T` `setMin(float theValue)` sets the minimum value of the Controller.
`T` `setMouseOver(boolean theFlag)`
`boolean` `setMousePressed(boolean theStatus)`
`T` `setMoveable(boolean theValue)` enable or prevent the controller to be moveable.
`T` `setParent(ControllerInterface<?> theParent)` set the parent of a parent of a controller.
`T` `setPosition(float theX, float theY)` set the position of a controller.
`T` `setPosition(processing.core.PVector thePVector)`
`T` `setSize(int theWidth, int theHeight)`
`T` `setSize(processing.core.PImage theImage)` auto-updates the size of a controller according to the dimensions of the PImage.
`T` `setStringValue(java.lang.String theValue)`
`T` `setTab(ControlWindow theWindow, java.lang.String theName)`
`T` `setTab(java.lang.String theName)` sets the tab of the controller.
`T` `setUpdate(boolean theFlag)` disables the update function for a controller.
`T` `setUserInteraction(boolean theValue)`
`T` `setValue(float theValue)`
`T` `setValueLabel(java.lang.String theLabel)` set or change the value of the value label of a controller.
`T` `setValueSelf(float theValue)`
`T` `setView(ControllerView<T> theDisplay)` use setDisplay to customize your controller look.
`void` `setView(ControllerView<T> theDisplay, int theMode)`
`T` `setVisible(boolean theFlag)`
`T` `setWidth(int theWidth)`
`T` `show()`
`java.lang.String` `toString()`
`T` `unlock()` enables the controller to be moved, changed and controlled by the user.
`T` `unplugFrom(java.lang.Object theObject)` unplugs the Controller for a single object
`T` `unplugFrom(java.lang.Object[] theObjects)` unplugs the controller from a list of objects
`T` `unregisterTooltip()`
`T` `update()` updates the value of the controller without having to set the value explicitly.
`T` `updateAbsolutePosition()`
`T` `updateEvents()` updateEvents is used for internal updates of a controller.
`T` `updateInternalEvents(processing.core.PApplet theApplet)` a method for putting input events like e.g.
`T` `updateSize()`

### Methods inherited from class java.lang.Object

`equals, getClass, hashCode, notify, notifyAll, wait, wait, wait`

### Methods inherited from interface controlP5.ControllerInterface

`parent, setColorLabel, setColorValue, setLabel`

### Field Detail

#### autoHeight

    public static int autoHeight

#### autoSpacing

    public static processing.core.PVector autoSpacing

#### autoWidth

    public static int autoWidth

### Constructor Detail

#### Controller

    public Controller(ControlP5 theControlP5,
              java.lang.String theName)

Convenience constructor to extend Controller.

Parameters:
  `theControlP5` -
  `theName` -

+Example
  `

      /**
       * ControlP5 extending Controllers
       *
       * the following example shows how to extend the Controller class to
       * create customizable Controllers. You can either extend the Controller class itself,
       * or any class that extends Controller itself like the Slider, Button, DropdownList, etc.
       *
       * How to:
       *
       * 1) do a super call to the convenience constructor requiring
       * 2 parameter (ControlP5 instance, name)
       *
       * 2) the Controller class has a set of empty methods that allow you to capture
       * inputs from the mouse including
       * onEnter(), onLeave(), onPress(), onRelease(), onClick(), onScroll(int), onDrag()
       * These you can override and include functionality as needed.
       *
       * 3) use method getPointer() to return the local (relative)
       * xy-coordinates of the controller
       *
       * 4) after instantiation custom controllers are treated the same
       * as default controlP5 controllers.
       *
       * by Andreas Schlegel, 2012
       * www.sojamo.de/libraries/controlp5
       *
       */

      import controlP5.*;

      ControlP5 cp5;
      PApplet p;

      void setup() {
        size(400, 400);
        cp5 = new ControlP5(this);

        // create 2 groups to show nesting of custom controllers and
        //
        Group g1 = cp5.addGroup("a").setPosition(0,100).setWidth(180);
        Group g2 = cp5.addGroup("b").setPosition(0,10).setWidth(180);
        g2.moveTo(g1);

        // create 2 custom Controllers from class MyButton
        // MyButton extends Controller and inherits all methods accordingly.
        new MyButton(cp5, "b1").setPosition(0, 0).setSize(180, 200).moveTo(g2);
        new MyButton(cp5, "b2").setPosition(205, 15).setSize(180, 200);

      }

      void draw() {
        background(0);
      }

      // b1 will be called from Controller b1
      public void b1(float theValue) {
        println("yay button "+theValue);
      }

      public void controlEvent(ControlEvent theEvent) {
        println("controlEvent : "+theEvent);
      }

      // Create a custom Controller, please not that
      // MyButton extends Controller<MyButton>, <MyButton>
      // is an indicator for the super class about the type of
      // custom controller to be created.

      class MyButton extends Controller<MyButton> {

        int current = 0xffff0000;

        float a = 128;

        float na;

        int y;

        // use the convenience constructor of super class Controller
        // MyButton will automatically registered and move to the
        // default controlP5 tab.

        MyButton(ControlP5 cp5, String theName) {
          super(cp5, theName);

          // replace the default view with a custom view.
          setView(new ControllerView() {
            public void display(PApplet p, Object b) {
              // draw button background
              na += (a-na) * 0.1;
              p.fill(current,na);
              p.rect(0, 0, getWidth(), getHeight());

              // draw horizontal line which can be moved on the x-axis
              // using the scroll wheel.
              p.fill(0,255,0);
              p.rect(0,y,width,10);

              // draw the custom label
              p.fill(128);
              translate(0,getHeight()+14);
              p.text(getName(),0,0);
              p.text(getName(),0,0);

            }
          }
          );
        }

        // override various input methods for mouse input control
        void onEnter() {
          cursor(HAND);
          println("enter");
          a = 255;
        }

        void onScroll(int n) {
          println("scrolling");
          y -= n;
          y = constrain(y,0,getHeight()-10);
        }

        void onPress() {
          println("press");
          current = 0xffffff00;
        }

        void onClick() {
          Pointer p1 = getPointer();
          println("clicked at "+p1.x()+", "+p1.y());
          current = 0xffffff00;
          setValue(y);
        }

        void onRelease() {
          println("release");
          current = 0xffffffff;
        }

        void onMove() {
          println("moving "+this+" "+_myControlWindow.getMouseOverList());
        }

        void onDrag() {
          current = 0xff0000ff;
          Pointer p1 = getPointer();
          float dif = dist(p1.px(),p1.py(),p1.x(),p1.y());
          println("dragging at "+p1.x()+", "+p1.y()+" "+dif);
        }

        void onReleaseOutside() {
          onLeave();
        }

        void onLeave() {
          println("leave");
          cursor(ARROW);
          a = 128;
        }
      }

  `

### Method Detail

#### add

    public T add(ControllerInterface<?> theElement)

Specified by:
  `add` in interface `ControllerInterface<T>`
Parameters:
  `theElement` - ControllerInterface
Returns:
  Controller

#### addCallback

    public T addCallback(CallbackListener theListener)

Parameters:
  `theListener` -
Returns:
  Controller
See Also:
  `CallbackListener`

#### addListener

    public T addListener(ControlListener theListener)

Specified by:
  `addListener` in interface `ControllerInterface<T>`
Parameters:
  `theListener` - ControlListener
Returns:
  Controller
See Also:
  `ControlListener`

#### align

    public T align(int theCaptionX,
          int theCaptionY,
          int theValueX,
          int theValueY)

#### bringToFront

    public T bringToFront()

Specified by:
  `bringToFront` in interface `ControllerInterface<T>`

#### bringToFront

    public T bringToFront(ControllerInterface<?> theController)

Specified by:
  `bringToFront` in interface `ControllerInterface<T>`

#### changeValue

    public final T changeValue(float theValue)

sets the value of the controller without sending the broadcast event. this function is final.

Parameters:
  `theValue` - float
Returns:
  Controller

#### continuousUpdateEvents

    public final void continuousUpdateEvents()

continuousUpdateEvents is used for internal updates of a controller. this method is final and can't be overridden.

Specified by:
  `continuousUpdateEvents` in interface `ControllerInterface<T>`

#### draw

    public void draw(processing.core.PGraphics theGraphics)

the default draw function for each controller extending superclass Controller. This draw function will take care of default matrix operations and will call the display function of the current ControllerView object active for this particular controller.

Specified by:
  `draw` in interface `CDrawable`
Specified by:
  `draw` in interface `ControllerInterface<T>`
Parameters:
  `theApplet` - PApplet
See Also:
  `ControllerView`

#### getAbsolutePosition

    public processing.core.PVector getAbsolutePosition()

Specified by:
  `getAbsolutePosition` in interface `ControllerInterface<T>`
Returns:
  `PVector`

#### getAddress

    public java.lang.String getAddress()

Specified by:
  `getAddress` in interface `ControllerInterface<T>`

#### getArrayValue

    public float[] getArrayValue()

returns the current float array value of a controller.

Specified by:
  `getArrayValue` in interface `ControllerInterface<T>`
Returns:
  float[]
See Also:
  `getValue()`, `getStringValue()`

#### getArrayValue

    public float getArrayValue(int theIndex)

Specified by:
  `getArrayValue` in interface `ControllerInterface<T>`
Parameters:
  `theIndex` -
Returns:
  float

#### getBehavior

    public ControlBehavior getBehavior()

Returns:
  ControlBehavior

#### getCaptionLabel

    public Label getCaptionLabel()

Returns:
  Label
See Also:
  `Label`

#### getColor

    public CColor getColor()

Specified by:
  `getColor` in interface `ControllerInterface<T>`

#### getControllerPlugList

    public java.util.List<ControllerPlug> getControllerPlugList()

Returns:
  List<ControllerPlug>

#### getControlWindow

    public ControlWindow getControlWindow()

Returns:
  ControlWindow

#### getDecimalPrecision

    public int getDecimalPrecision()

Returns:
  int

#### getDefaultValue

    public float getDefaultValue()

Returns:
  float

#### getHeight

    public int getHeight()

Specified by:
  `getHeight` in interface `ControllerInterface<T>`
Returns:
  int

#### getId

    public int getId()

returns the id of a controller, by default the id is -1. Any int can be given to a controller as its ID, controlP5 does not recognize duplicates, this has to be managed on the user site.

Specified by:
  `getId` in interface `ControllerInterface<T>`
Returns:
  int

#### getInfo

    public java.lang.String getInfo()

Returns:
  String

#### getLabel

    public java.lang.String getLabel()

returns the controller's caption label text.

Returns:
  String

#### getMax

    public float getMax()

returns the maximum value of the controller.

Returns:
  float

#### getMin

    public float getMin()

returns the minimum value of the controller.

Returns:
  float

#### getName

    public java.lang.String getName()

returns the index name of the controller.

Specified by:
  `getName` in interface `ControllerInterface<T>`
Returns:
  String

#### getParent

    public ControllerInterface<?> getParent()

returns the parent of a controller.

Specified by:
  `getParent` in interface `ControllerInterface<T>`
Returns:
  ControllerInterface

#### getPickingColor

    public int getPickingColor()

Specified by:
  `getPickingColor` in interface `ControllerInterface<T>`

#### getPointer

    public Pointer getPointer()

#### getPosition

    public processing.core.PVector getPosition()

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

Specified by:
  `getPosition` in interface `ControllerInterface<T>`

#### getProperty

    public ControllerProperty getProperty(java.lang.String thePropertyName)

Specified by:
  `getProperty` in interface `ControllerInterface<T>`

#### getProperty

    public ControllerProperty getProperty(java.lang.String theSetter,
                                 java.lang.String theGetter)

Specified by:
  `getProperty` in interface `ControllerInterface<T>`

#### getStringValue

    public java.lang.String getStringValue()

Specified by:
  `getStringValue` in interface `ControllerInterface<T>`
Returns:
  String
See Also:
  `getValue()`, `getArrayValue()`

#### getTab

    public Tab getTab()

get the instance of the tab the controller belongs to.

Specified by:
  `getTab` in interface `ControllerInterface<T>`
Returns:
  Tab

#### getValue

    public float getValue()

Specified by:
  `getValue` in interface `ControllerInterface<T>`
Returns:
  float
See Also:
  `getStringValue()`, `getArrayValue()`

#### getValueLabel

    public Label getValueLabel()

Returns:
  Label

#### getView

    public ControllerView<T> getView()

#### getWidth

    public int getWidth()

Specified by:
  `getWidth` in interface `ControllerInterface<T>`
Returns:
  int

#### getWindow

    public ControlWindow getWindow()

returns the control window of the controller

Specified by:
  `getWindow` in interface `ControllerInterface<T>`
Returns:
  ControlWindow

#### hide

    public T hide()

Specified by:
  `hide` in interface `ControllerInterface<T>`
Returns:
  Controller

#### init

    public void init()

Specified by:
  `init` in interface `ControllerInterface<T>`

#### isActive

    public boolean isActive()

checks if a controller is active.

Returns:
  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

#### isInside

    public boolean isInside()

returns true or false and indicates if the mouse is inside the area of a controller.

Returns:
  boolean

#### isLabelVisible

    public boolean isLabelVisible()

Returns:
  boolean

#### isListening

    public boolean isListening()

returns true or false for the current listening status. by default it is set to false

Returns:
  boolean
See Also:
  `listen(boolean)`

#### isLock

    public boolean isLock()

Returns:
  boolean

#### isMouseOver

    public boolean isMouseOver()

check if the mouse is within this particular controller.

Specified by:
  `isMouseOver` in interface `ControllerInterface<T>`
Returns:
  boolean

#### isMousePressed

    public boolean isMousePressed()

returns true or false if the mouse has is pressed.

Returns:
  boolean

#### isMoveable

    public boolean isMoveable()

checks if a controller is moveable.

Returns:
  boolean

#### isUpdate

    public boolean isUpdate()

enables the update function for a controller.

Specified by:
  `isUpdate` in interface `ControllerInterface<T>`
Returns:
  boolean
See Also:
  `update()`, `setUpdate(boolean)`

#### isUserInteraction

    public boolean isUserInteraction()

Returns:
  boolean

#### isVisible

    public boolean isVisible()

Specified by:
  `isVisible` in interface `ControllerInterface<T>`
Returns:
  boolean

#### keyEvent

    public void keyEvent(processing.event.KeyEvent theEvent)

Specified by:
  `keyEvent` in interface `ControllerInterface<T>`
Parameters:
  `KeyEvent` - theEvent

#### linebreak

    public T linebreak()

Returns:
  Controller

#### listen

    public T listen(boolean theValue)

enables a controller to listen to changes made to the variable linked to the controller. Use true to enable and false to disable a controller from listening to changes.

Parameters:
  `theFlag` -
Returns:
  Controller

#### listenerSize

    public int listenerSize()

Returns:
  int

#### lock

    public T lock()

disables the controller to be moved, or changed or controlled by the user.

Returns:
  Controller

#### moveTo

    public final T moveTo(ControlGroup<?> theGroup)

Parameters:
  `theGroup` -
Returns:
  Controller

#### moveTo

    public final T moveTo(ControllerGroup<?> theGroup)

Specified by:
  `moveTo` in interface `ControllerInterface<T>`

#### moveTo

    public final T moveTo(ControllerGroup<?> theGroup,
           Tab theTab,
           ControlWindow theControlWindow)

Specified by:
  `moveTo` in interface `ControllerInterface<T>`

#### moveTo

    public final T moveTo(ControlWindow theControlWindow)

moves the controller to the default tab of a control window - other than the main window.

Parameters:
  `theControlWindow` -

#### moveTo

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

Parameters:
  `theControlWindow` -
  `theTabName` -
Returns:
  Controller

#### moveTo

    public final T moveTo(processing.core.PApplet theApplet)

moves the controller to the default tab inside the main window.

Parameters:
  `theApplet` -
Returns:
  Controller

#### moveTo

    public final T moveTo(processing.core.PApplet theApplet,
           java.lang.String theTabName)

moves the controller to a tab inside the main window.

Parameters:
  `theApplet` -
  `theTabName` -

#### moveTo

    public final T moveTo(java.lang.String theTabName)

moves the controller to another tab. The tab is defined by parameter theTabName. if controlP5 can't find a tab with given name, controlP5 will create this tab and add it to the main window.

Parameters:
  `theTabName` - String
Returns:
  Controller

#### moveTo

    public final T moveTo(Tab theTab)

moves the controller to another tab.

Parameters:
  `theTab` -
Returns:
  Controller

#### plugTo

    public T plugTo(java.lang.Object theObject)

Parameters:
  `theObject` -
Returns:
  Controller

#### plugTo

    public T plugTo(java.lang.Object[] theObjects)

plugs the controller to a list of objects

Parameters:
  `theObject` -
Returns:
  Controller

#### plugTo

    public T plugTo(java.lang.Object[] theObjects,
           java.lang.String theName)

Parameters:
  `theObjects` -
  `theName` -
Returns:
  Controller

#### plugTo

    public T plugTo(java.lang.Object theObject,
           java.lang.String theName)

#### registerProperty

    public T registerProperty(java.lang.String thePropertyName)

Specified by:
  `registerProperty` in interface `ControllerInterface<T>`

#### registerProperty

    public T registerProperty(java.lang.String theSetter,
                     java.lang.String theGetter)

Specified by:
  `registerProperty` in interface `ControllerInterface<T>`

#### registerTooltip

    public T registerTooltip(java.lang.String theText)

adds a tooltip to a controller, by default the tooltip is disabled. A Tooltip is made visible when entering a controller with the mouse, when the mouse is moved inside the controller, the tooltip will hide.

Parameters:
  `theText` -
Returns:
  Controller

#### remove

    public void remove()

removes a controller from controlP5.

Specified by:
  `remove` in interface `ControllerInterface<T>`

#### remove

    public T remove(ControllerInterface<?> theElement)

Specified by:
  `remove` in interface `ControllerInterface<T>`
Parameters:
  `theElement` - ControllerInterface
Returns:
  Controller

#### removeBehavior

    public T removeBehavior()

Returns:
  Controller

#### removeCallback

    public T removeCallback()

Returns:
  Controller

#### removeCallback

    public T removeCallback(CallbackListener theListener)

Parameters:
  `theListener` -
Returns:
  Controller
See Also:
  `CallbackListener`

#### removeListener

    public T removeListener(ControlListener theListener)

Parameters:
  `theListener` - ControlListener
Returns:
  Controller
See Also:
  `ControlListener`

#### removeProperty

    public T removeProperty(java.lang.String thePropertyName)

Specified by:
  `removeProperty` in interface `ControllerInterface<T>`

#### removeProperty

    public T removeProperty(java.lang.String theSetter,
                   java.lang.String theGetter)

Specified by:
  `removeProperty` in interface `ControllerInterface<T>`

#### setAbsolutePosition

    public T setAbsolutePosition(processing.core.PVector thePVector)

Specified by:
  `setAbsolutePosition` in interface `ControllerInterface<T>`

#### setAddress

    public T setAddress(java.lang.String theAddress)

Specified by:
  `setAddress` in interface `ControllerInterface<T>`

#### setArrayValue

    public T setArrayValue(float[] theArray)

Specified by:
  `setArrayValue` in interface `ControllerInterface<T>`
Parameters:
  `theArray` -
Returns:
  Controller

#### setArrayValue

    public T setArrayValue(int theIndex,
                  float theValue)

Specified by:
  `setArrayValue` in interface `ControllerInterface<T>`
Parameters:
  `theIndex` -
  `theValue` -
Returns:
  Controller

#### setBehavior

    public T 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
Returns:
  Controller

#### setBroadcast

    public T 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
Returns:
  Controller

#### setCaptionLabel

    public T setCaptionLabel(java.lang.String theLabel)

sets the content of the caption label of a controller.

Specified by:
  `setCaptionLabel` in interface `ControllerInterface<T>`
Parameters:
  `theLabel` -
Returns:
  Controller

#### setColor

    public T setColor(CColor theColor)

Specified by:
  `setColor` in interface `ControllerInterface<T>`

#### setColorActive

    public T setColorActive(int theColor)

Specified by:
  `setColorActive` in interface `ControllerInterface<T>`

#### setColorBackground

    public T setColorBackground(int theColor)

Specified by:
  `setColorBackground` in interface `ControllerInterface<T>`

#### setColorCaptionLabel

    public T setColorCaptionLabel(int theColor)

Parameters:
  `theColor` -
Returns:
  Controller

#### setColorForeground

    public T setColorForeground(int theColor)

Specified by:
  `setColorForeground` in interface `ControllerInterface<T>`

#### setColorValueLabel

    public T setColorValueLabel(int theColor)

Parameters:
  `theColor` -
Returns:
  Controller

#### setDecimalPrecision

    public T 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` -
Returns:
  Controller

#### setDefaultValue

    public T setDefaultValue(float theValue)

set the default value.

Parameters:
  `theValue` - float
Returns:
  Controller

#### setGroup

    public final T setGroup(ControllerGroup<?> theGroup)

#### setGroup

    public final T setGroup(java.lang.String theName)

sets the group of the controller.

Parameters:
  `theName` - String
Returns:
  Controller

#### setHeight

    public T setHeight(int theHeight)

Parameters:
  `theHeight` -
Returns:
  Controller

#### setId

    public T setId(int theId)

set the id of a controller.

Specified by:
  `setId` in interface `ControllerInterface<T>`
Parameters:
  `int` - theId
Returns:
  Controller

#### setImage

    public T setImage(processing.core.PImage theImage)

#### setImage

    public T setImage(processing.core.PImage theImage,
             int theState)

Parameters:
  `theImage` -
  `theState` - use Controller.DEFAULT (background) Controller.OVER (foreground) Controller.ACTIVE (active)

#### setImages

    public T setImages(processing.core.PImage... imgs)

#### setImages

    public T setImages(processing.core.PImage theImageDefault,
              processing.core.PImage theImageOver,
              processing.core.PImage theImageActive)

by default controllers use simple shapes, to replace these shapes with images, use setImages(). This can be handy for buttons, toggles, bangs, for more complex controllers such as sliders, range, dropdownlist this is not advisable.

Parameters:
  `theImageDefault` -
  `theImageOver` -
  `theImageActive` -
Returns:
  Controller

#### setImages

    public T setImages(processing.core.PImage theImageDefault,
              processing.core.PImage theImageOver,
              processing.core.PImage theImageActive,
              processing.core.PImage theImageHighlight)

#### setLabelVisible

    public T setLabelVisible(boolean theValue)

show or hide the labels of a controller.

Parameters:
  `theValue` - boolean
Returns:
  Controller

#### setLock

    public T setLock(boolean theValue)

sets the lock status of the controller

Parameters:
  `theValue` -
Returns:
  Controller

#### setMax

    public T setMax(float theValue)

sets the maximum value of the Controller.

Parameters:
  `theValue` - float
Returns:
  Controller

#### setMin

    public T setMin(float theValue)

sets the minimum value of the Controller.

Parameters:
  `theValue` - float
Returns:
  Controller

#### setMouseOver

    public T setMouseOver(boolean theFlag)

Specified by:
  `setMouseOver` in interface `ControllerInterface<T>`

#### setMousePressed

    public final boolean setMousePressed(boolean theStatus)

Specified by:
  `setMousePressed` in interface `ControllerInterface<T>`
Parameters:
  `theStatus` - boolean
Returns:
  boolean

#### setMoveable

    public T setMoveable(boolean theValue)

enable or prevent the controller to be moveable. By default a controller is moveable.

Parameters:
  `theValue` - boolean
Returns:
  Controller

#### setParent

    public final T 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
Returns:
  Controller

#### setPosition

    public T setPosition(float theX,
                float theY)

set the position of a controller. The position of a controller is relative.

Specified by:
  `setPosition` in interface `ControllerInterface<T>`
Parameters:
  `theX` - float
  `theY` - float
Returns:
  Controller

#### setPosition

    public T setPosition(processing.core.PVector thePVector)

Specified by:
  `setPosition` in interface `ControllerInterface<T>`

#### setSize

    public T setSize(int theWidth,
            int theHeight)

Parameters:
  `theWidth` -
  `theHeight` -
Returns:
  Controller

#### setSize

    public T setSize(processing.core.PImage theImage)

auto-updates the size of a controller according to the dimensions of the PImage.

Parameters:
  `theImage` -
Returns:
  Controller

#### setStringValue

    public T setStringValue(java.lang.String theValue)

Specified by:
  `setStringValue` in interface `ControllerInterface<T>`
Parameters:
  `theValue` -
Returns:
  Controller

#### setTab

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

#### setTab

    public final T setTab(java.lang.String theName)

sets the tab of the controller.

Parameters:
  `theName` - String
Returns:
  Controller

#### setUpdate

    public T setUpdate(boolean theFlag)

disables the update function for a controller.

Specified by:
  `setUpdate` in interface `ControllerInterface<T>`
Parameters:
  `theFlag` - boolean
Returns:
  Controller
See Also:
  `update()`, `isUpdate()`

#### setUserInteraction

    public T setUserInteraction(boolean theValue)

#### setValue

    public T setValue(float theValue)

Specified by:
  `setValue` in interface `ControllerInterface<T>`
Parameters:
  `theValue` - float

#### setValueLabel

    public T 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` -
Returns:
  Controller

#### setValueSelf

    public T setValueSelf(float theValue)

#### setView

    public T setView(ControllerView<T> theDisplay)

use setDisplay to customize your controller look. A new controller-display class required to implement interface ControllerView. By default the display mode will be set to CUSTOM when setting a new display.

Parameters:
  `theDisplay` -
Returns:
  Controller
See Also:
  `ControllerView`

#### setView

    public void setView(ControllerView<T> theDisplay,
               int theMode)

#### setVisible

    public T setVisible(boolean theFlag)

Parameters:
  `theFlag` - boolean
Returns:
  Controller

#### setWidth

    public T setWidth(int theWidth)

Parameters:
  `theWidth` -
Returns:
  Controller

#### show

    public T show()

Specified by:
  `show` in interface `ControllerInterface<T>`
Returns:
  Controller

#### toString

    public java.lang.String toString()

Overrides:
  `toString` in class `java.lang.Object`

#### unlock

    public T unlock()

enables the controller to be moved, changed and controlled by the user.

Returns:
  Controller

#### unplugFrom

    public T unplugFrom(java.lang.Object theObject)

unplugs the Controller for a single object

Parameters:
  `theObject` -
Returns:
  Controller

#### unplugFrom

    public T unplugFrom(java.lang.Object[] theObjects)

unplugs the controller from a list of objects

Parameters:
  `theObjects` -
Returns:

#### unregisterTooltip

    public T unregisterTooltip()

Returns:
  Controller
See Also:
  `registerTooltip(String)`

#### update

    public T 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<T>`
Returns:
  Controller
See Also:
  `setUpdate(boolean)`, `isUpdate()`

#### updateAbsolutePosition

    public T updateAbsolutePosition()

Specified by:
  `updateAbsolutePosition` in interface `ControllerInterface<T>`

#### updateEvents

    public final T 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<T>`

#### updateInternalEvents

    public T 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<T>`
See Also:
  `ControllerInterface.updateInternalEvents`

#### updateSize

    public T updateSize()