controlP5
Class Range

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

public class Range
extends Controller

a slider.

+Example
/**
 * ControlP5 Slider. Horizontal and vertical sliders, 
 * with and without tick marks and snap-to-tick.
 * by andreas schlegel, 2010
 */

import controlP5.*;

ControlP5 controlP5;
int myColor = color(0,0,0);

int sliderValue = 100;
int sliderTicks1 = 100;
int sliderTicks2 = 30;


void setup() {
  size(400,400);
  controlP5 = new ControlP5(this);
  // add a vertical slider
  controlP5.addSlider("slider",0,200,128,20,100,10,100);
  // create another slider with tick marks, now without
  // default value, the initial value will be set according th
  // the value of variable sliderTicks2 then.
  controlP5.addSlider("sliderTicks1",0,255,100,100,10,100);
  Slider s1 = (Slider)controlP5.controller("sliderTicks1");
  s1.setNumberOfTickMarks(5);
  
  
  // add horizontal sliders
  controlP5.addSlider("sliderValue",0,255,128,200,180,100,10);
  controlP5.addSlider("sliderTicks2",0,255,128,200,220,100,10);
  Slider s2 = (Slider)controlP5.controller("sliderTicks2");
  s2.setNumberOfTickMarks(7);
  // use Slider.FIX or Slider.FLEXIBLE to change the slider handle
  // by default it is Slider.FIX
  s2.setSliderMode(Slider.FLEXIBLE);
  
}

void draw() {
  background(sliderTicks1);
  
  fill(sliderValue);
  rect(0,0,width,100);
  
  fill(myColor);
  rect(0,300,width,70);
  
  fill(sliderTicks2);
  rect(0,370,width,30);
}

void slider(float theColor) {
  myColor = color(theColor);
  println("a slider event. setting background to "+theColor);
}


Field Summary
 int alignValueLabel
           
static int FIX
           
static int FLEXIBLE
           
 int valueLabelPositioning
           
 
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, 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
 
Constructor Summary
Range(ControlP5 theControlP5, ControllerGroup theParent, java.lang.String theName, float theMin, float theMax, float theDefaultMinValue, float theDefaultMaxValue, int theX, int theY, int theWidth, int theHeight)
           
 
Method Summary
 void addToXMLElement(ControlP5XMLElement theElement)
           
 float[] arrayValue()
           
 void draw(processing.core.PApplet theApplet)
          the default draw function for each controller extending superclass Controller.
 TickMark getTickMark()
           
 float highValue()
           
 float lowValue()
           
 void mouseReleased()
           
 void mouseReleasedOutside()
           
 void onLeave()
           
 void setDraggable(boolean theFlag)
           
 Controller setHeight(int theValue)
          set the height of the slider.
 void setHighValue(float theValue)
           
 void setLowValue(float theValue)
           
 void setMax(float theValue)
          set the maximum value of the slider.
 void setMin(float theValue)
          set the minimum value of the slider.
 void setNumberOfTickMarks(int theNumber)
           
 void setSliderMode(int theMode)
           
 void setValue(float theValue)
          set the value of the range-slider.
 Controller setWidth(int theValue)
          set the width of the slider.
 void showTickMarks(boolean theFlag)
           
 void snapToTickMarks(boolean theFlag)
           
 void update()
          updates the value of the controller without having to set the value explicitly.
 void updateInternalEvents(processing.core.PApplet theApplet)
          TODO
 
Methods inherited from class controlP5.Controller
absolutePosition, add, addListener, behavior, captionLabel, changeValue, color, continuousUpdateEvents, controlWindow, defaultValue, disableSprite, 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, setId, setImage, setImage, setImages, setImages, setLabel, setLabelVisible, setLock, setMousePressed, setMoveable, setParent, setPosition, setSize, setSize, setSprite, setTab, setTab, setUpdate, setUserInteraction, setValueLabel, setVisible, setWindow, setWindow, show, stringValue, toString, trigger, unlock, unplugFrom, unplugFrom, updateAbsolutePosition, updateEvents, updateSize, value, valueLabel
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

FIX

public static final int FIX
See Also:
Constant Field Values

FLEXIBLE

public static final int FLEXIBLE
See Also:
Constant Field Values

alignValueLabel

public int alignValueLabel

valueLabelPositioning

public int valueLabelPositioning
Constructor Detail

Range

public Range(ControlP5 theControlP5,
             ControllerGroup theParent,
             java.lang.String theName,
             float theMin,
             float theMax,
             float theDefaultMinValue,
             float theDefaultMaxValue,
             int theX,
             int theY,
             int theWidth,
             int theHeight)
Parameters:
theControlP5 - ControlP5
theParent - ControllerGroup
theName - String
theMin - float
theMax - float
theDefaultValue - float
theX - int
theY - int
theWidth - int
theHeight - int
Method Detail

setSliderMode

public void setSliderMode(int theMode)
Parameters:
theMode - int

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

draw

public void draw(processing.core.PApplet theApplet)
Description copied from class: Controller
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 ControllerDisplay object active for this particular controller.

Specified by:
draw in interface CDrawable
Specified by:
draw in interface ControllerInterface
Overrides:
draw in class Controller
Parameters:
theApplet - PApplet
See Also:
ControllerDisplay

setValue

public void setValue(float theValue)
set the value of the range-slider.

Specified by:
setValue in class Controller
Parameters:
theValue - 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

setDraggable

public void setDraggable(boolean theFlag)

arrayValue

public float[] arrayValue()
Overrides:
arrayValue in class Controller

setMin

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

Overrides:
setMin in class Controller
Parameters:
theValue - float

setMax

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

Overrides:
setMax in class Controller
Parameters:
theValue - float

lowValue

public float lowValue()

highValue

public float highValue()

setLowValue

public void setLowValue(float theValue)

setHighValue

public void setHighValue(float theValue)

setWidth

public Controller setWidth(int theValue)
set the width of the slider.

Overrides:
setWidth in class Controller
Parameters:
theValue - int

setHeight

public Controller setHeight(int theValue)
set the height of the slider.

Overrides:
setHeight in class Controller
Parameters:
theValue - int

mouseReleased

public void mouseReleased()

mouseReleasedOutside

public void mouseReleasedOutside()

onLeave

public void onLeave()

setNumberOfTickMarks

public void setNumberOfTickMarks(int theNumber)

showTickMarks

public void showTickMarks(boolean theFlag)

snapToTickMarks

public void snapToTickMarks(boolean theFlag)

getTickMark

public TickMark getTickMark()

addToXMLElement

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


processing library controlP5 by Andreas Schlegel. (c) 2010