controlP5
Class Knob

java.lang.Object
  extended by controlP5.Controller
      extended by controlP5.Knob
All Implemented Interfaces:
CDrawable, ControllerInterface, ControlP5Constants

public class Knob
extends Controller

a knob. description tbd.

+Example
/**
 * ControlP5 Knob
 * by andreas schlegel, 2009
 */
 
import controlP5.*;


ControlP5 controlP5;

int myColorBackground = color(0,0,0);

int knobValue = 100;

Knob myKnobA;

Knob myKnobB;

void setup() {
  size(400,400);
  smooth();
  controlP5 = new ControlP5(this);
  myKnobA = controlP5.addKnob("knob",0,360,0,100,160,40);
  myKnobB = controlP5.addKnob("knobValue",100,200,128,100,240,40);
  myKnobA.setOffsetAngle(-HALF_PI);
}

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


void knob(int theValue) {
  myColorBackground = color(theValue);
  println("a knob event. setting background to "+theValue);
}


void keyPressed() {
  myKnobA.setValue(180);
}

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
Knob(ControlP5 theControlP5, ControllerGroup theParent, java.lang.String theName, float theMin, float theMax, float theDefaultValue, int theX, int theY, int theWidth)
           
 
Method Summary
 void addToXMLElement(ControlP5XMLElement theElement)
           
 int getDragDirection()
          get the drag direction which is either Controller.HORIZONTAL or Controller.VERTICAL.
 float getRange()
          get the range value.
 float getResolution()
           
 float getStartAngle()
          get the start angle, 0 is at 3 o'clock.
 void mousePressed()
           
 void mouseReleased()
           
 void mouseReleasedOutside()
           
 void setDisplayStyle(int theStyle)
          set the display style of a know.
 void setDragDirection(int theValue)
          set the drag direction, when controlling a knob, parameter is either Controller.HORIZONTAL or Controller.VERTICAL.
 void setMax(float theValue)
          set the maximum value of the knob.
 void setMin(float theValue)
          set the minimum value of the knob.
 void setNumberOfTickMarks(int theNumber)
           
 void setOffsetAngle(float theValue)
          Deprecated.  
 void setRange(float theRange)
          set the range in between which the know operates.
 void setResolution(float theValue)
          resolution is a sensitivity value when dragging a knob.
 void setStartAngle(float theAngle)
          The start angle is a value between 0 and TWO_PI.
 void setTickMarkLength(int theLength)
           
 void setTickMarkWeight(float theWeight)
           
 void setValue(float theValue)
          set the value of the controller.
 void showTickMarks(boolean theFlag)
           
 void snapToTickMarks(boolean theFlag)
           
 void update()
          updates the value of the controller without having to set the value explicitly.
 void updateDisplayMode(int theMode)
           
 void updateInternalEvents(processing.core.PApplet theApplet)
          TODO
 float value()
          get the current value of the controller.
 
Methods inherited from class controlP5.Controller
absolutePosition, add, addListener, arrayValue, behavior, captionLabel, changeValue, color, continuousUpdateEvents, controlWindow, defaultValue, disableSprite, draw, enableSprite, getAsXML, getColor, getHeight, getPickingColor, getSprite, getTab, getWidth, getWindow, hide, id, init, isBroadcast, isInside, isLock, isMousePressed, isMoveable, isUpdate, isUserInteraction, isVisible, isXMLsavable, keyEvent, label, linebreak, listenerSize, lock, max, min, moveTo, moveTo, moveTo, moveTo, moveTo, moveTo, moveTo, moveTo, moveTo, name, parent, plugTo, plugTo, position, remove, remove, removeBehavior, removeListener, setArrayValue, setBehavior, setBroadcast, setCaptionLabel, setColor, setColorActive, setColorBackground, setColorCaptionLabel, setColorForeground, setColorLabel, setColorValue, setColorValueLabel, setDecimalPrecision, setDefaultValue, setDisplay, setDisplay, setGroup, setGroup, setHeight, setId, setImage, setImage, setImages, setImages, setLabel, setLabelVisible, setLock, setMousePressed, setMoveable, setParent, setPosition, setSize, setSize, setSprite, setTab, setTab, setUpdate, setUserInteraction, setValueLabel, setVisible, setWidth, setWindow, setWindow, show, stringValue, toString, trigger, unlock, unplugFrom, unplugFrom, updateAbsolutePosition, updateEvents, updateSize, valueLabel
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Knob

