org.mt4j.components.visibleComponents.widgets
Class MTTextArea

java.lang.Object
  extended by org.mt4j.components.MTComponent
      extended by org.mt4j.components.visibleComponents.AbstractVisibleComponent
          extended by org.mt4j.components.visibleComponents.shapes.AbstractShape
              extended by org.mt4j.components.visibleComponents.shapes.MTPolygon
                  extended by org.mt4j.components.visibleComponents.shapes.MTRectangle
                      extended by org.mt4j.components.visibleComponents.widgets.MTTextArea
All Implemented Interfaces:
IMTComponent, IMTComponent3D, ITextInputListener, IMTInputEventListener, IdragClusterable, IGestureEventListener
Direct Known Subclasses:
MTTextField

public class MTTextArea
extends MTRectangle

    
implements IdragClusterable, ITextInputListener

    

The Class MTTextArea. This widget allows to display text with a specified font. If the constructor with no fixed text are dimensions is used, the text area will expand itself to fit the text in.
If the constructor with fixed dimensions is used, the text will have word wrapping and be clipped to the specified dimensions.

Author:
Christopher Ruff

Nested Class Summary
 
Nested classes/interfaces inherited from class org.mt4j.components.visibleComponents.shapes.MTRectangle
MTRectangle.PositionAnchor
 
Field Summary
 
Fields inherited from class org.mt4j.components.visibleComponents.shapes.AbstractShape
BOUNDS_CHECK_THEN_GEOMETRY_CHECK, BOUNDS_DONT_USE, BOUNDS_ONLY_CHECK
 
Constructor Summary
MTTextArea(float x, float y, float width, float height, IFont font, processing.core.PApplet pApplet)
          Instantiates a new mT text area.
MTTextArea(processing.core.PApplet pApplet, IFont font)
          Instantiates a new text area.
 
Method Summary
 void appendCharByName(java.lang.String characterName)
          Append char by name.
 void appendCharByUnicode(java.lang.String unicode)
          Append char by unicode.
 void appendText(java.lang.String string)
          Appends the string to the textarea.
protected  void characterAdded(IFontCharacter character)
           
protected  void characterRemoved(IFontCharacter character)
           
 void clear()
          resets the textarea, clears all characters.
 void drawComponent(processing.core.PGraphics g)
          Draws this component only (Not its children!).
 IFontCharacter[] getCharacters()
          Gets the characters.
 IFont getFont()
          Gets the font.
 float getInnerPadding()
           
protected  float getLastLineWidth()
           
 int getLineCount()
          Gets the line count.
protected  float getMaxLineWidth()
          Gets the max line width.
protected  float getScrollTextX()
           
protected  float getScrollTextY()
           
 java.lang.String getText()
          Gets the text.
protected  float getTotalLinesHeight()
          Gets the total lines height.
 boolean isEnableCaret()
          Checks if is enable caret.
 boolean isSelected()
          Checks if is selected.
 void postDraw(processing.core.PGraphics graphics)
          Post draw.
 void preDraw(processing.core.PGraphics graphics)
          This method is called just before the components drawComponent method is invoked.
 void removeLastCharacter()
          Removes the last character in the textarea.
protected  void scrollTextX(float amount)
           
protected  void scrollTextY(float amount)
           
 void setBitmapFontTextureFiltered(boolean scalable)
          Changes the texture filtering for the textarea's bitmap font.
 void setEnableCaret(boolean enableCaret)
          Sets the enable caret.
 void setHeightLocal(float height)
          Sets the height local.
 void setInnerPadding(float innerPadding)
           
 void setSelected(boolean selected)
          Sets the selected.
 void setText(java.lang.String string)
          Sets the provided string as the text of this textarea.
 void setWidthLocal(float width)
          Sets the width local.
 void snapToKeyboard(MTKeyboard mtKeyboard)
          Snap to keyboard.
 void updateComponent(long timeDelta)
          Tells the component to update its state if neccessary.
 
Methods inherited from class org.mt4j.components.visibleComponents.shapes.MTRectangle
computeDefaultBounds, get2DPolygonArea, getAnchor, getCenterOfMass2DLocal, getCenterPointLocal, getPosition, setAnchor, setPositionGlobal, setPositionRelativeToParent, setSizeLocal
 
Methods inherited from class org.mt4j.components.visibleComponents.shapes.MTPolygon
destroyComponent, drawPureGl, getGeometryIntersectionLocal, getHeightXY, getHeightXYVectLocal, getNormal, getWidthXY, getWidthXYVectLocal, isGeometryContainsPointLocal, setGeometryInfo, setHeightXYGlobal, setHeightXYRelativeToParent, setSizeXYGlobal, setSizeXYRelativeToParent, setVertices, setWidthXYGlobal, setWidthXYRelativeToParent
 
