controlP5
Class ControlGroup

java.lang.Object
  extended by controlP5.ControllerGroup
      extended by controlP5.ControlGroup
All Implemented Interfaces:
ControllerInterface, ControlListener, ControlP5Constants
Direct Known Subclasses:
Accordion, CheckBox, ColorPicker, DropdownList, Group, ListBox, RadioButton

public class ControlGroup
extends ControllerGroup
implements ControlListener

In previous versions you would use the ControlGroup class to bundle controllers in a group. Now please use the Group class to do so.

ControlGroup extends ControllerGroup, for a list and documentation of available methods see the ControllerGroup documentation.

See Also:
Group
+Example
/**
* ControlP5 Group
*
*
* find a list of public methods available for the Group Controller
* at the bottom of this sketch.
*
* by Andreas Schlegel, 2012
* www.sojamo.de/libraries/controlp5
*
*/


import controlP5.*;

ControlP5 cp5;

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

  cp5 = new ControlP5(this);
  
  Group g1 = cp5.addGroup("g1")
                .setPosition(100,100)
                .setBackgroundHeight(100)
                .setBackgroundColor(color(255,50))
                ;
                     
  cp5.addBang("A-1")
     .setPosition(10,20)
     .setSize(80,20)
     .setGroup(g1)
     ;
          
  cp5.addBang("A-2")
     .setPosition(10,60)
     .setSize(80,20)
     .setGroup(g1)
     ;
     
  
  Group g2 = cp5.addGroup("g2")
                .setPosition(300,100)
                .setWidth(300)
                .activateEvent(true)
                .setBackgroundColor(color(255,80))
                .setBackgroundHeight(100)
                .setLabel("Hello World.")
                ;
  
  cp5.addSlider("S-1")
     .setPosition(80,10)
     .setSize(180,9)
     .setGroup(g2)
     ;
     
  cp5.addSlider("S-2")
     .setPosition(80,20)
     .setSize(180,9)
     .setGroup(g2)
     ;
     
  cp5.addRadioButton("radio")
     .setPosition(10,10)
     .setSize(20,9)
     .addItem("black",0)
     .addItem("red",1)
     .addItem("green",2)
     .addItem("blue",3)
     .addItem("grey",4)
     .setGroup(g2)
     ;
}


void draw() {
  background(0);
}


void controlEvent(ControlEvent theEvent) {
  if(theEvent.isGroup()) {
    println("got an event from group "
            +theEvent.group().name()
            +", isOpen? "+theEvent.group().isOpen()
            );
            
  } else if (theEvent.isController()){
    println("got something from a controller "
            +theEvent.controller().name()
            );
  }
}


void keyPressed() {
  if(key==' ') {
    cp5.group("g1").remove();
  }
}