public Knob(ControlP5 theControlP5,
            ControllerGroup theParent,
            java.lang.String theName,
            float theMin,
            float theMax,
            float theDefaultValue,
            int theX,
            int theY,
            int theWidth)
Method Detail

setStartAngle

public void setStartAngle(float theAngle)
The start angle is a value between 0 and TWO_PI. By default the start angle is set to HALF_PI + PI * 0.25f

Parameters:
theAngle -

getStartAngle

public float getStartAngle()
get the start angle, 0 is at 3 o'clock.

Returns:

setRange

public void setRange(float theRange)
set the range in between which the know operates. By default the range is PI + HALF_PI

Parameters:
theRange -

getRange

public float getRange()
get the range value.

Returns:

setDragDirection

public void setDragDirection(int theValue)
set the drag direction, when controlling a knob, parameter is either Controller.HORIZONTAL or Controller.VERTICAL.

Parameters:
theValue -

getDragDirection

public int getDragDirection()
get the drag direction which is either Controller.HORIZONTAL or Controller.VERTICAL.

Returns:

setResolution

public void setResolution(float theValue)
resolution is a sensitivity value when dragging a knob. the higher the value, the more sensitive the dragging.

Parameters:
theValue -

getResolution

public float getResolution()

setNumberOfTickMarks

public void setNumberOfTickMarks(int theNumber)

showTickMarks

public void showTickMarks(boolean theFlag)

snapToTickMarks

public void snapToTickMarks(boolean theFlag)

setTickMarkLength

public void setTickMarkLength(int theLength)

setTickMarkWeight

public void setTickMarkWeight(float theWeight)

updateInternalEvents

public void updateInternalEvents(processing.core.PApplet theApplet)
Description copied from class: Controller
TODO

Specified by:
updateInternalEvents in interface ControllerInterface
Overrides:
updateInternalEvents in class Controller
See Also:
ControllerInterface.updateInternalEvents

mousePressed

public void mousePressed()

mouseReleased

public void mouseReleased()

mouseReleasedOutside

public void mouseReleasedOutside()

setMin

public void setMin(float theValue)
set the minimum value of the knob.

Overrides:
setMin in class Controller
Parameters:
theValue - float

setMax

public void setMax(float theValue)
set the maximum value of the knob.

Overrides:
setMax in class Controller
Parameters:
theValue - float

setValue

public void setValue(float theValue)
Description copied from class: Controller
set the value of the controller.

Specified by:
setValue in class Controller
Parameters:
theValue - float

value

public float value()
Description copied from class: Controller
get the current value of the controller.

Specified by:
value in interface ControllerInterface
Overrides:
value in class Controller
Returns:
float

update

public void update()
Description copied from class: Controller
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(). setUpdate ( )

Specified by:
update in interface ControllerInterface
Overrides:
update in class Controller

setOffsetAngle

public void setOffsetAngle(float theValue)
Deprecated. 

See Also:
setStartAngle(float)

addToXMLElement

public void addToXMLElement(ControlP5XMLElement theElement)
Parameters:
theElement - ControlP5XMLElement

setDisplayStyle

public void setDisplayStyle(int theStyle)
set the display style of a know. takes parameters Knob.LINE, Knob.ELLIPSE or Knob.ARC. default style is Knob.LINE

Parameters:
theStyle -

updateDisplayMode

public void updateDisplayMode(int theMode)


processing library controlP5 by Andreas Schlegel. (c) 2010