com.sas.table
Class TextCell

com.sas.table.TextCell
All Implemented Interfaces:
com.sas.lang.ObjectDataInterface, com.sas.lang.StringDataInterface, CellViewInterface
Direct Known Subclasses:
TransformTextCell

public class TextCell
implements com.sas.lang.StringDataInterface

Provides a cell view for displaying and editing a paragraph of text.


Field Summary
 
Fields inherited from class com.sas.table.CellView
cell
 
Fields inherited from interface com.sas.table.CellViewInterface
FORMATTED_DATA, RAW_DATA
 
Constructor Summary
TextCell()
          Constructs a new TextCell object.
 
Method Summary
 int getCaretPosition()
          Returns the current caret position in the text string.
 java.lang.String getFormattedData()
          Alias for getText.
 int getMaximumStringWidth()
          Returns the maximum character length allowed for strings.
 int getMinimumStringWidth()
          Returns the minimum character length allowed for strings.
 int getMinimumWidth(java.awt.Graphics g)
          Returns the minimum width of the current cell in pixels.
 java.lang.Object getObjectData()
          Returns the data associated with the current cell.
 int getPreferredHeight(java.awt.Graphics g, int width)
          Returns the preferred height of the current cell in pixels.
 int getPreferredInputType()
          Returns FORMATTED_DATA as the preferred input type.
 int getPreferredOutputType()
          Returns FORMATTED_DATA as the preferred output type.
 int getPreferredWidth(java.awt.Graphics g, int height)
          Returns the preferred width of the current cell in pixels.
 java.lang.String getText()
          Returns the text value of the current cell.
protected  boolean isCharacterValid(char ch)
          Controls whether a character is inserted into the cell's data.
 boolean isPartiallyDisplayed()
          Indicates whether the TextCell's contents are currently displayed by the table view, but also clipped.
 void onActiveStateChanged(int oldState, int newState, java.awt.Point point)
          Notifies the view of a change to Cell.activeState.
 void paint(java.awt.Graphics g)
          Paints the TextCell
 void processFocusEvent(java.awt.event.FocusEvent event)
          Process focus events which occur on the TextCell.
 void processKeyEvent(java.awt.event.KeyEvent event)
          Process key events which occur on the TextCell.
 void processMouseEvent(java.awt.event.MouseEvent event)
          Process mouse events which occur on the TextCell.
 void processMouseMotionEvent(java.awt.event.MouseEvent event)
          Process mouse motion events which occur on the TextCell.
 void setFormattedData(java.lang.String data)
          Sets the text of the TextCell.
 void setMaximumStringWidth(int newValue)
          Gets the maximum character length allowed for strings.
 void setMinimumStringWidth(int newValue)
          Gets the minimum character length allowed for strings.
 void setObjectData(java.lang.Object newData)
          Sets the data associated with the current cell.
 void setText(java.lang.String newValue)
          Sets the text value of the current cell.
 
Methods inherited from class com.sas.table.CellView
getCell, getMinimumHeight, setCell
 

Constructor Detail

TextCell

public TextCell()
Constructs a new TextCell object.

Method Detail

getCaretPosition

public int getCaretPosition()
Returns the current caret position in the text string. If TextCell is not in edit mode -1 is returned. Edit mode is determined by the cell's activation level.

Returns:
the current caret position if in edit mode, otherwise -1

getFormattedData

public java.lang.String getFormattedData()
Alias for getText.

Specified by:
getFormattedData in interface CellViewInterface
Overrides:
getFormattedData in class CellView
Returns:
the current text value
See Also:
getText()

getMaximumStringWidth

public int getMaximumStringWidth()
Returns the maximum character length allowed for strings.

Returns:
the maximum character length allowed for strings
See Also:
setMaximumStringWidth(int)

getMinimumStringWidth

public int getMinimumStringWidth()
Returns the minimum character length allowed for strings.

Returns:
the minimum character length allowed for strings
See Also:
setMinimumStringWidth(int)

getMinimumWidth

public int getMinimumWidth(java.awt.Graphics g)
Returns the minimum width of the current cell in pixels. The minimum width will be based on the size of the text measured using the current font.

Specified by:
getMinimumWidth in interface CellViewInterface
Overrides:
getMinimumWidth in class CellView
Parameters:
g - The graphics context to measure the cell in.
Returns:
the minimum width in pixels
See Also:
CellView.getMinimumHeight(java.awt.Graphics)

getObjectData

public java.lang.Object getObjectData()
Returns the data associated with the current cell. This is an alias to getFormattedData since the preferred input type of TextCell is FORMATTED_DATA.

Specified by:
getObjectData in interface com.sas.lang.ObjectDataInterface
Returns:
the data associated with the current cell
See Also:
setObjectData(java.lang.Object), getFormattedData()

getPreferredHeight

public int getPreferredHeight(java.awt.Graphics g,
                              int width)
Returns the preferred height of the current cell in pixels. The preferred height will be based on the size of the text within the specified width and measured using the current font.

Specified by:
getPreferredHeight in interface CellViewInterface
Parameters:
g - The graphics context to measure the cell in.
width - The width (in pixels) to constrain by. Specify -1 to not constrain.
Returns:
the preferred height of the current cell in pixels
See Also:
getPreferredWidth(java.awt.Graphics, int)

getPreferredInputType

