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

a textarea can be used to leave notes, it uses the controlP5 BitFont to render text. Scrollbars will automaticaly be added when text extends the visible area. Textarea extends ControllerGroup, for more methods available see the ControllerGroup documentation.

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

import controlP5.*;

ControlP5 cp5;
Textarea myTextarea;

void setup() {
  size(700,400);
  cp5 = new ControlP5(this);
  
  myTextarea = cp5.addTextarea("txt")
                  .setPosition(100,100)
                  .setSize(200,200)
                  .setFont(createFont("arial",12))
                  .setLineHeight(14)
                  .setColor(color(128))
                  .setColorBackground(color(255,100))
                  .setColorForeground(color(255,100));
                  ;
  myTextarea.setText("Lorem Ipsum is simply dummy text of the printing and typesetting"
                    +" industry. Lorem Ipsum has been the industry's standard dummy text"
                    +" ever since the 1500s, when an unknown printer took a galley of type"
                    +" and scrambled it to make a type specimen book. It has survived not"
                    +" only five centuries, but also the leap into electronic typesetting,"
                    +" remaining essentially unchanged. It was popularised in the 1960s"
                    +" with the release of Letraset sheets containing Lorem Ipsum passages,"
                    +" and more recently with desktop publishing software like Aldus"
                    +" PageMaker including versions of Lorem Ipsum."
                    );
    
  cp5.addSlider("changeWidth")
     .setRange(100,400)
     .setValue(200)
     .setPosition(100,20)
     .setSize(100,19)
     ;
     
  cp5.addSlider("changeHeight")
     .setRange(100,400)
     .setValue(200)
     .setPosition(100,40)
     .setSize(100,19)
     ;
  
}


void keyPressed() {
  if(key=='r') {
    myTextarea.setText("Lorem ipsum dolor sit amet, consectetur adipiscing elit."
                      +" Quisque sed velit nec eros scelerisque adipiscing vitae eu sem."
                      +" Quisque malesuada interdum lectus. Pellentesque pellentesque molestie"
                      +" vestibulum. Maecenas ultricies, neque at porttitor lacinia, tellus enim"
                      +" suscipit tortor, ut dapibus orci lorem non ipsum. Mauris ut velit velit."
                      +" Fusce at purus in augue semper tincidunt imperdiet sit amet eros."
                      +" Vestibulum nunc diam, fringilla vitae tristique ut, viverra ut felis."
                      +" Proin aliquet turpis ornare leo aliquam dapibus. Integer dui nisi, condimentum"
                      +" ut sagittis non, fringilla vestibulum sapien. Sed ullamcorper libero et massa"
                      +" congue in facilisis mauris lobortis. Fusce cursus risus sit amet leo imperdiet"
                      +" lacinia faucibus turpis tempus. Pellentesque pellentesque augue sed purus varius"
                      +" sed volutpat dui rhoncus. Lorem ipsum dolor sit amet, consectetur adipiscing elit"
                      );
                      
  } else if(key=='c') {
    myTextarea.setColor(0xffffffff);
  }
}
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);
}




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

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

Format:
ClassName : returnType methodName(parameter type)

