jMobileCore toolkit

com.jmobilecore.ui.core
Class TextAreaComposer

java.lang.Object
  extended by com.jmobilecore.ui.core.TextAreaComposer
All Implemented Interfaces:
AbstractComposer

public class TextAreaComposer
extends java.lang.Object
implements AbstractComposer

The TextAreaText defines set of methods that supports a text caret's handling and basic text editing.

Author:
Evgeniy Krapiva, Greg Gridin

Nested Class Summary
static class TextAreaComposer.LineRange
          LineRange represents 2 numbers - ranges for displayed text
 
Field Summary
protected  int caretPosition
          Current caret position in characters from the beginning of text
protected  int caretPositionX
          Current caret position from the beginning of a row
protected  int caretPositionY
          The caret vertical position from the top of component
protected  TextAreaComposer.LineRange currentRange
          Current row where the caret is situated
protected  java.util.Vector linebreaks
          Holds the LineRange classes.
protected  java.lang.StringBuffer text
          The text to edit
 byte wrappingStyle
          Current wrapping style
 
Constructor Summary
TextAreaComposer(int rows, int compwidth, javax.microedition.lcdui.Font font)
          Constructs new instance of TextAreaText.
 
Method Summary
 boolean addChar(char ch, boolean insertMode)
          Adds new symbol or replaces the current one
 void appendText(java.lang.String str)
          Appends the given text to the text area's current text.
 boolean backspace()
          Deletes previous symbol, moves cursor one position left
protected  boolean caretDown()
          Moves the caret one position down
 boolean caretLeft()
          Moves the caret one position left
 boolean caretRight()
          Moves the caret one position right
protected  boolean caretUp()
          Moves the caret one position up
 boolean deleteChar()
          Deletes current symbol
 void destructor()
          Default destructor.
protected  int findRange(int pos)
          Returns the range for the specified offset
 int getCaretPosition()
          Returns the caret position
 char[] getChars()
          Returns the char array (mutable) that is presented by this text component.
 int getCurrentLength()
          Returns the current text length
 java.lang.String getText()
          Returns the text that is presented by this text component.
 void indexText()
          Splits the text onto displayable substrings
 void insertText(java.lang.String str, int pos)
          Inserts the specified text at the specified position in this text area.
 void reset(javax.microedition.lcdui.Font font)
           
 boolean setCaretPosition(int pos)
          Sets cater position to specified position
 void setText(java.lang.String newText)
          Sets the text that is presented by this text component to be the specified text.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

caretPosition

protected int caretPosition
Current caret position in characters from the beginning of text


caretPositionX

protected int caretPositionX
Current caret position from the beginning of a row


caretPositionY

protected int caretPositionY
The caret vertical position from the top of component


currentRange

protected TextAreaComposer.LineRange currentRange
Current row where the caret is situated


linebreaks

protected java.util.Vector linebreaks
Holds the LineRange classes. Total number of rows the flat text is splitted into equals linebreaks.size()


text

protected java.lang.StringBuffer text
The text to edit


wrappingStyle

public byte wrappingStyle
Current wrapping style

Constructor Detail

TextAreaComposer

public TextAreaComposer(int rows,
                        int compwidth,
                        javax.microedition.lcdui.Font font)
Constructs new instance of TextAreaText.

Parameters:
rows - the number of rows to display
compwidth -
font - the current font
Method Detail

addChar

public boolean addChar(char ch,
                       boolean insertMode)
Adds new symbol or replaces the current one

Specified by:
addChar in interface AbstractComposer
Parameters:
ch - new symbol
insertMode - if true then new symbol will be added, otherwise the current symbol will be replaced
Returns:
true if the add/replace is possible, false otherwise

appendText

public void appendText(java.lang.String str)
Appends the given text to the text area's current text.


backspace

public boolean backspace()
Deletes previous symbol, moves cursor one position left

Specified by:
backspace in interface AbstractComposer
Returns:
true if the delete and moving is possible/done, false otherwise

caretDown

protected boolean caretDown()
Moves the caret one position down

Returns:
true if the moving is possible/done, false otherwise

caretLeft

public boolean caretLeft()
Moves the caret one position left

Specified by:
caretLeft in interface AbstractComposer
Returns:
true if the moving is possible/done, false otherwise

caretRight

public boolean caretRight()
Moves the caret one position right

Specified by:
caretRight in interface AbstractComposer
Returns:
true if the moving is possible/done, false otherwise

caretUp

protected boolean caretUp()
Moves the caret one position up

Returns:
true if the moving is possible/done, false otherwise

deleteChar

public boolean deleteChar()
Deletes current symbol

Specified by:
deleteChar in interface AbstractComposer
Returns:
true if the delete possible/done, false otherwise

destructor

public void destructor()
Default destructor. Helps VM to perform garbage collection

Specified by:
destructor in interface AbstractComposer

findRange

protected int findRange(int pos)
Returns the range for the specified offset


getCaretPosition

public int getCaretPosition()
Description copied from interface: AbstractComposer
Returns the caret position

Specified by:
getCaretPosition in interface AbstractComposer

getChars

public char[] getChars()
Description copied from interface: AbstractComposer
Returns the char array (mutable) that is presented by this text component. Usually works faster and more efficient than #getText

Specified by:
getChars in interface AbstractComposer

getCurrentLength

public int getCurrentLength()
Description copied from interface: AbstractComposer
Returns the current text length

Specified by:
getCurrentLength in interface AbstractComposer

getText

public java.lang.String getText()
Returns the text that is presented by this text component.

Specified by:
getText in interface AbstractComposer

indexText

public void indexText()
Splits the text onto displayable substrings


insertText

public void insertText(java.lang.String str,
                       int pos)
Inserts the specified text at the specified position in this text area.


reset

public void reset(javax.microedition.lcdui.Font font)

setCaretPosition

public boolean setCaretPosition(int pos)
Sets cater position to specified position

Specified by:
setCaretPosition in interface AbstractComposer
Parameters:
pos - new caret position
Returns:
true if operation is successful, false otherwise

setText

public void setText(java.lang.String newText)
Sets the text that is presented by this text component to be the specified text.

Specified by:
setText in interface AbstractComposer
Parameters:
newText - the new text.

jMobileCore toolkit