/*
a list of all methods available for the Group Controller
use ControlP5.printPublicMethodsFor(Group.class);
to print the following list into the console.

You can find further details about class Group in the javadoc.

Format:
ClassName : returnType methodName(parameter type)


controlP5.ControlGroup : Group activateEvent(boolean) 
controlP5.ControlGroup : Group addListener(ControlListener) 
controlP5.ControlGroup : Group hideBar() 
controlP5.ControlGroup : Group removeListener(ControlListener) 
controlP5.ControlGroup : Group setBackgroundColor(int) 
controlP5.ControlGroup : Group setBackgroundHeight(int) 
controlP5.ControlGroup : Group setBarHeight(int) 
controlP5.ControlGroup : Group showBar() 
controlP5.ControlGroup : Group updateInternalEvents(PApplet) 
controlP5.ControlGroup : String getInfo() 
controlP5.ControlGroup : String toString() 
controlP5.ControlGroup : boolean isBarVisible() 
controlP5.ControlGroup : int getBackgroundHeight() 
controlP5.ControlGroup : int getBarHeight() 
controlP5.ControlGroup : int listenerSize() 
controlP5.ControllerGroup : CColor getColor() 
controlP5.ControllerGroup : ControlWindow getWindow() 
controlP5.ControllerGroup : ControlWindowCanvas addCanvas(ControlWindowCanvas) 
controlP5.ControllerGroup : Controller getController(String) 
controlP5.ControllerGroup : ControllerProperty getProperty(String) 
controlP5.ControllerGroup : ControllerProperty getProperty(String, String) 
controlP5.ControllerGroup : Group add(ControllerInterface) 
controlP5.ControllerGroup : Group bringToFront() 
controlP5.ControllerGroup : Group bringToFront(ControllerInterface) 
controlP5.ControllerGroup : Group close() 
controlP5.ControllerGroup : Group disableCollapse() 
controlP5.ControllerGroup : Group enableCollapse() 
controlP5.ControllerGroup : Group hide() 
controlP5.ControllerGroup : Group moveTo(ControlWindow) 
controlP5.ControllerGroup : Group moveTo(PApplet) 
controlP5.ControllerGroup : Group open() 
controlP5.ControllerGroup : Group registerProperty(String) 
controlP5.ControllerGroup : Group registerProperty(String, String) 
controlP5.ControllerGroup : Group remove(CDrawable) 
controlP5.ControllerGroup : Group remove(ControllerInterface) 
controlP5.ControllerGroup : Group removeCanvas(ControlWindowCanvas) 
controlP5.ControllerGroup : Group removeProperty(String) 
controlP5.ControllerGroup : Group removeProperty(String, String) 
controlP5.ControllerGroup : Group setAddress(String) 
controlP5.ControllerGroup : Group setArrayValue(float[]) 
controlP5.ControllerGroup : Group setColor(CColor) 
controlP5.ControllerGroup : Group setColorActive(int) 
controlP5.ControllerGroup : Group setColorBackground(int) 
controlP5.ControllerGroup : Group setColorForeground(int) 
controlP5.ControllerGroup : Group setColorLabel(int) 
controlP5.ControllerGroup : Group setColorValue(int) 
controlP5.ControllerGroup : Group setHeight(int) 
controlP5.ControllerGroup : Group setId(int) 
controlP5.ControllerGroup : Group setLabel(String) 
controlP5.ControllerGroup : Group setMouseOver(boolean) 
controlP5.ControllerGroup : Group setMoveable(boolean) 
controlP5.ControllerGroup : Group setOpen(boolean) 
controlP5.ControllerGroup : Group setPosition(PVector) 
controlP5.ControllerGroup : Group setPosition(float, float) 
controlP5.ControllerGroup : Group setStringValue(String) 
controlP5.ControllerGroup : Group setUpdate(boolean) 
controlP5.ControllerGroup : Group setValue(float) 
controlP5.ControllerGroup : Group setVisible(boolean) 
controlP5.ControllerGroup : Group setWidth(int) 
controlP5.ControllerGroup : Group show() 
controlP5.ControllerGroup : Group update() 
controlP5.ControllerGroup : Group updateAbsolutePosition() 
controlP5.ControllerGroup : Label getCaptionLabel() 
controlP5.ControllerGroup : Label getValueLabel() 
controlP5.ControllerGroup : PVector getPosition() 
controlP5.ControllerGroup : String getAddress() 
controlP5.ControllerGroup : String getInfo() 
controlP5.ControllerGroup : String getName() 
controlP5.ControllerGroup : String getStringValue() 
controlP5.ControllerGroup : String toString() 
controlP5.ControllerGroup : Tab getTab() 
controlP5.ControllerGroup : boolean isCollapse() 
controlP5.ControllerGroup : boolean isMouseOver() 
controlP5.ControllerGroup : boolean isMoveable() 
controlP5.ControllerGroup : boolean isOpen() 
controlP5.ControllerGroup : boolean isUpdate() 
controlP5.ControllerGroup : boolean isVisible() 
controlP5.ControllerGroup : boolean setMousePressed(boolean) 
controlP5.ControllerGroup : float getValue() 
controlP5.ControllerGroup : float[] getArrayValue() 
controlP5.ControllerGroup : int getHeight() 
controlP5.ControllerGroup : int getId() 
controlP5.ControllerGroup : int getWidth() 
controlP5.ControllerGroup : void remove() 
java.lang.Object : String toString() 
java.lang.Object : boolean equals(Object) 


*/




