controlP5
Class Textarea

java.lang.Object
  extended by controlP5.ControllerGroup
      extended by controlP5.Textarea
All Implemented Interfaces:
ControllerInterface, ControlListener, ControlP5Constants

public class Textarea
extends ControllerGroup
implements ControlListener

+Example
/**
  * ControlP5 TextArea.
  *
  * by andreas schlegel, 2009
  */

import controlP5.*;

ControlP5 controlP5;
Textarea myTextarea;

void setup() {
  size(400,400);
  frameRate(30);
  controlP5 = new ControlP5(this);
  myTextarea = controlP5.addTextarea(
  "label1", 
  "a textarea is of type group, not controller.\n"+
    "you can set the width and height of a textarea, if there is more text than space available, scrollbars are added.  "+
    "use ALT + mouseDown to move the textarea. First sketches showing the potential of the new volumetric brush (here the box version was used). Size and density and brush mode (additve, multiply or replace) can be customized. Here I first used a massive brush size with high positive density to create the box, then switched to negative density and smaller size to carve out. The colours are visualizing curvature and were applied in Meshlab later.", 
  100,100,200,60);
  controlP5.addSlider("changeWidth",0,200,100,100,20,100,9);
  controlP5.addSlider("changeHeight",0,200,100,100,60,100,9);
  myTextarea.setColorForeground(0xffff0000);
}


void keyPressed() {
  if(key=='r') {
    myTextarea.setText("a textarea can be used to leave notes inside of controlP5 displayed on the screen. scrollbars are available when text extends the visible area. Textarea extends ControllerGroup, for more available methods see the ControllerGroup documentation.");
  } else if(key=='c') {
    myTextarea.setColor(0xff0000);
  }
}
void draw() {
  background(0);
  if(keyPressed && key==' ') {
    myTextarea.scroll((float)mouseX/(float)width);
  }
  if(keyPressed && key=='l') {
    myTextarea.setLineHeight(mouseY);
  }
}

void changeWidth(int theValue) {
  myTextarea.setWidth(theValue);
}

void changeHeight(int theValue) {
  myTextarea.setHeight(theValue);
}


Field Summary
 
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, HORIZONTAL, 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, VERTICAL
 
Constructor Summary
Textarea(ControlP5 theControlP5, ControllerGroup theGroup, java.lang.String theName, java.lang.String theText, int theX, int theY, int theW, int theH)
           
Textarea(java.lang.String theText, int theX, int theY)
           
 
Method Summary
 void addToXMLElement(ControlP5XMLElement theElement)
           
 void controlEvent(ControlEvent theEvent)
          ControlListener is an interface that can be implemented by a custom class.
 void disableColorBackground()
           
 void enableColorBackground()
           
 void hideScrollbar()
           
 boolean isScrollbarVisible()
           
 void scroll(float theValue)
          scroll the Textarea remotely.
 void setColor(int theColor)
          set the text color of the textarea.
 void setColorBackground(int theColor)
          set the background color of the group.
 Textarea setHeight(int theValue)
          set the height of the textarea.
 void setLineHeight(int theLineHeight)
          set the lineheight of the textarea.
 void setPosition(float theX, float theY)
          set the position of the textarea.
 void setText(java.lang.String theText)
          set the text of the textarea.
 Textarea setWidth(int theValue)
          set the width of the textarea.
 void showScrollbar()
           
 java.lang.String stringValue()
          returns the content of the textarea's label.
 java.lang.String text()
          returns the text content of the textarea .
 float value()
          !!! experimental, have to check if this spoils anything.
 Label valueLabel()
          returns the instance of the textarea's label.
 
