ControlGroup (Javadocs: controlP5)

controlP5

## Class ControlGroup<T>

- java.lang.Object
- - controlP5.ControllerGroup<T>
  - - controlP5.ControlGroup<T>

- All Implemented Interfaces:
    ControllerInterface<T>, ControlListener, ControlP5Constants
  Direct Known Subclasses:
    Accordion, Background, CheckBox, ColorPicker, Group, RadioButton

      public class ControlGroup<T>
      extends ControllerGroup<T>
      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(800,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(250,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)
             ;

          Group g3 = cp5.addGroup("g3")
                        .setPosition(600,100)
                        .setSize(150,200)
                        .setBackgroundColor(color(255,100))
                        ;

          cp5.addScrollableList("list")
             .setPosition(10,10)
             .setSize(130,100)
             .setGroup(g3)
             .addItems(java.util.Arrays.asList("a","b","c","d","e","f","g"))
             ;
        }

        void draw() {
          background(0);
        }

        void controlEvent(ControlEvent theEvent) {
          if(theEvent.isGroup()) {
            println("got an event from group "
                    +theEvent.getGroup().getName()
                    +", isOpen? "+theEvent.getGroup().isOpen()
                    );

          } else if (theEvent.isController()){
            println("got something from a controller "
                    +theEvent.getController().getName()
                    );
          }
        }

        void keyPressed() {
          if(key==' ') {
            if(cp5.getGroup("g1")!=null) {
              cp5.getGroup("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 removeListener(ControlListener)
        controlP5.ControlGroup : Group setBackgroundColor(int)
        controlP5.ControlGroup : Group setBackgroundHeight(int)
        controlP5.ControlGroup : Group setBarHeight(int)
        controlP5.ControlGroup : Group setSize(int, int)
        controlP5.ControlGroup : Group updateInternalEvents(PApplet)
        controlP5.ControlGroup : String getInfo()
        controlP5.ControlGroup : String toString()
        controlP5.ControlGroup : int getBackgroundHeight()
        controlP5.ControlGroup : int getBarHeight()
        controlP5.ControlGroup : int listenerSize()
        controlP5.ControllerGroup : CColor getColor()
        controlP5.ControllerGroup : Canvas addCanvas(Canvas)
        controlP5.ControllerGroup : ControlWindow getWindow()
        controlP5.ControllerGroup : Controller getController(String)
        controlP5.ControllerGroup : ControllerProperty getProperty(String)
        controlP5.ControllerGroup : ControllerProperty getProperty(String, String)
        controlP5.ControllerGroup : Group add(ControllerInterface)
        controlP5.ControllerGroup : Group addListener(ControlListener)
        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 hideArrow()
        controlP5.ControllerGroup : Group hideBar()
        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(Canvas)
        controlP5.ControllerGroup : Group removeListener(ControlListener)
        controlP5.ControllerGroup : Group removeProperty(String)
        controlP5.ControllerGroup : Group removeProperty(String, String)
        controlP5.ControllerGroup : Group setAddress(String)
        controlP5.ControllerGroup : Group setArrayValue(float[])
        controlP5.ControllerGroup : Group setArrayValue(int, float)
        controlP5.ControllerGroup : Group setCaptionLabel(String)
        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(float, float)
        controlP5.ControllerGroup : Group setPosition(float[])
        controlP5.ControllerGroup : Group setSize(int, int)
        controlP5.ControllerGroup : Group setStringValue(String)
        controlP5.ControllerGroup : Group setTitle(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 showArrow()
        controlP5.ControllerGroup : Group showBar()
        controlP5.ControllerGroup : Group update()
        controlP5.ControllerGroup : Group updateAbsolutePosition()
        controlP5.ControllerGroup : Label getCaptionLabel()
        controlP5.ControllerGroup : Label getValueLabel()
        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 isBarVisible()
        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 getArrayValue(int)
        controlP5.ControllerGroup : float getValue()
        controlP5.ControllerGroup : float[] getArrayValue()
        controlP5.ControllerGroup : float[] getPosition()
        controlP5.ControllerGroup : int getHeight()
        controlP5.ControllerGroup : int getId()
        controlP5.ControllerGroup : int getWidth()
        controlP5.ControllerGroup : int listenerSize()
        controlP5.ControllerGroup : void controlEvent(ControlEvent)
        controlP5.ControllerGroup : void remove()
        java.lang.Object : String toString()
        java.lang.Object : boolean equals(Object)

        created: 2015/03/24 12:21:07

        */

    `

- - ### Field Summary

    - ### Fields inherited from interface controlP5.ControlP5Constants

      `acceptClassList, ACTION_BROADCAST, ACTION_CLICK, ACTION_DOUBLE_PRESS, ACTION_DRAG, ACTION_END_DRAG, ACTION_ENTER, ACTION_EXIT, ACTION_LEAVE, ACTION_MOVE, ACTION_PRESS, ACTION_PRESSED, ACTION_RELEASE, ACTION_RELEASE_OUTSIDE, ACTION_RELEASED, ACTION_RELEASEDOUTSIDE, ACTION_START_DRAG, 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, delimiter, 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, JSON, KEYCONTROL, LEFT, LEFT_OUTSIDE, LIME, LINE, LIST, LOAD, MAROON, MENU, METHOD, MOVE, MULTI, MULTIPLES, NAVY, OLIVE, ORANGE, OVER, P2D, P3D, pathdelimiter, PI, PRESS, PRESSED, PRINT, PURPLE, RED, RELEASE, RELEASED, RESET, RIGHT, RIGHT_OUTSIDE, SAVE, SERIALIZED, 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_GREY, THEME_RED, THEME_RETRO, TOP, TOP_OUTSIDE, TRANSITION_WAIT_FADEIN, TREE, TWO_PI, UP, VALUELABEL, VERBOSE, VERTICAL, WAIT, WHITE, YELLOW`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `ControlGroup(ControlP5 theControlP5, ControllerGroup<?> theParent, java.lang.String theName, int theX, int theY, int theW, int theH)`
    `ControlGroup(ControlP5 theControlP5, java.lang.String theName)` Convenience constructor to extend ControlGroup.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `T` | `activateEvent(boolean theFlag)` activates or deactivates the Event status of a ControlGroup.
    `T` | `addListener(ControlListener theListener)`
    `void` | `controlEvent(ControlEvent theEvent)` controlEvent is called by controlP5's ControlBroadcaster to inform available listeners about value changes.
    `int` | `getBackgroundHeight()`
    `int` | `getBarHeight()`
    `java.lang.String` | `getInfo()`
    `int` | `listenerSize()`
    `void` | `mousePressed()`
    `T` | `removeListener(ControlListener theListener)`
    `T` | `setBackgroundColor(int theColor)`
    `T` | `setBackgroundHeight(int theHeight)`
    `T` | `setBarHeight(int theHeight)`
    `T` | `setSize(int theWidth, int theHeight)`
    `java.lang.String` | `stringValue()`
    `java.lang.String` | `toString()`
    `T` | `updateInternalEvents(processing.core.PApplet theApplet)` a method for putting input events like e.g.

    - ### Methods inherited from class controlP5.ControllerGroup

      `add, addCanvas, addCloseButton, addDrawable, bringToFront, bringToFront, close, continuousUpdateEvents, disableCollapse, draw, enableCollapse, getAbsolutePosition, getAddress, getArrayValue, getArrayValue, getCaptionLabel, getColor, getController, getHeight, getId, getName, getParent, getPickingColor, getPosition, getProperty, getProperty, getStringValue, getTab, getValue, getValueLabel, getWidth, getWindow, hide, hideArrow, hideBar, init, isBarVisible, isCollapse, isMouseOver, isMoveable, isOpen, isUpdate, isVisible, keyEvent, moveTo, moveTo, moveTo, moveTo, moveTo, moveTo, moveTo, moveTo, moveTo, open, registerProperty, registerProperty, remove, remove, remove, removeCanvas, removeCloseButton, removeProperty, removeProperty, set, setAbsolutePosition, setAddress, setArrayValue, setArrayValue, setCaptionLabel, setColor, setColorActive, setColorBackground, setColorForeground, setColorLabel, setColorValue, setGroup, setGroup, setHeight, setId, setLabel, setMouseOver, setMousePressed, setMoveable, setOpen, setPosition, setPosition, setStringValue, setTab, setTab, setTab, setTitle, setUpdate, setValue, setVisible, setWidth, show, showArrow, showBar, update, updateAbsolutePosition, updateEvents, x, y`

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

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

- - ### Constructor Detail

    - #### ControlGroup

          public ControlGroup(ControlP5 theControlP5,
                              ControllerGroup<?> theParent,
                              java.lang.String theName,
                              int theX,
                              int theY,
                              int theW,
                              int theH)

    - #### ControlGroup

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

      Convenience constructor to extend ControlGroup.

  - ### Method Detail

    - #### activateEvent

          public T activateEvent(boolean theFlag)

      activates or deactivates the Event status of a ControlGroup.

    - #### addListener

          public T addListener(ControlListener theListener)

      Specified by:
        `addListener` in interface `ControllerInterface<T>`
      Overrides:
        `addListener` in class `ControllerGroup<T>`

    - #### 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`
      Overrides:
        `controlEvent` in class `ControllerGroup<T>`
      Parameters:
        `theEvent` - ControlEvent
      See Also:
        `CallbackListener`, `CallbackEvent`

    - #### getBackgroundHeight

          public int getBackgroundHeight()

    - #### getBarHeight

          public int getBarHeight()

    - #### getInfo

          public java.lang.String getInfo()

      Overrides:
        `getInfo` in class `ControllerGroup<T>`

    - #### listenerSize

          public int listenerSize()

      Overrides:
        `listenerSize` in class `ControllerGroup<T>`

    - #### mousePressed

          public void mousePressed()

    - #### removeListener

          public T removeListener(ControlListener theListener)

      Overrides:
        `removeListener` in class `ControllerGroup<T>`

    - #### setBackgroundColor

          public T setBackgroundColor(int theColor)

    - #### setBackgroundHeight

          public T setBackgroundHeight(int theHeight)

    - #### setBarHeight

          public T setBarHeight(int theHeight)

    - #### setSize

          public T setSize(int theWidth,
                           int theHeight)

      Overrides:
        `setSize` in class `ControllerGroup<T>`

    - #### stringValue

          public java.lang.String stringValue()

    - #### toString

          public java.lang.String toString()

      Overrides:
        `toString` in class `ControllerGroup<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>`
      Overrides:
        `updateInternalEvents` in class `ControllerGroup<T>`

processing library controlP5 by Andreas Schlegel. (c) 2006-2015