Methods inherited from class org.mt4j.components.visibleComponents.shapes.AbstractShape
componentContainsPointLocal, destroy, destroyDisplayLists, disableAndDeleteDisplayLists, generateAndUseDisplayLists, generateDisplayLists, getBoundingShape, getCenterPointGlobal, getCenterPointRelativeToParent, getConvexHullXYGlobal, getGeometryInfo, getIntersectionLocal, getTexture, getTextureMode, getVertexCount, getVerticesGlobal, getVerticesLocal, isBoundingShapeSet, isBoundsAutoCompute, isContainedIn, isTextureEnabled, isUseDirectGL, isUseDisplayList, isUseVBOs, setBoundingShape, setBoundsAutoCompute, setBoundsBehaviour, setBoundsPickingBehaviour, setDefaultGestureActions, setFillColor, setMatricesDirty, setPositionRelativeToOther, setStrokeColor, setTexture, setTextureEnabled, setTextureMode, setUseDirectGL, setUseDisplayList, setUseVBOs, tweenTranslate, tweenTranslate, tweenTranslateTo
 
Methods inherited from class org.mt4j.components.visibleComponents.AbstractVisibleComponent
applyStyle, getFillColor, getFillDrawMode, getFillPaint, getLineStipple, getMaterial, getStrokeColor, getStrokeWeight, getStyleInfo, isDrawSmooth, isNoFill, isNoStroke, postDrawChildren, setDrawSmooth, setFillDrawMode, setFillPaint, setLineStipple, setMaterial, setNoFill, setNoStroke, setStrokeWeight, setStyleInfo
 
Methods inherited from class org.mt4j.components.MTComponent
addChild, addChild, addChildren, addGestureListener, addInputListener, addStateChangeListener, applyLocalMatrix, attachCamera, containsChild, containsDirectChild, containsPointGlobal, fireInputEvent, fireStateChange, fireStateChange, getAttachedCamera, getChildbyID, getChildByIndex, getChildByName, getChildClip, getChildCount, getChildIndexOf, getChildList, getChildren, getClip, getController, getCustomViewportSetting, getDefaultViewportSetting, getGestureListeners, getGlobalInverseMatrix, getGlobalMatrix, getGlobalVecToParentRelativeSpace, getID, getInputListeners, getInputProcessors, getIntersectionGlobal, getLight, getLocalInverseMatrix, getLocalMatrix, getLocalVecToParentRelativeSpace, getName, getParent, getRenderer, getRoot, getTransformToDestinationLocalSpace, getTransformToDestinationParentSpace, getUserData, getViewingCamera, globalToLocal, globalToLocal, hasCustomViewPort, isComposite, isDepthBufferDisabled, isEnabled, isGestureAllowed, isPickable, isVisible, localToGlobal, pick, pick, processGestureEvent, processInputEvent, registerInputProcessor, removeAllChildren, removeAllGestureEventListeners, removeAllGestureEventListeners, removeChild, removeChild, removeFromParent, removeGestureEventListener, removeInputListener, removeStateChangeListener, reOrthogonalize, rotateX, rotateX, rotateXGlobal, rotateY, rotateY, rotateYGlobal, rotateZ, rotateZ, rotateZGlobal, scale, scale, scaleGlobal, sendChildToFront, sendToFront, setChildClip, setClip, setComposite, setController, setDepthBufferDisabled, setEnabled, setGestureAllowance, setLight, setLocalMatrix, setName, setPickable, setUserData, setViewPortSettings, setVisible, toString, transform, translate, translate, translateGlobal, unregisterAllInputProcessors, unregisterInputProcessor
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.mt4j.input.inputProcessors.componentProcessors.lassoProcessor.IdragClusterable
getCenterPointGlobal
 
Methods inherited from interface org.mt4j.components.interfaces.IMTComponent3D
getCustomViewportSetting, getDefaultViewportSetting, getIntersectionGlobal, getViewingCamera, hasCustomViewPort, isPickable, rotateXGlobal, rotateYGlobal, setPickable
 
Methods inherited from interface org.mt4j.components.interfaces.IMTComponent
containsPointGlobal, getID, getName, getRenderer, isEnabled, isGestureAllowed, isVisible, processInputEvent, rotateZGlobal, scaleGlobal, setEnabled, setName, setVisible, translateGlobal
 

Constructor Detail

MTTextArea

public MTTextArea(float x,
                  float y,
                  float width,
                  float height,
                  IFont font,
                  processing.core.PApplet pApplet)
Instantiates a new mT text area. This constructor creates a textarea with fixed dimensions. If the text exceeds the dimensions the text is clipped.

Parameters:
x - the x
y - the y
width - the width
height - the height
font - the font
pApplet - the applet

MTTextArea

public MTTextArea(processing.core.PApplet pApplet,
                  IFont font)
Instantiates a new text area. This constructor creates a text area with variable dimensions that expands itself when text is added.

Parameters:
pApplet - the applet
font - the font
Method Detail

updateComponent

public void updateComponent(long timeDelta)
Description copied from class: MTComponent
Tells the component to update its state if neccessary. This is called shortly before the component's drawComponent() method is invoked. The timeDelta parameter indicates the time passed since the last frame was drawn and can be used for animation for example.
Also, this updates the associated IMTController object if existing. If overriden, the superclass implementation should always be called!

