jMobileCore toolkit

com.jmobilecore.ui.core
Class TextComponent

java.lang.Object
  extended by com.jmobilecore.ui.core.Component
      extended by com.jmobilecore.ui.core.TextComponent
Direct Known Subclasses:
TextArea, TextField

public abstract class TextComponent
extends Component

The TextComponent class is the superclass of any component that allows the editing of some text.

The TextComponent class defines a set of methods that supports text editing using phone keypad.

Author:
Greg Gridin

Field Summary
protected static java.lang.String ALL_SPEC_CHARS
          All special character
static int BORDER_GAP
          The gap between the textfield frame and textfield text
static int BORDER_WIDTH
          The gap between the screen border and the textfield frame
static int C_ALL_SPEC_CHARS
          Allows all special characters in the document
static int C_ALPHA
          Allows all alphabet characters and space in the document
static int C_ALPHA_NUMERIC
          Allows alphanumeric characters in the document
static int C_ANY
          Allows any characters in the document
static int C_EMAIL
          Allows all email characters in the document
static int C_EMAIL_SPEC_CHARS
          Allows email special letters in the document
static int C_LOWER_CASE
          Allows lowercase letters in the document
static int C_NO_CHARS
          Do not allows any chars
static int C_NUMERIC
          Allows numbers in the document
static int C_SPACE
          Allows spaces in the document
static int C_UPPER_CASE
          Allows uppercase letters in the document
protected  java.util.Timer cHandler
          The timer is used to determine if key input time is elapsed
protected static char[][] CHAR_OPTIONS
          The characters, mapped to the number keys
protected  int charOptionCounter
          Index into charOptionCounter for the last character used.
protected  int constraint
          Constraints for the document
protected static int CURSOR_DELAY
          Blinking rate for the curson in milliseconds
static byte CURSOR_TYPE_LINE
           
static byte CURSOR_TYPE_SYMBOL
           
 boolean editable
          The flag that determines whether or not this text component is editable.
protected static java.lang.String EMAIL_SPEC_CHARS
          Email special characters
protected  boolean insertMode
          Indicated if text component is in insert mode
protected static int[] KEY_OPTIONS
          Phone keys used for data input.
protected  int lastKeyCode
           
protected static java.lang.String LC_CHARS
          Lowercase characters
protected static java.lang.String NUMERIC_CHARS
          Numeric characters
protected static java.lang.String SPACE_CHARS
          Space character
protected static java.lang.String UC_CHARS
          Uppercase characters
protected  char[] validChars
          The array of allowed characted
 
Fields inherited from class com.jmobilecore.ui.core.Component
alignment, background, CENTER, focusable, focusedBackground, focusedForeground, font, foreground, height, isCompletelyVisible, isFocused, isVisible, LEFT, parentScreen, RIGHT, screenY, valid, width
 
Constructor Summary
TextComponent(int constr)
          Creates a new TextComponent instance.
 
Method Summary
 void addValidChars(java.lang.String str)
          Adds valid characters for the component.
 void destructor()
          Default destructor.
 int getCaretPosition()
          Gets the position of the text insertion caret for this text component.
protected abstract  AbstractComposer getComposer()
          Gets current input composer
protected  int getKeyOption(int keyCode)
           
protected  void initCursor()
          Initializes new timer
protected  boolean isCharValid(char ch)
          Checks if the character is allows symbol
protected  boolean preProcessKeyCode(int keyCode)
           
protected  char processKeyCode(int keyCode)
           
protected  void resetCursor()
          Cancels the timer
protected  void resetCursorHandler()
           
 boolean setCaretPosition(int caretPosition)
          Sets the position of the text insertion caret for this text component.
 
Methods inherited from class com.jmobilecore.ui.core.Component
getBackground, getFont, getForeground, getHeight, getWidth, invalidate, isFocusOwner, keyPressed, keyReleased, keyRepeated, paint, paintBackground, pointerDragged, pointerPressed, pointerReleased, prepareForeground, releaseFocus, requestFocus, setFont, setHeight
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ALL_SPEC_CHARS

protected static final java.lang.String ALL_SPEC_CHARS
All special character

See Also:
Constant Field Values

BORDER_GAP

public static final int BORDER_GAP
The gap between the textfield frame and textfield text

See Also:
Constant Field Values

BORDER_WIDTH

public static final int BORDER_WIDTH
The gap between the screen border and the textfield frame

See Also:
Constant Field Values

C_ALL_SPEC_CHARS

public static final int C_ALL_SPEC_CHARS
Allows all special characters in the document

See Also:
ALL_SPEC_CHARS, Constant Field Values

C_ALPHA