Methods inherited from class controlP5.ControllerGroup
absolutePosition, add, addCanvas, addDrawable, arrayValue, captionLabel, close, color, continuousUpdateEvents, controller, disableCollapse, draw, enableCollapse, getAsXML, getColor, getHeight, getPickingColor, getTab, getWidth, getWindow, hide, id, init, isCollapse, isMoveable, isOpen, isUpdate, isVisible, isXMLsavable, keyEvent, moveTo, moveTo, moveTo, moveTo, moveTo, moveTo, moveTo, moveTo, name, open, parent, position, remove, remove, remove, removeCanvas, setColorActive, setColorForeground, setColorLabel, setColorValue, setGroup, setGroup, setId, setLabel, setMousePressed, setMoveable, setOpen, setTab, setTab, setTab, setUpdate, setVisible, show, toString, update, updateAbsolutePosition, updateEvents, updateInternalEvents
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Textarea

public Textarea(ControlP5 theControlP5,
                ControllerGroup theGroup,
                java.lang.String theName,
                java.lang.String theText,
                int theX,
                int theY,
                int theW,
                int theH)
Parameters:
theControlP5 - ControlP5
theGroup - ControllerGroup
theName - String
theText - String
theX - int
theY - int
theW - int
theH - int

Textarea

public Textarea(java.lang.String theText,
                int theX,
                int theY)
Parameters:
theText - String
theX - int
theY - int
Method Detail

controlEvent

public void controlEvent(ControlEvent theEvent)
Description copied from interface: ControlListener
ControlListener is an interface that can be implemented by a custom class. add the controlListener to a controller with Controller.addListner()

Specified by:
controlEvent in interface ControlListener
Parameters:
theEvent - ControlEvent

hideScrollbar

public void hideScrollbar()

showScrollbar

public void showScrollbar()

isScrollbarVisible

public boolean isScrollbarVisible()

setColorBackground

public void setColorBackground(int theColor)
Description copied from class: ControllerGroup
set the background color of the group.

Specified by:
setColorBackground in interface ControllerInterface
Overrides:
setColorBackground in class ControllerGroup
Parameters:
theColor - int

disableColorBackground

public void disableColorBackground()

enableColorBackground

public void enableColorBackground()

scroll

public void scroll(float theValue)
scroll the Textarea remotely. values must range from 0 to 1.

Parameters:
theValue -

setWidth

public Textarea setWidth(int theValue)
set the width of the textarea.

Overrides:
setWidth in class ControllerGroup
Parameters:
theValue - int

setHeight

public Textarea setHeight(int theValue)
set the height of the textarea.

Overrides:
setHeight in class ControllerGroup
Parameters:
theValue - int

setLineHeight

public void setLineHeight(int theLineHeight)
set the lineheight of the textarea.

Parameters:
theLineHeight - int

setColor

public void setColor(int theColor)
set the text color of the textarea.

Parameters:
theColor - int

valueLabel

public Label valueLabel()
returns the instance of the textarea's label.

Overrides:
valueLabel in class ControllerGroup
Returns:

setText

public void setText(java.lang.String theText)
set the text of the textarea.

Parameters:
theText - String

setPosition

public void setPosition(float theX,
                        float theY)
set the position of the textarea.

Specified by:
setPosition in interface ControllerInterface
Overrides:
setPosition in class ControllerGroup
Parameters:
theX - float
theY - float

addToXMLElement

public void addToXMLElement(ControlP5XMLElement theElement)
Specified by:
addToXMLElement in interface ControllerInterface
Parameters:
theElement - ControlP5XMLElement

stringValue

public java.lang.String stringValue()
returns the content of the textarea's label.

Specified by:
stringValue in interface ControllerInterface
Overrides:
stringValue in class ControllerGroup
Returns:
String

text

public java.lang.String text()
returns the text content of the textarea .

Returns:

value

public float value()
Description copied from class: ControllerGroup
!!! experimental, have to check if this spoils anything. implemented for ScrollList and MultiList to forward values to a dedicated method

Specified by:
value in interface ControllerInterface
Overrides:
value in class ControllerGroup
Returns:
float


processing library controlP5 by Andreas Schlegel. (c) 2010