Specified by:
updateComponent in interface IMTComponent
Overrides:
updateComponent in class MTComponent
Parameters:
timeDelta - the time delta

preDraw

public void preDraw(processing.core.PGraphics graphics)
Description copied from class: MTComponent
This method is called just before the components drawComponent method is invoked. It sets up the components matrix, clipping and other stuff.

Overrides:
preDraw in class AbstractVisibleComponent
Parameters:
graphics - the graphics context

drawComponent

public void drawComponent(processing.core.PGraphics g)
Description copied from class: MTComponent
Draws this component only (Not its children!).
This method can be overridden in subclasses and filled with drawing commands.

Specified by:
drawComponent in interface IMTComponent
Overrides:
drawComponent in class MTPolygon
Parameters:
g - the graphics context

postDraw

public void postDraw(processing.core.PGraphics graphics)
Description copied from class: MTComponent
Post draw. Called immediatly after drawing this component.

Overrides:
postDraw in class AbstractVisibleComponent

scrollTextX

protected void scrollTextX(float amount)

scrollTextY

protected void scrollTextY(float amount)

getScrollTextX

protected float getScrollTextX()

getScrollTextY

protected float getScrollTextY()

setBitmapFontTextureFiltered

public void setBitmapFontTextureFiltered(boolean scalable)
Changes the texture filtering for the textarea's bitmap font. (if a bitmap font is used). If the parameter is "true" this will allow the text being scaled without getting too pixelated. If the text isnt going to be scaled ever, it is best to leave or set this to "false" for a sharper text.
NOTE: Only applies if OpenGL is the renderer and the textarea uses a bitmap font.
NOTE: This affects the whole bitmap font so if it is used elsewhere it is changed there, too.

Parameters:
scalable - the new bitmap font scalable

setWidthLocal

public void setWidthLocal(float width)
Sets the width local.

Overrides:
setWidthLocal in class MTRectangle
Parameters:
width - the new width local

setHeightLocal

public void setHeightLocal(float height)
Sets the height local.

Overrides:
setHeightLocal in class MTRectangle
Parameters:
height - the new height local

appendText

public void appendText(java.lang.String string)
Appends the string to the textarea.

Specified by:
appendText in interface ITextInputListener
Parameters:
string - the string

setText

public void setText(java.lang.String string)
Sets the provided string as the text of this textarea.

Specified by:
setText in interface ITextInputListener
Parameters:
string - the string

getText

public java.lang.String getText()
Description copied from interface: ITextInputListener
Gets the text.

Specified by:
getText in interface ITextInputListener
Returns:
the text

appendCharByName

public void appendCharByName(java.lang.String characterName)
Append char by name.

Parameters:
characterName - the character name

appendCharByUnicode

public void appendCharByUnicode(java.lang.String unicode)
Description copied from interface: ITextInputListener
Append char by unicode.

Specified by:
appendCharByUnicode in interface ITextInputListener
Parameters:
unicode - the unicode

getCharacters

public IFontCharacter[] getCharacters()
Gets the characters.

Returns:
the characters

characterAdded

protected void characterAdded(IFontCharacter character)

characterRemoved

protected void characterRemoved(IFontCharacter character)

removeLastCharacter

public void removeLastCharacter()
Removes the last character in the textarea.

Specified by:
removeLastCharacter in interface ITextInputListener

clear

public void clear()
resets the textarea, clears all characters.

Specified by:
clear in interface ITextInputListener

getLastLineWidth

protected float getLastLineWidth()

getMaxLineWidth

protected float getMaxLineWidth()
Gets the max line width. The padding is also added.

Returns:
the max line width

getTotalLinesHeight

protected float getTotalLinesHeight()
Gets the total lines height. Padding is not included

Returns:
the total lines height

getInnerPadding

public float getInnerPadding()

setInnerPadding

public void setInnerPadding(float innerPadding)

getLineCount

public int getLineCount()
Gets the line count.

Returns:
the line count

getFont

public IFont getFont()
Gets the font.

Returns:
the font

snapToKeyboard

public void snapToKeyboard(MTKeyboard mtKeyboard)
Snap to keyboard.

Parameters:
mtKeyboard - the mt keyboard

isSelected

public boolean isSelected()
Description copied from interface: IdragClusterable
Checks if is selected.

Specified by:
isSelected in interface IdragClusterable
Returns:
true, if is selected

setSelected

public void setSelected(boolean selected)
Description copied from interface: IdragClusterable
Sets the selected.

Specified by:
setSelected in interface IdragClusterable
Parameters:
selected - the new selected

isEnableCaret

public boolean isEnableCaret()
Checks if is enable caret.

Returns:
true, if is enable caret

setEnableCaret

public void setEnableCaret(boolean enableCaret)
Sets the enable caret.

Parameters:
enableCaret - the new enable caret