public static final int C_ALPHA
Allows all alphabet characters and space in the document

See Also:
Constant Field Values

C_ALPHA_NUMERIC

public static final int C_ALPHA_NUMERIC
Allows alphanumeric characters in the document

See Also:
Constant Field Values

C_ANY

public static final int C_ANY
Allows any characters in the document

See Also:
Constant Field Values

C_EMAIL

public static final int C_EMAIL
Allows all email characters in the document

See Also:
Constant Field Values

C_EMAIL_SPEC_CHARS

public static final int C_EMAIL_SPEC_CHARS
Allows email special letters in the document

See Also:
EMAIL_SPEC_CHARS, Constant Field Values

C_LOWER_CASE

public static final int C_LOWER_CASE
Allows lowercase letters in the document

See Also:
LC_CHARS, Constant Field Values

C_NO_CHARS

public static final int C_NO_CHARS
Do not allows any chars

See Also:
Constant Field Values

C_NUMERIC

public static final int C_NUMERIC
Allows numbers in the document

See Also:
NUMERIC_CHARS, Constant Field Values

C_SPACE

public static final int C_SPACE
Allows spaces in the document

See Also:
SPACE_CHARS, Constant Field Values

C_UPPER_CASE

public static final int C_UPPER_CASE
Allows uppercase letters in the document

See Also:
UC_CHARS, Constant Field Values

cHandler

protected java.util.Timer cHandler
The timer is used to determine if key input time is elapsed


CHAR_OPTIONS

protected static final char[][] CHAR_OPTIONS
The characters, mapped to the number keys


charOptionCounter

protected volatile int charOptionCounter
Index into charOptionCounter for the last character used.


constraint

protected int constraint
Constraints for the document


CURSOR_DELAY

protected static final int CURSOR_DELAY
Blinking rate for the curson in milliseconds

See Also:
Constant Field Values

CURSOR_TYPE_LINE

public static final byte CURSOR_TYPE_LINE
See Also:
Constant Field Values

CURSOR_TYPE_SYMBOL

public static final byte CURSOR_TYPE_SYMBOL
See Also:
Constant Field Values

editable

public boolean editable
The flag that determines whether or not this text component is editable. If the flag is set to true, this text component becomes user editable. If the flag is set to false, the user cannot change the text of this text component.


EMAIL_SPEC_CHARS

protected static final java.lang.String EMAIL_SPEC_CHARS
Email special characters

See Also:
Constant Field Values

insertMode

protected volatile boolean insertMode
Indicated if text component is in insert mode


KEY_OPTIONS

protected static final int[] KEY_OPTIONS
Phone keys used for data input.


lastKeyCode

protected int lastKeyCode

LC_CHARS

protected static final java.lang.String LC_CHARS
Lowercase characters

See Also:
Constant Field Values

NUMERIC_CHARS

protected static final java.lang.String NUMERIC_CHARS
Numeric characters

See Also:
Constant Field Values

SPACE_CHARS

protected static final java.lang.String SPACE_CHARS
Space character

See Also:
Constant Field Values

UC_CHARS

protected static final java.lang.String UC_CHARS
Uppercase characters

See Also:
Constant Field Values

validChars

protected char[] validChars
The array of allowed characted

Constructor Detail

TextComponent

public TextComponent(int constr)
Creates a new TextComponent instance.

Parameters:
constr - Constraints for this document
Method Detail

addValidChars

public void addValidChars(java.lang.String str)
Adds valid characters for the component.

Parameters:
str - string of valid characters

destructor

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

Overrides:
destructor in class Component

getCaretPosition

public int getCaretPosition()
Gets the position of the text insertion caret for this text component.

Returns:
the position of the text insertion caret

getComposer

protected abstract AbstractComposer getComposer()
Gets current input composer


getKeyOption

protected int getKeyOption(int keyCode)

initCursor

protected void initCursor()
Initializes new timer


isCharValid

protected boolean isCharValid(char ch)
Checks if the character is allows symbol

Parameters:
ch - test character
Returns:
true if the characted is allwed symbol for the component, false otherwise

preProcessKeyCode

protected boolean preProcessKeyCode(int keyCode)

processKeyCode

protected char processKeyCode(int keyCode)

resetCursor

protected void resetCursor()
Cancels the timer


resetCursorHandler

protected void resetCursorHandler()

setCaretPosition

public boolean setCaretPosition(int caretPosition)
Sets the position of the text insertion caret for this text component. The caret position is constrained to be at or before the current selection end and non-negative.

Parameters:
caretPosition - the position of the text insertion caret
Returns:
true if setting of caret position is possible false

jMobileCore toolkit