controlP5.Textarea : Label getValueLabel() 
controlP5.Textarea : String getStringValue() 
controlP5.Textarea : String getText() 
controlP5.Textarea : Textarea disableColorBackground() 
controlP5.Textarea : Textarea enableColorBackground() 
controlP5.Textarea : Textarea hideScrollbar() 
controlP5.Textarea : Textarea scroll(float) 
controlP5.Textarea : Textarea setBorderColor(int) 
controlP5.Textarea : Textarea setColor(int) 
controlP5.Textarea : Textarea setColorBackground(int) 
controlP5.Textarea : Textarea setFont(ControlFont) 
controlP5.Textarea : Textarea setFont(PFont) 
controlP5.Textarea : Textarea setFont(int) 
controlP5.Textarea : Textarea setHeight(int) 
controlP5.Textarea : Textarea setLineHeight(int) 
controlP5.Textarea : Textarea setScrollActive(int) 
controlP5.Textarea : Textarea setScrollBackground(int) 
controlP5.Textarea : Textarea setScrollForeground(int) 
controlP5.Textarea : Textarea setSize(int, int) 
controlP5.Textarea : Textarea setText(String) 
controlP5.Textarea : Textarea setWidth(int) 
controlP5.Textarea : Textarea showScrollbar() 
controlP5.Textarea : boolean isScrollable() 
controlP5.Textarea : float getValue() 
controlP5.Textarea : void controlEvent(ControlEvent) 
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 : 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 : Textarea add(ControllerInterface) 
controlP5.ControllerGroup : Textarea bringToFront() 
controlP5.ControllerGroup : Textarea bringToFront(ControllerInterface) 
controlP5.ControllerGroup : Textarea close() 
controlP5.ControllerGroup : Textarea disableCollapse() 
controlP5.ControllerGroup : Textarea enableCollapse() 
controlP5.ControllerGroup : Textarea hide() 
controlP5.ControllerGroup : Textarea moveTo(ControlWindow) 
controlP5.ControllerGroup : Textarea moveTo(PApplet) 
controlP5.ControllerGroup : Textarea open() 
controlP5.ControllerGroup : Textarea registerProperty(String) 
controlP5.ControllerGroup : Textarea registerProperty(String, String) 
controlP5.ControllerGroup : Textarea remove(CDrawable) 
controlP5.ControllerGroup : Textarea remove(ControllerInterface) 
controlP5.ControllerGroup : Textarea removeCanvas(ControlWindowCanvas) 
controlP5.ControllerGroup : Textarea removeProperty(String) 
controlP5.ControllerGroup : Textarea removeProperty(String, String) 
controlP5.ControllerGroup : Textarea setAddress(String) 
controlP5.ControllerGroup : Textarea setArrayValue(float[]) 
controlP5.ControllerGroup : Textarea setColor(CColor) 
controlP5.ControllerGroup : Textarea setColorActive(int) 
controlP5.ControllerGroup : Textarea setColorBackground(int) 
controlP5.ControllerGroup : Textarea setColorForeground(int) 
controlP5.ControllerGroup : Textarea setColorLabel(int) 
controlP5.ControllerGroup : Textarea setColorValue(int) 
controlP5.ControllerGroup : Textarea setHeight(int) 
controlP5.ControllerGroup : Textarea setId(int) 
controlP5.ControllerGroup : Textarea setLabel(String) 
controlP5.ControllerGroup : Textarea setMouseOver(boolean) 
controlP5.ControllerGroup : Textarea setMoveable(boolean) 
controlP5.ControllerGroup : Textarea setOpen(boolean) 
controlP5.ControllerGroup : Textarea setPosition(PVector) 
controlP5.ControllerGroup : Textarea setPosition(float, float) 
controlP5.ControllerGroup : Textarea setStringValue(String) 
controlP5.ControllerGroup : Textarea setUpdate(boolean) 
controlP5.ControllerGroup : Textarea setValue(float) 
controlP5.ControllerGroup : Textarea setVisible(boolean) 
controlP5.ControllerGroup : Textarea setWidth(int) 
controlP5.ControllerGroup : Textarea show() 
controlP5.ControllerGroup : Textarea update() 
controlP5.ControllerGroup : Textarea updateAbsolutePosition() 
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
Textarea(java.lang.String theText, int theX, int theY)
           
 
Method Summary
 void controlEvent(ControlEvent theEvent)
          controlEvent is called by controlP5's ControlBroadcaster to inform available listeners about value changes.
 Textarea disableColorBackground()
           
 Textarea enableColorBackground()
           
 float getScrollPosition()
           
 java.lang.String getStringValue()
          
 java.lang.String getText()
          returns the text content of the textarea.
 float getValue()
          
 Label getValueLabel()
          returns the instance of the textarea's label.
 Textarea hideScrollbar()
           
 boolean isScrollable()
           
 Textarea scroll(float theValue)
          scroll the Textarea remotely.
 void scrolled(int theStep)
           
 Textarea setBorderColor(int theColor)
           
 Textarea setColor(int theColor)
          set the text color of the textarea.
 Textarea setColorBackground(int theColor)
          
 Textarea setFont(ControlFont theFont)
           
 Textarea setFont(int theFontIndex)
           
 Textarea setFont(processing.core.PFont thePFont)
           
 Textarea setHeight(int theValue)
          set the height of the textarea.
 Textarea setLineHeight(int theLineHeight)
          set the lineheight of the textarea.
 Textarea setScrollActive(int theColor)
           
 Textarea setScrollBackground(int theColor)
           
 Textarea setScrollForeground(int theColor)
           
 Textarea setSize(int theWidth, int theHeight)
           
 Textarea setText(java.lang.String theText)
          set the text of the textarea.
 Textarea setWidth(int theValue)
          set the width of the textarea.
 Textarea showScrollbar()
           
 java.lang.String stringValue()
          Deprecated. 
 float value()
          Deprecated. 
 Label valueLabel()
          Deprecated. 
 
