public abstract class ControllerGroup<T> extends java.lang.Object implements ControllerInterface<T>, ControlP5Constants, ControlListener
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 and Description |
---|
ControllerGroup(ControlP5 theControlP5,
ControllerGroup<?> theParent,
java.lang.String theName,
float theX,
float theY) |
ControllerGroup(ControlP5 theControlP5,
java.lang.String theName)
Convenience constructor to extend ControllerGroup.
|
Modifier and Type | Method and Description |
---|---|
processing.core.PVector |
absolutePosition()
Deprecated.
|
T |
add(ControllerInterface<?> theElement)
Adds a controller to the group, but use Controller.setGroup() instead.
|
Canvas |
addCanvas(Canvas theCanvas)
Adds a canvas to a controllerGroup such as a tab or group.
|
T |
addCloseButton()
TODO redesign or deprecate add a close button to the controlbar of this controlGroup.
|
T |
addDrawable(CDrawable theElement) |
T |
addListener(ControlListener theListener) |
float[] |
arrayValue()
Deprecated.
|
T |
bringToFront() |
T |
bringToFront(ControllerInterface<?> theController) |
T |
close() |
CColor |
color()
Deprecated.
|
void |
continuousUpdateEvents() |
void |
controlEvent(ControlEvent theEvent)
controlEvent is called by controlP5's ControlBroadcaster to inform available listeners about
value changes.
|
Controller<?> |
controller(java.lang.String theController)
Deprecated.
|
T |
disableCollapse() |
void |
draw(processing.core.PGraphics theGraphics) |
T |
enableCollapse() |
processing.core.PVector |
getAbsolutePosition() |
java.lang.String |
getAddress() |
float[] |
getArrayValue() |
float |
getArrayValue(int theIndex) |
Label |
getCaptionLabel() |
CColor |
getColor() |
Controller<?> |
getController(java.lang.String theController) |
int |
getHeight() |
int |
getId() |
java.lang.String |
getInfo() |
java.lang.String |
getName() |
ControllerInterface<?> |
getParent() |
int |
getPickingColor() |
processing.core.PVector |
getPosition() |
ControllerProperty |
getProperty(java.lang.String thePropertyName) |
ControllerProperty |
getProperty(java.lang.String theSetter,
java.lang.String theGetter) |
java.lang.String |
getStringValue() |
Tab |
getTab() |
float |
getValue() |
Label |
getValueLabel() |
int |
getWidth() |
ControlWindow |
getWindow() |
T |
hide() |
T |
hideArrow() |
T |
hideBar() |
int |
id()
Deprecated.
|
void |
init() |
boolean |
isBarVisible() |
boolean |
isCollapse() |
boolean |
isMouseOver() |
boolean |
isMoveable() |
boolean |
isOpen() |
boolean |
isUpdate()
checks the update status of a controller.
|
boolean |
isVisible() |
void |
keyEvent(processing.event.KeyEvent theEvent) |
int |
listenerSize() |
T |
moveTo(ControllerGroup<?> theGroup) |
T |
moveTo(ControllerGroup<?> theGroup,
Tab theTab,
ControlWindow theControlWindow) |
T |
moveTo(ControlWindow theControlWindow) |
T |
moveTo(ControlWindow theControlWindow,
java.lang.String theTabName) |
T |
moveTo(processing.core.PApplet thePApplet) |
T |
moveTo(java.lang.String theTabName) |
T |
moveTo(java.lang.String theTabName,
ControlWindow theControlWindow) |
T |
moveTo(Tab theTab) |
T |
moveTo(Tab theTab,
ControlWindow theControlWindow) |
java.lang.String |
name()
Deprecated.
|
T |
open() |
ControllerInterface<?> |
parent()
Deprecated.
|
processing.core.PVector |
position()
Deprecated.
|
T |
registerProperty(java.lang.String thePropertyName) |
T |
registerProperty(java.lang.String theSetter,
java.lang.String theGetter) |
void |
remove()
removes the group from controlP5.
|
T |
remove(CDrawable theElement) |
T |
remove(ControllerInterface<?> theElement)
Removes a controller from the group, but use Controller.setGroup() instead.
|
T |
removeCanvas(Canvas theCanvas)
Removes a canvas from a controller group.
|
T |
removeCloseButton()
TODO redesign or deprecate remove the close button.
|
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 |
setCaptionLabel(java.lang.String theValue) |
T |
setColor(CColor theColor) |
T |
setColorActive(int theColor) |
T |
setColorBackground(int theColor) |
T |
setColorForeground(int theColor) |
T |
setColorLabel(int theColor) |
T |
setColorValue(int theColor) |
T |
setGroup(ControllerGroup<?> theGroup) |
T |
setGroup(java.lang.String theName) |
T |
setHeight(int theHeight) |
T |
setId(int theId) |
T |
setLabel(java.lang.String theLabel) |
T |
setMouseOver(boolean theFlag) |
boolean |
setMousePressed(boolean theStatus) |
T |
setMoveable(boolean theFlag)
set the moveable status of the group, when false, the group can't be moved.
|
T |
setOpen(boolean theFlag) |
T |
setPosition(float theX,
float theY)
set the position of this controller.
|
T |
setPosition(processing.core.PVector thePVector) |
T |
setSize(int theWidth,
int theHeight) |
T |
setStringValue(java.lang.String theValue) |
T |
setTab(ControlWindow theWindow,
java.lang.String theName) |
T |
setTab(java.lang.String theName) |
T |
setTab(Tab theTab) |
T |
setTitle(java.lang.String theTitle) |
T |
setUpdate(boolean theFlag)
enables or disables the update function of a controller.
|
T |
setValue(float theValue) |
T |
setVisible(boolean theFlag) |
T |
setWidth(int theWidth) |
T |
show() |
T |
showArrow() |
T |
showBar() |
java.lang.String |
stringValue()
Deprecated.
|
java.lang.String |
toString() |
T |
update() |
T |
updateAbsolutePosition() |
T |
updateEvents() |
T |
updateInternalEvents(processing.core.PApplet theApplet)
a method for putting input events like e.g.
|
float |
value()
Deprecated.
|
public ControllerGroup(ControlP5 theControlP5, ControllerGroup<?> theParent, java.lang.String theName, float theX, float theY)
theControlP5
- ControlP5theParent
- ControllerGrouptheName
- StringtheX
- floattheY
- floatpublic ControllerGroup(ControlP5 theControlP5, java.lang.String theName)
theControlP5
- theName
- /**
* 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,
// is an indicator for the super class about the type of
// custom controller to be created.
class MyButton extends Controller {
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;
}
}
@Deprecated public processing.core.PVector absolutePosition()
public T add(ControllerInterface<?> theElement)
add
in interface ControllerInterface<T>
theElement
- ControllerInterfacepublic Canvas addCanvas(Canvas theCanvas)
theCanvas
- public T addCloseButton()
public T addDrawable(CDrawable theElement)
theElement
- CDrawablepublic T addListener(ControlListener theListener)
addListener
in interface ControllerInterface<T>
theListener
- ControlListenerControlListener
@Deprecated public float[] arrayValue()
public T bringToFront()
bringToFront
in interface ControllerInterface<T>
public T bringToFront(ControllerInterface<?> theController)
bringToFront
in interface ControllerInterface<T>
public T close()
@Deprecated public CColor color()
public void continuousUpdateEvents()
continuousUpdateEvents
in interface ControllerInterface<T>
public void controlEvent(ControlEvent theEvent)
ControlListener
controlEvent
in interface ControlListener
theEvent
- ControlEventCallbackListener
,
CallbackEvent
@Deprecated public Controller<?> controller(java.lang.String theController)
public T disableCollapse()
public final void draw(processing.core.PGraphics theGraphics)
draw
in interface ControllerInterface<T>
public T enableCollapse()
public processing.core.PVector getAbsolutePosition()
getAbsolutePosition
in interface ControllerInterface<T>
public java.lang.String getAddress()
getAddress
in interface ControllerInterface<T>
public float[] getArrayValue()
getArrayValue
in interface ControllerInterface<T>
public float getArrayValue(int theIndex)
getArrayValue
in interface ControllerInterface<T>
theIndex
- public Label getCaptionLabel()
public CColor getColor()
getColor
in interface ControllerInterface<T>
public Controller<?> getController(java.lang.String theController)
public int getHeight()
getHeight
in interface ControllerInterface<T>
public int getId()
getId
in interface ControllerInterface<T>
public java.lang.String getInfo()
public java.lang.String getName()
getName
in interface ControllerInterface<T>
public ControllerInterface<?> getParent()
getParent
in interface ControllerInterface<T>
public int getPickingColor()
getPickingColor
in interface ControllerInterface<T>
public processing.core.PVector getPosition()
getPosition
in interface ControllerInterface<T>
public ControllerProperty getProperty(java.lang.String thePropertyName)
getProperty
in interface ControllerInterface<T>
public ControllerProperty getProperty(java.lang.String theSetter, java.lang.String theGetter)
getProperty
in interface ControllerInterface<T>
public java.lang.String getStringValue()
getStringValue
in interface ControllerInterface<T>
public Tab getTab()
getTab
in interface ControllerInterface<T>
public float getValue()
getValue
in interface ControllerInterface<T>
public Label getValueLabel()
public int getWidth()
getWidth
in interface ControllerInterface<T>
public ControlWindow getWindow()
getWindow
in interface ControllerInterface<T>
public T hide()
hide
in interface ControllerInterface<T>
public T hideArrow()
public T hideBar()
@Deprecated public int id()
id
in interface ControllerInterface<T>
public void init()
init
in interface ControllerInterface<T>
public boolean isBarVisible()
public boolean isCollapse()
public boolean isMouseOver()
isMouseOver
in interface ControllerInterface<T>
public boolean isMoveable()
public boolean isOpen()
public boolean isUpdate()
isUpdate
in interface ControllerInterface<T>
public boolean isVisible()
isVisible
in interface ControllerInterface<T>
public void keyEvent(processing.event.KeyEvent theEvent)
keyEvent
in interface ControllerInterface<T>
theEvent
- KeyEventpublic int listenerSize()
public final T moveTo(ControllerGroup<?> theGroup)
moveTo
in interface ControllerInterface<T>
public final T moveTo(ControllerGroup<?> theGroup, Tab theTab, ControlWindow theControlWindow)
moveTo
in interface ControllerInterface<T>
theGroup
- ControlGrouptheTab
- TabtheControlWindow
- ControlWindowpublic T moveTo(ControlWindow theControlWindow)
public final T moveTo(ControlWindow theControlWindow, java.lang.String theTabName)
public T moveTo(processing.core.PApplet thePApplet)
public final T moveTo(java.lang.String theTabName)
public final T moveTo(java.lang.String theTabName, ControlWindow theControlWindow)
public final T moveTo(Tab theTab, ControlWindow theControlWindow)
@Deprecated public java.lang.String name()
name
in interface ControllerInterface<T>
public T open()
@Deprecated public ControllerInterface<?> parent()
parent
in interface ControllerInterface<T>
@Deprecated public processing.core.PVector position()
public T registerProperty(java.lang.String thePropertyName)
registerProperty
in interface ControllerInterface<T>
public T registerProperty(java.lang.String theSetter, java.lang.String theGetter)
registerProperty
in interface ControllerInterface<T>
public void remove()
remove
in interface ControllerInterface<T>
public T remove(CDrawable theElement)
theElement
- CDrawablepublic T remove(ControllerInterface<?> theElement)
remove
in interface ControllerInterface<T>
theElement
- ControllerInterfacepublic T removeCanvas(Canvas theCanvas)
theCanvas
- public T removeCloseButton()
public T removeListener(ControlListener theListener)
theListener
- ControlListenerControlListener
public T removeProperty(java.lang.String thePropertyName)
removeProperty
in interface ControllerInterface<T>
public T removeProperty(java.lang.String theSetter, java.lang.String theGetter)
removeProperty
in interface ControllerInterface<T>
public T setAbsolutePosition(processing.core.PVector thePVector)
setAbsolutePosition
in interface ControllerInterface<T>
public T setAddress(java.lang.String theAddress)
setAddress
in interface ControllerInterface<T>
public T setArrayValue(float[] theArray)
setArrayValue
in interface ControllerInterface<T>
theArray
- public T setArrayValue(int theIndex, float theValue)
setArrayValue
in interface ControllerInterface<T>
theIndex
- theValue
- public T setCaptionLabel(java.lang.String theValue)
setCaptionLabel
in interface ControllerInterface<T>
public T setColor(CColor theColor)
setColor
in interface ControllerInterface<T>
public T setColorActive(int theColor)
setColorActive
in interface ControllerInterface<T>
public T setColorBackground(int theColor)
setColorBackground
in interface ControllerInterface<T>
public T setColorForeground(int theColor)
setColorForeground
in interface ControllerInterface<T>
public T setColorLabel(int theColor)
setColorLabel
in interface ControllerInterface<T>
public T setColorValue(int theColor)
setColorValue
in interface ControllerInterface<T>
public final T setGroup(ControllerGroup<?> theGroup)
theGroup
- ControllerGrouppublic final T setGroup(java.lang.String theName)
theName
- Stringpublic T setHeight(int theHeight)
theHeight
- public T setId(int theId)
setId
in interface ControllerInterface<T>
public T setLabel(java.lang.String theLabel)
setLabel
in interface ControllerInterface<T>
theLabel
- Stringpublic T setMouseOver(boolean theFlag)
setMouseOver
in interface ControllerInterface<T>
public boolean setMousePressed(boolean theStatus)
setMousePressed
in interface ControllerInterface<T>
theStatus
- booleanpublic T setMoveable(boolean theFlag)
theFlag
- booleanpublic T setOpen(boolean theFlag)
public T setPosition(float theX, float theY)
setPosition
in interface ControllerInterface<T>
theX
- floattheY
- floatpublic T setPosition(processing.core.PVector thePVector)
setPosition
in interface ControllerInterface<T>
public T setSize(int theWidth, int theHeight)
public T setStringValue(java.lang.String theValue)
setStringValue
in interface ControllerInterface<T>
public final T setTab(ControlWindow theWindow, java.lang.String theName)
public final T setTab(java.lang.String theName)
theName
- Stringpublic T setTitle(java.lang.String theTitle)
public T setUpdate(boolean theFlag)
setUpdate
in interface ControllerInterface<T>
theFlag
- booleanpublic T setValue(float theValue)
setValue
in interface ControllerInterface<T>
public T setVisible(boolean theFlag)
theFlag
- booleanpublic T setWidth(int theWidth)
theWidth
- public T show()
show
in interface ControllerInterface<T>
public T showArrow()
public T showBar()
@Deprecated public java.lang.String stringValue()
stringValue
in interface ControllerInterface<T>
public java.lang.String toString()
toString
in class java.lang.Object
public T update()
update
in interface ControllerInterface<T>
public T updateAbsolutePosition()
updateAbsolutePosition
in interface ControllerInterface<T>
public T updateEvents()
updateEvents
in interface ControllerInterface<T>
public T updateInternalEvents(processing.core.PApplet theApplet)
ControllerInterface
updateInternalEvents
in interface ControllerInterface<T>
@Deprecated public float value()
processing library controlP5 by Andreas Schlegel. (c) 2006-2014