public int getPreferredInputType()
Returns FORMATTED_DATA as the preferred input type.

Specified by:
getPreferredInputType in interface CellViewInterface
Overrides:
getPreferredInputType in class CellView
Returns:
FORMATTED_DATA
See Also:
CellViewInterface.getPreferredInputType()

getPreferredOutputType

public int getPreferredOutputType()
Returns FORMATTED_DATA as the preferred output type.

Specified by:
getPreferredOutputType in interface CellViewInterface
Overrides:
getPreferredOutputType in class CellView
Returns:
FORMATTED_DATA
See Also:
CellViewInterface.getPreferredOutputType()

getPreferredWidth

public int getPreferredWidth(java.awt.Graphics g,
                             int height)
Returns the preferred width of the current cell in pixels. The preferred width will be based on the size of the text within the specified height and measured using the current font.

Specified by:
getPreferredWidth in interface CellViewInterface
Parameters:
g - The graphics context to measure the cell in.
height - The height (in pixels) to constrain by. Specify -1 to not constrain.
Returns:
the preferred width of the current cell in pixels
See Also:
getPreferredHeight(java.awt.Graphics, int)

getText

public java.lang.String getText()
Returns the text value of the current cell.

Specified by:
getText in interface com.sas.lang.StringDataInterface
Returns:
the text value of the current cell
See Also:
setText(java.lang.String)

isCharacterValid

protected boolean isCharacterValid(char ch)
Controls whether a character is inserted into the cell's data. This method is called whenever this cell is activated and a character is typed. If ch is not valid, the character is not inserted into the string.

Parameters:
ch - the character to validate
Returns:
true if the character is valid, false otherwise

isPartiallyDisplayed

public boolean isPartiallyDisplayed()
Indicates whether the TextCell's contents are currently displayed by the table view, but also clipped. In other words, the cell is scrolled into view but its contents are clipped within its current bounds

Specified by:
isPartiallyDisplayed in interface CellViewInterface
Overrides:
isPartiallyDisplayed in class CellView
Returns:
true if the TextCell's contents are displayed but clipped, and false otherwise.

onActiveStateChanged

public void onActiveStateChanged(int oldState,
                                 int newState,
                                 java.awt.Point point)
Description copied from class: CellView
Notifies the view of a change to Cell.activeState.

Specified by:
onActiveStateChanged in interface CellViewInterface
Overrides:
onActiveStateChanged in class CellView
Parameters:
oldState - The previous value of Cell.activeState.
newState - The new value of Cell.activeState.
point - Optional xy-coordinate (relative to the view's origin) where the activation was initiated. Could be used to position a text cursor, for example.
See Also:
CellViewInterface.onActiveStateChanged(int, int, java.awt.Point)

paint

public void paint(java.awt.Graphics g)
Paints the TextCell

Specified by:
paint in interface CellViewInterface
Parameters:
g - the graphics context to paint to

processFocusEvent

public void processFocusEvent(java.awt.event.FocusEvent event)
Process focus events which occur on the TextCell.

Specified by:
processFocusEvent in interface CellViewInterface
Overrides:
processFocusEvent in class CellView
Parameters:
event - the event to handle

processKeyEvent

public void processKeyEvent(java.awt.event.KeyEvent event)
Process key events which occur on the TextCell.

Specified by:
processKeyEvent in interface CellViewInterface
Overrides:
processKeyEvent in class CellView
Parameters:
event - the event to handle

processMouseEvent

public void processMouseEvent(java.awt.event.MouseEvent event)
Process mouse events which occur on the TextCell.

Specified by:
processMouseEvent in interface CellViewInterface
Overrides:
processMouseEvent in class CellView
Parameters:
event - the event to handle

processMouseMotionEvent

public void processMouseMotionEvent(java.awt.event.MouseEvent event)
Process mouse motion events which occur on the TextCell.

Specified by:
processMouseMotionEvent in interface CellViewInterface
Overrides:
processMouseMotionEvent in class CellView
Parameters:
event - the event to handle

setFormattedData

public final void setFormattedData(java.lang.String data)
Sets the text of the TextCell.

Specified by:
setFormattedData in interface CellViewInterface
Overrides:
setFormattedData in class CellView
Parameters:
data - the new text value
See Also:
CellView.getFormattedData()

setMaximumStringWidth

public void setMaximumStringWidth(int newValue)
Gets the maximum character length allowed for strings.

Parameters:
newValue - the new maximum character length allowed for strings
See Also:
getMaximumStringWidth()

setMinimumStringWidth

public void setMinimumStringWidth(int newValue)
Gets the minimum character length allowed for strings.

Parameters:
newValue - the new minimum character length allowed for strings
See Also:
getMinimumStringWidth()

setObjectData

public final void setObjectData(java.lang.Object newData)
Sets the data associated with the current cell. Since the preferred input type of TextCell is FORMATTED_DATA, the result of toString on newData will be set as the text.

Specified by:
setObjectData in interface com.sas.lang.ObjectDataInterface
Parameters:
newData - the data to associate with the current cell
See Also:
getObjectData()

setText

public void setText(java.lang.String newValue)
Sets the text value of the current cell.

Specified by:
setText in interface com.sas.lang.StringDataInterface
Parameters:
newValue - the new text value
See Also:
getText()



Copyright © 2009 SAS Institute Inc. All Rights Reserved.