com.mot.lnf
Class TextView

java.lang.Object
  |
  +--com.mot.lnf.TextView

public abstract class TextView
extends java.lang.Object

The TextView class encapsulates all the logic needed to render multiple and single line text. To that end, this class helps maintain a separation of data from the view of that data. Static or edited text can be displayed with this class. Included is support for cursor rendering, masked text, and text selection. Also supported is cursor movement on a line to line basis per the current view of text rendered.


Method Summary
 int getAvailableWidth()
          Get the width available to display this text view
 char[] getChars()
          Get the character array displayed by this TextView
 int getCursorIndex()
          Get the index of the cursor location
 int getFirstRowHeight()
          Get the height of the first row in this text view
 int getFirstRowIndent()
          This method returns the number of pixels the first row of text is indented.
abstract  int getFirstRowWidth()
          This method returns the width of the first row of text
 int getFitPolicy()
          Get the fit policy being used by this TextView
 javax.microedition.lcdui.Font getFont()
          Get the font being used to render characters in this TextView
abstract  int getHeight()
          Get the height required to display all the characters in this TextView
 int getLastRowHeight()
          Get the height of the last row in this text view
abstract  int getLastRowWidth()
          This method returns the width of the last row of text
 int getLayout()
          Get the layout of this TextView
 int getNumChars()
          Get the number of characters contained in this TextView
abstract  boolean isMultiLine()
          Find out if this TextView is displayed on multiple lines
abstract  boolean moveCursor(int direction)
          Move the cursor up or down
abstract  void paint(javax.microedition.lcdui.Graphics g)
          This method is used to paint the TextView to a Graphics object.
abstract  void reformatRow(int index)
          Reformat text starting at the beginning of the row containing the given index
 void reformatText()
          Reformat text which needs updating
abstract  void reformatText(int index)
          Reformat the contents of this TextView
 void setAvailableWidth(int w)
          Set the width available for this TextView
 void setChars(char[] c, int num)
          Set the characters to be displayed in this TextView
 void setCursorIndex(int idx)
          Set the index of where the cursor is located in this TextField
 void setDecimalMode(boolean dec, char decChar)
          Turn decimal mode on or off
 void setFirstRowHeight(int rowHeight)
          This method is used to manually set row heights.
 void setFirstRowIndent(int inset)
          This method sets the horizontal inset of the first row for this TextView.
 void setFitPolicy(int newPolicy)
          Set the fit policy for this TextView.
 void setFont(javax.microedition.lcdui.Font f)
          This method sets the font for the TextView.
 void setLastRowHeight(int rowHeight)
          This method is used to manually set row heights.
 void setLayout(int lyt)
          Set the layout for this TextView
 void setNumChars(int num)
          Set the number of valid characters in the character array
 void setPasswordMode(boolean hide)
          Turn password mode on or off
 void setXPosition(int newX)
          Set the x position for contents of this TextView
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getFirstRowWidth

public abstract int getFirstRowWidth()
This method returns the width of the first row of text
Returns:
The width, in pixels, of the first row of text.

getHeight

public abstract int getHeight()
Get the height required to display all the characters in this TextView
Returns:
height of the text, in pixels

getLastRowWidth

public abstract int getLastRowWidth()
This method returns the width of the last row of text
Returns:
The width, in pixels, of the last row of text.

isMultiLine

public abstract boolean isMultiLine()
Find out if this TextView is displayed on multiple lines
Returns:
true for a multi-line TextView

moveCursor

public abstract boolean moveCursor(int direction)
Move the cursor up or down
Parameters:
direction - to move the cursor, one of Canvas.UP or Canvas.DOWN
Returns:
true if the cursor moved, false if not

paint

public abstract void paint(javax.microedition.lcdui.Graphics g)
This method is used to paint the TextView to a Graphics object.

Parameters:
g - the graphics object to be painted to.

reformatText

public abstract void reformatText(int index)
Reformat the contents of this TextView
Parameters:
index - of character to start updating

reformatRow

public abstract void reformatRow(int index)
Reformat text starting at the beginning of the row containing the given index
Parameters:
index - which needs updating

getAvailableWidth