Field Summary
 
Fields inherited from interface controlP5.ControlP5Constants
acceptClassList, ACTION_BROADCAST, ACTION_ENTER, ACTION_LEAVE, ACTION_PRESSED, ACTION_RELEASED, ACTION_RELEASEDOUTSIDE, ACTIVE, ALL, ALT, ARC, ARRAY, BACKSPACE, BASELINE, BITFONT, BOOLEAN, BOTTOM, BOTTOM_OUTSIDE, CAPTIONLABEL, CENTER, COMMANDKEY, CONTROL, controlEventClass, CUSTOM, DECREASE, DEFAULT, DELETE, DONE, DOWN, ELLIPSE, ENTER, ESCAPE, EVENT, eventMethod, FADEIN, FADEOUT, FIELD, FLOAT, HALF_PI, HIDE, HIGHLIGHT, HORIZONTAL, IDLE, IMAGE, INACTIVE, INCREASE, INTEGER, INVALID, KEYCONTROL, LEFT, LEFT_OUTSIDE, LINE, LOAD, MENU, METHOD, MOVE, MULTIPLES, OVER, PI, PRESSED, PRINT, RELEASE, RESET, RIGHT, RIGHT_OUTSIDE, SAVE, SHIFT, SINGLE, SINGLE_COLUMN, SINGLE_ROW, SPRITE, STRING, SWITCH, SWITCH_BACK, SWITCH_FORE, TAB, TOP, TOP_OUTSIDE, TRANSITION_WAIT_FADEIN, TWO_PI, UP, VALUELABEL, VERBOSE, VERTICAL, WAIT
 
Constructor Summary
ControlGroup(ControlP5 theControlP5, ControllerGroup theParent, java.lang.String theName, int theX, int theY, int theW, int theH)
           
 
Method Summary
 java.lang.Object activateEvent(boolean theFlag)
          activates or deactivates the Event status of a ControlGroup.
 java.lang.Object addCloseButton()
          TODO redesign or deprecate add a close button to the controlbar of this controlGroup.
 java.lang.Object addListener(ControlListener theListener)
          adds a listener to the controller.
 void controlEvent(ControlEvent theEvent)
          controlEvent is called by controlP5's ControlBroadcaster to inform available listeners about value changes.
 int getBackgroundHeight()
          get the height of the controlGroup's background.
 int getBarHeight()
           
 java.lang.String getInfo()
          
 java.lang.Object hideBar()
           
 boolean isBarVisible()
           
 int listenerSize()
           
 void mousePressed()
           
 java.lang.Object removeCloseButton()
          TODO redesign or deprecate remove the close button.
 java.lang.Object removeListener(ControlListener theListener)
          remove a listener from the controller.
 java.lang.Object setBackgroundColor(int theColor)
          set the background color of a controlGroup.
 java.lang.Object setBackgroundHeight(int theHeight)
          set the height of the controlGroup's background.
 java.lang.Object setBarHeight(int theHeight)
          set the height of the top bar (used to open/close and move a controlGroup).
 java.lang.Object showBar()
           
 java.lang.String stringValue()
          !!! experimental, see ControllerGroup.value()
 java.lang.String toString()
          
 java.lang.Object updateInternalEvents(processing.core.PApplet theApplet)
          a method for putting input events like e.g.
 
