controlP5
Class ControlWindow

java.lang.Object
  extended by controlP5.ControlWindow
All Implemented Interfaces:
java.awt.event.MouseWheelListener, java.util.EventListener

public class ControlWindow
extends java.lang.Object
implements java.awt.event.MouseWheelListener

the purpose of a control window is to out-source controllers so that they dont need to be drawn into the actual processing window. to save cpu, a control window is not updated when not active - in focus. for the same reason the framerate is set to 15.

+Example
/**
 * ControlP5 ControlWindow
 * by andreas schlegel, 2009
 */

import controlP5.*;

ControlP5 controlP5;

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

ControlWindow controlWindow;

public int sliderValue = 40;

void setup() {
  size(400,400);  
  frameRate(25);
  controlP5 = new ControlP5(this);
  controlP5.setAutoDraw(false);
  controlWindow = controlP5.addControlWindow("controlP5window",100,100,400,200);
  controlWindow.hideCoordinates();
  
  controlWindow.setBackground(color(40));
  Controller mySlider = controlP5.addSlider("sliderValue",0,255,40,40,100,10);
  mySlider.setWindow(controlWindow);
  Textfield field = controlP5.addTextfield("myWindowTextfield",70,130,100,20);
  field.setWindow(controlWindow);

  controlP5.addSlider("sliderValue1",0,255,40,40,100,10);
  controlP5.addTextfield("myTextfield",70,130,40,20);
  controlWindow.setTitle("abc");
  
}

void draw() {
  background(sliderValue);
  controlP5.draw();
}

void myTextfield(String theValue) {
  println(theValue);
}

void myWindowTextfield(String theValue) {
  println("from controlWindow: "+theValue);
}

void keyPressed() {
  if(key==',') controlP5.window("controlP5window").hide();
  if(key=='.') controlP5.window("controlP5window").show();
  // controlWindow = controlP5.addControlWindow("controlP5window2",600,100,400,200);
  // controlP5.controller("sliderValue1").moveTo(controlWindow);
  
  // since version 0.5.0, a controlWindow can be set undecorated.
  if(key=='d') {
    if(controlWindow.isUndecorated()) {
      controlWindow.setUndecorated(false);
    } else {
      controlWindow.setUndecorated(true);
    }
  }
  if(key=='t') {
    controlWindow.toggleUndecorated();
  }
}


Field Summary
 int background
           
static int ECONOMIC
           
static int NORMAL
           
 
Constructor Summary
ControlWindow(ControlP5 theControlP5, processing.core.PApplet theApplet)
           
 
Method Summary
 void activateTab(java.lang.String theTab)
          activate a tab of a control window.
 Tab add(Tab theTab)
          add a tab to the control window.
 void addCanvas(ControlWindowCanvas theCanvas)
           
 Tab addTab(java.lang.String theTab)
           
 void clear()
          clear the control window, delete all controllers from a control window.
 java.awt.Component component()
           
 Tab currentTab()
          get the current active tab of a control window.
 void draw()
           
 void frameRate(int theFrameRate)
          set the frame rate of the control window.
 void hide()
          hide the controllers and tabs of the ControlWindow.
 void hideCoordinates()
          hide the xy coordinates displayed in the title of a control window.
 boolean isDrawBackground()
          returns a boolean indicating if the background is drawn automatically or not.
 boolean isMouseOver()
          returns true if the mouse is inside a controller.
 boolean isMousePressed()
           
 boolean isUndecorated()
           
 boolean isUpdate()
          check the update status of a control window.
 boolean isVisible()
          check if the content of the control window is visible.
 void keyEvent(java.awt.event.KeyEvent theKeyEvent)
           
 void mouseEvent(java.awt.event.MouseEvent theMouseEvent)
           
 void mouseWheelMoved(java.awt.event.MouseWheelEvent e)
           
 void multitouch(int[][] theCoordinates)
           
 java.lang.String name()
          get the name of the control window.
 processing.core.PApplet papplet()
          get the papplet instance of the ControlWindow.
 void pre()
           
 void remove()
          remove a control window from controlP5.
 void removeCanvas(ControlWindowCanvas theCanvas)
           
 void removeTab(Tab theTab)
          remove a tab from a control window.
 void setBackground(int theValue)
          set the background color of the control window.
 void setColorActive(int theColor)
          set the color for the controller while active.
 void setColorBackground(int theColor)
          set the background color of the controller.
 void setColorForeground(int theColor)
          set the foreground color of the controller.
 void setColorLabel(int theColor)
          set the color of the text label of the controller.
 void setColorValue(int theColor)
          set the color of the values.
 void setContext(CDrawable theDrawable)
           
 void setDrawBackground(boolean theFlag)
          by default the background of a controlWindow is filled with a backgorund color every frame.
 void setLocation(int theX, int theY)
           
 void setMode(int theMode)
          Deprecated.  
 void setTitle(java.lang.String theTitle)
          set the title of a control window.
 void setUndecorated(boolean theFlag)
           
 void setUpdate(boolean theFlag)
          enable or disable the update function of a control window.
 void setUpdateMode(int theMode)
          set the draw mode of a control window.
 void show()
          show the controllers and tabs of the ControlWindow.
 void showCoordinates()
          shows the xy coordinates displayed in the title of a control window.
 Tab tab(java.lang.String theTabName)
          get a tab by name of a control window
 ControllerList tabs()
           
 void toggleUndecorated()
           
 void update()
          update all controllers contained in the control window if update is enabled.
 void updateEvents()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