public int getAvailableWidth()
Get the width available to display this text view
Returns:
the width, in pixels, allocated for displaying text

getChars

public char[] getChars()
Get the character array displayed by this TextView
Returns:
the character array stored in this TextView

getCursorIndex

public int getCursorIndex()
Get the index of the cursor location
Returns:
index of the cursor

getFirstRowHeight

public int getFirstRowHeight()
Get the height of the first row in this text view
Returns:
height of the first row, in pixels

getFirstRowIndent

public int getFirstRowIndent()
This method returns the number of pixels the first row of text is indented.
Returns:
The indent amount, in pixels, of the first row of text.

getFitPolicy

public int getFitPolicy()
Get the fit policy being used by this TextView
Returns:
one of Choice.TEXT_WRAP_DEFAULT, Choice.TEXT_WRAP_ON, Choice.TEXT_WRAP_OFF

getFont

public javax.microedition.lcdui.Font getFont()
Get the font being used to render characters in this TextView
Returns:
The font being used for rendering

getLastRowHeight

public int getLastRowHeight()
Get the height of the last row in this text view
Returns:
height of the last row, in pixels

getLayout

public int getLayout()
Get the layout of this TextView
Returns:
layout

getNumChars

public int getNumChars()
Get the number of characters contained in this TextView

reformatText

public void reformatText()
Reformat text which needs updating

setAvailableWidth

public void setAvailableWidth(int w)
Set the width available for this TextView
Parameters:
w - the new width to be used in this TextView

setChars

public void setChars(char[] c,
                     int num)
Set the characters to be displayed in this TextView
Parameters:
c - the characters to be displayed

setCursorIndex

public void setCursorIndex(int idx)
Set the index of where the cursor is located in this TextField
Parameters:
idx - new index of the cursor

setFirstRowHeight

public void setFirstRowHeight(int rowHeight)
This method is used to manually set row heights.

The implementation supports manual row height setting for the first and last rows individually. Other rows will receive the same height setting. For all rows the height specified must be at least equal to the line height of the Font for the TextView. Rows specified to be set at a smaller height will be set to the Font line height.

Parameters:
rowHeight - the height for that row.

setFirstRowIndent

public void setFirstRowIndent(int inset)
This method sets the horizontal inset of the first row for this TextView.

The first row of text will be inset by this amount effectively shortening the potential width of that row only. This inset will appear on the right or left of the row depending on justification. Calling this method with center justification set has no effect.
Parameters:
inset - the width in pixels of the inset for the first row.

setFitPolicy

public void setFitPolicy(int newPolicy)
Set the fit policy for this TextView. Options are: Choice.TEXT_WRAP_DEFAULT, Choice.TEXT_WRAP_ON, Choice.TEXT_WRAP_OFF
Parameters:
newPolicy - the fit policy to be used in this TextView

setFont

public void setFont(javax.microedition.lcdui.Font f)
This method sets the font for the TextView.

Parameters:
f - the new font to use to render characters on this TextView.

setLastRowHeight

public void setLastRowHeight(int rowHeight)
This method is used to manually set row heights.

The implementation supports manual row height setting for the first and last rows individually. Other rows will receive the same height setting. For all rows the height specified must be at least equal to the line height of the Font for the TextView. Rows specified to be set at a smaller height will be set to the Font line height.

Parameters:
rowHeight - the height for that row.

setLayout

public void setLayout(int lyt)
Set the layout for this TextView
Parameters:
lyt - new layout directive for this TextView, a combination of layout directives, as specified in javax.microedition.lcdui.Item.

setNumChars

public void setNumChars(int num)
Set the number of valid characters in the character array
Parameters:
num - How many valid chars are in the current char array

setPasswordMode

public void setPasswordMode(boolean hide)
Turn password mode on or off
Parameters:
hide - true if contents should be hidden

setDecimalMode

public void setDecimalMode(boolean dec,
                           char decChar)
Turn decimal mode on or off
Parameters:
dec - true if the text is under DECIMAL constraints
decChar - character to use to display the decimal

setXPosition

public void setXPosition(int newX)
Set the x position for contents of this TextView
Parameters:
newX - New x position