Methods inherited from class controlP5.ControllerGroup
add, addCanvas, addDrawable, bringToFront, bringToFront, close, disableCollapse, enableCollapse, getAbsolutePosition, getAddress, getArrayValue, getCaptionLabel, getColor, getController, getHeight, getId, getName, getPosition, getProperty, getProperty, getStringValue, getTab, getValue, getValueLabel, getWidth, getWindow, hide, isCollapse, isMouseOver, isMoveable, isOpen, isUpdate, isVisible, moveTo, moveTo, moveTo, moveTo, moveTo, moveTo, moveTo, moveTo, moveTo, open, registerProperty, registerProperty, remove, remove, remove, removeCanvas, removeProperty, removeProperty, setAddress, setArrayValue, setColor, setColorActive, setColorBackground, setColorForeground, setColorLabel, setColorValue, setGroup, setGroup, setHeight, setId, setLabel, setMouseOver, setMoveable, setOpen, setPosition, setPosition, setStringValue, setTab, setTab, setTab, setUpdate, setValue, setVisible, setWidth, show, updateAbsolutePosition
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface controlP5.ControllerInterface
continuousUpdateEvents, draw, getParent, getPickingColor, init, keyEvent, parent, setAbsolutePosition, setMousePressed, update, updateEvents
 

Constructor Detail

ControlGroup

public ControlGroup(ControlP5 theControlP5,
                    ControllerGroup theParent,
                    java.lang.String theName,
                    int theX,
                    int theY,
                    int theW,
                    int theH)
Method Detail

activateEvent

public java.lang.Object activateEvent(boolean theFlag)
activates or deactivates the Event status of a ControlGroup.

Parameters:
theFlag - boolean
See Also:
Tab

addCloseButton

public java.lang.Object addCloseButton()
TODO redesign or deprecate add a close button to the controlbar of this controlGroup.


addListener

public java.lang.Object addListener(ControlListener theListener)
adds a listener to the controller.

Parameters:
theListener - ControlListener
Returns:
ControlGroup

controlEvent

public void controlEvent(ControlEvent theEvent)
Description copied from interface: ControlListener
controlEvent is called by controlP5's ControlBroadcaster to inform available listeners about value changes. Use the CallbackListener to get informed when actions such as pressed, release, drag, etc are performed.

Specified by:
controlEvent in interface ControlListener
Parameters:
theEvent - ControlEvent
See Also:
CallbackListener, CallbackEvent

getBackgroundHeight

public int getBackgroundHeight()
get the height of the controlGroup's background.

Returns:

getBarHeight

public int getBarHeight()
Returns:
int

getInfo

public java.lang.String getInfo()

Overrides:
getInfo in class ControllerGroup

hideBar

public java.lang.Object hideBar()
Returns:
ControlGroup

isBarVisible

public boolean isBarVisible()
Returns:
boolean

listenerSize

public int listenerSize()
Returns:
int

mousePressed

public void mousePressed()

removeCloseButton

public java.lang.Object removeCloseButton()
TODO redesign or deprecate remove the close button.


removeListener

public java.lang.Object removeListener(ControlListener theListener)
remove a listener from the controller.

Parameters:
theListener - ControlListener
Returns:
ControlGroup

setBackgroundColor

public java.lang.Object setBackgroundColor(int theColor)
set the background color of a controlGroup.

Parameters:
theColor -
Returns:
ControlGroup

setBackgroundHeight

public java.lang.Object setBackgroundHeight(int theHeight)
set the height of the controlGroup's background.

Parameters:
theHeight -
Returns:
ControlGroup

setBarHeight

public java.lang.Object setBarHeight(int theHeight)
set the height of the top bar (used to open/close and move a controlGroup).

Parameters:
theHeight -
Returns:
ControlGroup

showBar

public java.lang.Object showBar()
Returns:
ControlGroup

stringValue

public java.lang.String stringValue()
!!! experimental, see ControllerGroup.value()

Overrides:
stringValue in class ControllerGroup
Returns:
String

toString

public java.lang.String toString()

Overrides:
toString in class ControllerGroup

updateInternalEvents

public java.lang.Object 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
Overrides:
updateInternalEvents in class ControllerGroup


processing library controlP5 by Andreas Schlegel. (c) 2012