background

public int background

NORMAL

public static final int NORMAL
See Also:
Constant Field Values

ECONOMIC

public static final int ECONOMIC
See Also:
Constant Field Values
Constructor Detail

ControlWindow

public ControlWindow(ControlP5 theControlP5,
                     processing.core.PApplet theApplet)
Parameters:
theControlP5 - ControlP5
theApplet - PApplet
Method Detail

currentTab

public Tab currentTab()
get the current active tab of a control window.

Returns:
Tab

activateTab

public void activateTab(java.lang.String theTab)
activate a tab of a control window.

Parameters:
theTab - String

removeTab

public void removeTab(Tab theTab)
remove a tab from a control window.

Parameters:
theTab - Tab

add

public Tab add(Tab theTab)
add a tab to the control window.

Parameters:
theTab - Tab
Returns:
Tab

addTab

public Tab addTab(java.lang.String theTab)

tabs

public ControllerList tabs()
Returns:
ControllerList

tab

public Tab tab(java.lang.String theTabName)
get a tab by name of a control window

Parameters:
theTabName - String
Returns:
Tab

remove

public void remove()
remove a control window from controlP5.


clear

public void clear()
clear the control window, delete all controllers from a control window.


updateEvents

public void updateEvents()

isMouseOver

public boolean isMouseOver()
returns true if the mouse is inside a controller. !!! doesnt work for groups yet.

Returns:

update

public void update()
update all controllers contained in the control window if update is enabled.


setUpdate

public void setUpdate(boolean theFlag)
enable or disable the update function of a control window.

Parameters:
theFlag - boolean

isUpdate

public boolean isUpdate()
check the update status of a control window.

Returns:
boolean

addCanvas

public void addCanvas(ControlWindowCanvas theCanvas)

removeCanvas

public void removeCanvas(ControlWindowCanvas theCanvas)

pre

public void pre()

draw

public void draw()

setContext

public void setContext(CDrawable theDrawable)
Parameters:
theDrawable - CDrawable

name

public java.lang.String name()
get the name of the control window.

Returns:
String

mouseEvent

public void mouseEvent(java.awt.event.MouseEvent theMouseEvent)
Parameters:
theMouseEvent - MouseEvent

mouseWheelMoved

public void mouseWheelMoved(java.awt.event.MouseWheelEvent e)
Specified by:
mouseWheelMoved in interface java.awt.event.MouseWheelListener

multitouch

public void multitouch(int[][] theCoordinates)

isMousePressed

public boolean isMousePressed()

keyEvent

public void keyEvent(java.awt.event.KeyEvent theKeyEvent)
Parameters:
theKeyEvent - KeyEvent

setColorActive

public void setColorActive(int theColor)
set the color for the controller while active.

Parameters:
theColor - int

setColorForeground

public void setColorForeground(int theColor)
set the foreground color of the controller.

Parameters:
theColor - int

setColorBackground

public void setColorBackground(int theColor)
set the background color of the controller.

Parameters:
theColor - int

setColorLabel

public void setColorLabel(int theColor)
set the color of the text label of the controller.

Parameters:
theColor - int

setColorValue

public void setColorValue(int theColor)
set the color of the values.

Parameters:
theColor - int

setBackground

public void setBackground(int theValue)
set the background color of the control window.

Parameters:
theValue - int

papplet

public processing.core.PApplet papplet()
get the papplet instance of the ControlWindow.

Returns:
PApplet

component

public java.awt.Component component()

setTitle

public void setTitle(java.lang.String theTitle)
set the title of a control window. only applies to control windows of type PAppletWindow.


showCoordinates

public void showCoordinates()
shows the xy coordinates displayed in the title of a control window. only applies to control windows of type PAppletWindow.

Parameters:
theFlag -

hideCoordinates

public void hideCoordinates()
hide the xy coordinates displayed in the title of a control window. only applies to control windows of type PAppletWindow.

Parameters:
theFlag -

hide

public void hide()
hide the controllers and tabs of the ControlWindow.


setMode

public void setMode(int theMode)
Deprecated. 

Parameters:
theMode -

setUpdateMode

public void setUpdateMode(int theMode)
set the draw mode of a control window. a separate control window is only updated when in focus. to update the context of the window continuously, use yourControlWindow.setUpdateMode(ControlWindow.NORMAL); otherwise use yourControlWindow.setUpdateMode(ControlWindow.ECONOMIC); for an economic, less cpu intensive update.

Parameters:
theMode -

frameRate

public void frameRate(int theFrameRate)
set the frame rate of the control window.

Parameters:
theFrameRate -

show

public void show()
show the controllers and tabs of the ControlWindow.


setDrawBackground

public void setDrawBackground(boolean theFlag)
by default the background of a controlWindow is filled with a backgorund color every frame. to enable or disable the background from drawing, use setDrawBackgorund(true/false).

Parameters:
theFlag -

isDrawBackground

public boolean isDrawBackground()
returns a boolean indicating if the background is drawn automatically or not.

Returns:

isVisible

public boolean isVisible()
check if the content of the control window is visible.

Returns:
boolean

toggleUndecorated

public void toggleUndecorated()

setUndecorated

public void setUndecorated(boolean theFlag)

isUndecorated

public boolean isUndecorated()

setLocation

public void setLocation(int theX,
                        int theY)


processing library controlP5 by Andreas Schlegel. (c) 2010