Methods inherited from class controlP5.ControllerGroup
add, addCanvas, addDrawable, bringToFront, bringToFront, close, disableCollapse, enableCollapse, getAbsolutePosition, getAddress, getArrayValue, getCaptionLabel, getColor, getController, getHeight, getId, getInfo, getName, getPosition, getProperty, getProperty, getTab, 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, setColorForeground, setColorLabel, setColorValue, setGroup, setGroup, setId, setLabel, setMouseOver, setMoveable, setOpen, setPosition, setPosition, setStringValue, setTab, setTab, setTab, setUpdate, setValue, setVisible, show, toString, 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, updateInternalEvents
 

Constructor Detail

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
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

disableColorBackground

public Textarea disableColorBackground()

enableColorBackground

public Textarea enableColorBackground()

getScrollPosition

public float getScrollPosition()

getStringValue

public java.lang.String getStringValue()
Description copied from class: ControllerGroup

Specified by:
getStringValue in interface ControllerInterface
Overrides:
getStringValue in class ControllerGroup

getText

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

Returns:
String

getValue

public float getValue()

Specified by:
getValue in interface ControllerInterface
Overrides:
getValue in class ControllerGroup

getValueLabel

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

Overrides:
getValueLabel in class ControllerGroup
Returns:

hideScrollbar

public Textarea hideScrollbar()

isScrollable

public boolean isScrollable()

scroll

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

Parameters:
theValue -

scrolled

public void scrolled(int theStep)

setBorderColor

public Textarea setBorderColor(int theColor)
Parameters:
theColor -
Returns:
Textarea

setColor

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

Parameters:
theColor - int

setColorBackground

public Textarea setColorBackground(int theColor)
Description copied from class: ControllerGroup

Specified by:
setColorBackground in interface ControllerInterface
Overrides:
setColorBackground in class ControllerGroup

setFont

public Textarea setFont(ControlFont theFont)

setFont

public Textarea setFont(int theFontIndex)

setFont

public Textarea setFont(processing.core.PFont thePFont)

setHeight

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

Overrides:
setHeight in class ControllerGroup
Parameters:
theValue - int
Returns:
ControllerGroup

setLineHeight

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

Parameters:
theLineHeight - int

setScrollActive

public Textarea setScrollActive(int theColor)
Parameters:
theColor -
Returns:
Textarea

setScrollBackground

public Textarea setScrollBackground(int theColor)
Parameters:
theColor -
Returns:
Textarea

setScrollForeground

public Textarea setScrollForeground(int theColor)
Parameters:
theColor -
Returns:
Textarea

setSize

public Textarea setSize(int theWidth,
                        int theHeight)

setText

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

Parameters:
theText - String

setWidth

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

Overrides:
setWidth in class ControllerGroup
Parameters:
theValue - int
Returns:
ControllerGroup

showScrollbar

public Textarea showScrollbar()

stringValue

@Deprecated
public java.lang.String stringValue()
Deprecated. 

Overrides:
stringValue in class ControllerGroup

value

@Deprecated
public float value()
Deprecated. 

Overrides:
value in class ControllerGroup

valueLabel

@Deprecated
public Label valueLabel()
Deprecated. 

Overrides:
valueLabel in class ControllerGroup


processing library controlP5 by Andreas Schlegel. (c) 2012