|
Components |
|
| |||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
com.sas.table.Cell
public abstract class Cell
Defines an abstract base class for TableView's data and label cells.
Cell includes methods for accessing and changing a cell's data, determining whether it's displayed or been selected or modified, finding out its location and size, and associating a style with it.
Since TableView is designed to work with different cell types (implementations), a uniform way to access cells is needed -- Cell provides this. Cell is actually a wrapper around a cell view. A cell view is an implemenation of CellViewInterface that is used to display, format, and edit a cell's data. The cell view is accessible via the getView() method. The class of cell view that gets created is determined by the effective CellStyle.viewClass property. By default, TableView uses a TextCell for all cells, but each cell is free to use any implementation of CellViewInterface. For example, if TableView's model had a column (say column 3) of boolean data, you might want to configure TableView to use check boxes to display that data like so:
Column col = tableView.getColumn(3);
ColumnStyle colStyle = new ColumnStyle();
CellStyle cellStyle = new CellStyle();
cellStyle.setViewClass (CheckBoxCell.class);
colStyle.setDefaultCellStyle (cellStyle);
col.setStyle (colStyle);
TableView
,
DataCell
,
LabelCell
,
CellStyle
,
CellViewInterface
Field Summary |
---|
Fields inherited from class com.sas.table.TableElement |
---|
emptyModelTypesArray, emptyModelTypeStylesArray, tableView |
Fields inherited from interface com.sas.table.TableElementInterface |
---|
REFRESH_ALL, REFRESH_DATA, REFRESH_DATA_STYLE, REFRESH_LABEL, REFRESH_LABEL_STYLE, REFRESH_STYLE |
Constructor Summary | |
---|---|
protected |
Cell(TableView table)
Constructor. |
Method Summary | |
---|---|
abstract boolean |
equals(Cell other)
Compares this and a given cell for equality. |
boolean |
equals(TableElement obj)
Compares this and a given table element for equality. |
int |
getActiveState()
Returns the cell's activeState, i.e. it's degree or level of activation. |
java.awt.Rectangle |
getBounds()
Returns a rectangle that matches the cell's bounds, i.e. its location and size. |
java.awt.Rectangle |
getDisplayedBounds()
Returns a rectangle that matches the cell's displayed bounds, i.e. its location and displayed size. |
abstract int |
getDisplayedHeight()
Returns the vertical size of the area allotted to the cell in the table's current display. |
abstract int |
getDisplayedWidth()
Returns the horizontal size of the area allotted to the cell in the table's current display. |
java.awt.Font |
getEffectiveFont()
Returns the effective font, i.e. the font that will be used to paint the cell. |
void |
getEffectiveStylePropertyBag(java.lang.String propertyID,
com.sas.collection.PropertyBagInterface bag,
boolean clearBag)
Determines the effective value of the specified style property of type StaticPropertyBagInterface. |
java.lang.Object |
getEffectiveStylePropertyValue(java.lang.String propertyID,
java.lang.Object defaultValue)
Returns the effective value of the specified style property. |
java.awt.Graphics |
getGraphics()
Creates a graphics context for this cell. |
abstract int |
getHeight()
Returns the vertical extent of the cell. |
abstract int |
getHorizontalPosition()
Returns the x-coordinate of the top-left corner of the cell (relative to the top-left corner of the table). |
java.awt.Insets |
getInsets()
Returns this cell's insets. |
int |
getMinimumHeight(java.awt.Graphics g)
Returns the minimum amount of vertical space needed to display the cell in the given graphics context. |
int |
getMinimumWidth(java.awt.Graphics g)
Returns the minimum amount of horizontal space needed to display the cell in the given graphics context. |
java.lang.String[] |
getModelTypes()
Returns the types associated with this cell by the table view's model. |
com.sas.collection.StaticPropertyBagInterface[] |
getModelTypeStyles()
Returns the styles associated with the cell's model types. |
java.lang.Object |
getObjectData()
Returns the cell's data. |
abstract java.lang.Class |
getObjectDataClass()
Returns the class of the cell's data. |
int |
getPreferredHeight(java.awt.Graphics g)
Alias for "getPreferredHeight (g, -1)". |
int |
getPreferredHeight(java.awt.Graphics g,
int width)
Returns the preferred amount of vertical space needed to display the cell in the given graphics context. |
int |
getPreferredWidth(java.awt.Graphics g)
Alias for "getPreferredWidth (g, -1)". |
int |
getPreferredWidth(java.awt.Graphics g,
int height)
Returns the preferred amount of horizontal space needed to display the cell in the given graphics context. |
protected TableElement |
getThis()
Returns the TableElement instance to delegate all variable access to. |
protected abstract Cell |
getThisCell()
Returns the Cell instance to delegate all variable access to. |
abstract int |
getVerticalPosition()
Returns the y-coordinate of the top-left corner of the cell (relative to the top-left corner of the table). |
CellViewInterface |
getView()
Returns the instance of the effective CellStyle.viewClass that is used to format, render, and edit the cell's data. |
abstract int |
getWidth()
Returns the horizontal extent of the cell. |
boolean |
isActivated()
Returns true if the activeState is either ACTIVE_LIGHT or ACTIVE and false otherwise. |
boolean |
isDataInvalid()
Returns true if the cell contains invalid data and false otherwise. |
boolean |
isKeyHandled()
Returns the value of the keyHandled property. |
abstract boolean |
isLabel()
Returns true if the cell is a label and false otherwise. |
boolean |
isModified()
Returns true if the cell contains modified data and false otherwise. |
boolean |
isMouseCaptured()
Returns true if the cell has captured the mouse and false otherwise. |
boolean |
isSelected()
Returns true if the cell is selected in table and false otherwise. |
protected java.lang.String |
onGetFormattedData()
Cell framework method for seeding the cell's view with formatted data from the table's model. |
protected abstract java.lang.Object |
onGetObjectData()
Cell framework method for seeding the cell's view with data from the table's model. |
protected abstract java.lang.String[] |
onGetTypes()
Cell framework method for initializing the cell's type(s) from the table's model. |
protected void |
onPaintBackground(java.awt.Graphics g,
int width,
int height)
Cell.paint framework method for painting the cell's background. |
protected void |
onPaintBorder(java.awt.Graphics g,
int width,
int height)
Cell.paint framework method for painting the cell's border. |
protected void |
onPaintForeground(java.awt.Graphics g,
int width,
int height)
Cell.paint framework method for painting the cell's foreground. |
protected abstract void |
onWriteObjectData()
Cell framework method for writing the cell's data to the table's model. |
void |
paint(java.awt.Graphics g)
Paints the cell. |
void |
processFocusEvent(java.awt.event.FocusEvent event)
Forwards a focus event to the cell's view. |
void |
processKeyEvent(java.awt.event.KeyEvent event)
Forwards a key event to the cell's view. |
void |
processMouseEvent(java.awt.event.MouseEvent event)
Forwards a mouse event to the cell's view. |
void |
processMouseMotionEvent(java.awt.event.MouseEvent event)
Forwards a mouse motion event to the cell's view. |
void |
refresh(int flags)
Refreshes the cell to its state as maintained by the table view's model. |
void |
repaint()
Alias for "repaint (0, 0, getWidth(), getHeight())". |
void |
repaint(int x,
int y,
int width,
int height)
Repaints the specified rectangle of the cell. |
void |
setActiveState(int newValue)
Alias for "setActiveState (newValue, null)". |
void |
setActiveState(int newValue,
java.awt.Point point)
Sets the cell's activeState, i.e. it's degree or level of activation. |
void |
setKeyHandled(boolean newValue)
Sets the value of the keyHandled property. |
void |
setModified(boolean newValue)
Sets the value of the modified property. |
void |
setMouseCaptured(boolean newValue)
Enables or disables mouse capture by the cell. |
void |
setObsolete()
Indicates that the cell should be considered obsolete. |
void |
writeObjectData()
Writes the cell's data to the table's model. |
Methods inherited from class com.sas.table.TableElement |
---|
equals, getDefaultStyle, getModelDefaultStyle, getModelStyle, getStyle, getTableView, isCurrent, isTransient, onGetEffectiveStylePropertyBag, onGetEffectiveStylePropertyValue, onGetModelStyle, setStyle |
Methods inherited from interface com.sas.table.TableElementInterface |
---|
isDisplayed |
Constructor Detail |
---|
protected Cell(TableView table)
table
- The TableView instance that contains this cell.Method Detail |
---|
public final boolean equals(TableElement obj)
equals
in class TableElement
true
if obj is a Cell and
equals((Cell)obj)
returns true
;
false
otherwise.public abstract boolean equals(Cell other)
true
if this cell is equivalent to
other; false
otherwise.public int getActiveState()
CellActiveStates
,
setActiveState(int)
public final java.awt.Rectangle getBounds()
getDisplayedBounds()
public final java.awt.Rectangle getDisplayedBounds()
getBounds()
public abstract int getDisplayedHeight()
getHeight()
public abstract int getDisplayedWidth()
getWidth()
public java.awt.Font getEffectiveFont()
public void getEffectiveStylePropertyBag(java.lang.String propertyID, com.sas.collection.PropertyBagInterface bag, boolean clearBag)
getEffectiveStylePropertyBag
in class TableElement
propertyID
- An interned String (see String.intern()) which identifies a property
of type PropertyBagInterface, for example, CellStyle.FONT_STYLE.bag
- The bag to fill with the effective values of the subproperties
associated with propertyID.clearBag
- If true, an initial bag.removeAll() is done.TableElement.getEffectiveStylePropertyBag(java.lang.String, com.sas.collection.PropertyBagInterface, boolean)
,
getEffectiveStylePropertyValue(java.lang.String, java.lang.Object)
public java.lang.Object getEffectiveStylePropertyValue(java.lang.String propertyID, java.lang.Object defaultValue)
getEffectiveStylePropertyValue
in class TableElement
propertyID
- An interned String (see String.intern()) which identifies the property,
for example, CellStyle.FOREGROUND_COLOR.defaultValue
- Value to return if no value is found for the property.
TableElement.getEffectiveStylePropertyValue(java.lang.String, java.lang.Object)
,
getEffectiveStylePropertyBag(java.lang.String, com.sas.collection.PropertyBagInterface, boolean)
public java.awt.Graphics getGraphics()
null
if this cell is not currently on the screen.
null
if it has none.public abstract int getHeight()
getDisplayedHeight()
public abstract int getHorizontalPosition()
public java.awt.Insets getInsets()
public int getMinimumHeight(java.awt.Graphics g)
g
- The graphics context to measure the cell in.
public int getMinimumWidth(java.awt.Graphics g)
g
- The graphics context to measure the cell in.
public java.lang.Object getObjectData() throws com.sas.table.TableException
TableException
- If this is the first access of the data, the table's model will be
queried for it. This query can generate a TableException.
If the cell's view hasn't yet been created, it will be and any failure
while doing so (e.g. InstantiationException) will be recast as a
TableException.writeObjectData()
public abstract java.lang.Class getObjectDataClass() throws com.sas.table.TableException
TableException
- Thrown if the query can not be satisfied (e.g. i/o-failure).public final int getPreferredHeight(java.awt.Graphics g)
g
- The graphics context to measure the cell in.
public int getPreferredHeight(java.awt.Graphics g, int width)
g
- The graphics context to measure the cell in.width
- The width (in pixels) to constrain by. Specify -1 to not constrain.
public final int getPreferredWidth(java.awt.Graphics g)
g
- The graphics context to measure the cell in.
public int getPreferredWidth(java.awt.Graphics g, int height)
g
- The graphics context to measure the cell in.height
- The height (in pixels) to constrain by. Specify -1 to not constrain.
protected final TableElement getThis()
this
, but if this
has been obsoleted then a different, but equivalent, instance will be
returned.
getThis
in class TableElement
TableElement.setObsolete()
protected abstract Cell getThisCell()
this
, but if this
has been obsoleted then a different, but equivalent, instance will be
returned.
TableElement.setObsolete()
public java.lang.String[] getModelTypes()
getModelTypes
in class TableElement
StaticTableTypeInterface
,
getModelTypeStyles()
public com.sas.collection.StaticPropertyBagInterface[] getModelTypeStyles()
getModelTypeStyles
in class TableElement
StaticTableTypeStylesInterface
,
getModelTypes()
public abstract int getVerticalPosition()
public final CellViewInterface getView() throws com.sas.table.TableException
TableException
- If this is the first access to the view, the view will be created and
any failure while doing so (e.g. InstantiationException) will be
recast as a TableException. Creating the view involves seeding it
with data from the table's model. This model query can also generate
a TableException.public abstract int getWidth()
getDisplayedWidth()
public boolean isActivated()
public boolean isDataInvalid()
public boolean isKeyHandled()
setKeyHandled(boolean)
public abstract boolean isLabel()
public boolean isModified()
setModified(boolean)
public boolean isMouseCaptured()
setMouseCaptured(boolean)
public boolean isSelected()
protected java.lang.String onGetFormattedData() throws com.sas.table.TableException
TableException
- Propagated from call to model.protected abstract java.lang.Object onGetObjectData() throws com.sas.table.TableException
TableException
- Propagated from call to model.protected abstract java.lang.String[] onGetTypes() throws com.sas.table.TableException
TableException
- Propagated from call to model.protected void onPaintBackground(java.awt.Graphics g, int width, int height)
g
- The graphics context to use for painting.
Painting should be done relative to (0, 0).width
- The paintable width of the graphics context.height
- The paintable height of the graphics context.protected void onPaintBorder(java.awt.Graphics g, int width, int height)
g
- The graphics context to use for painting.
Painting should be done relative to (0, 0).width
- The paintable width of the graphics context.height
- The paintable height of the graphics context.protected void onPaintForeground(java.awt.Graphics g, int width, int height) throws com.sas.table.TableException
g
- The graphics context to use for painting.
Painting should be done relative to (0, 0).width
- The paintable width of the graphics context.height
- The paintable height of the graphics context.
TableException
- Can arise from a call to getView.protected abstract void onWriteObjectData() throws com.sas.table.TableException
TableException
- Propagated from call to model.public void paint(java.awt.Graphics g)
g
- The graphics context to use for painting.public void processFocusEvent(java.awt.event.FocusEvent event)
event
- The focus event.public void processKeyEvent(java.awt.event.KeyEvent event)
NOTE: Sets keyHandled to true before calling CellViewInterface.processKeyEvent. keyHandled-aware implementations of CellViewInterface can choose to set keyHandled to false in order to defer handling of the event to the table. For example, TextCell will do this for a right-arrow key event when the text cursor is already at the end of its text string, thus allowing the table to move to the next cell.
event
- The key event.public void processMouseEvent(java.awt.event.MouseEvent event)
event
- The mouse event. The event's point should be relative to the
table's origin, not the cell's.public void processMouseMotionEvent(java.awt.event.MouseEvent event)
event
- The mouse motion event. The event's point should be relative to the
table's origin, not the cell's.public void refresh(int flags)
refresh
in interface TableElementInterface
refresh
in class TableElement
flags
- Bitmask of REFRESH_DATA and/or REFRESH_STYLE.public final void repaint()
public void repaint(int x, int y, int width, int height)
x
- The x coordinate of the rectangle in pixels
relative to the top-left corner of the cell.y
- The y coordinate of the rectangle in pixels
relative to the top-left corner of the cell.width
- The width of the rectangle in pixels.height
- The height of the rectangle in pixels.public final void setActiveState(int newValue)
public void setActiveState(int newValue, java.awt.Point point)
Note: this is designed to be called by TableView; independent calls will result in TableView's currentElement property getting out-of-sync.
newValue
- The new value to assign the activeState property.
Valid values are any of the values defined by CellActiveStates.point
- Optional xy-coordinate (relative to the table's origin) where the
activation was initiated. Could be used to position a text cursor,
for example.getActiveState()
public void setKeyHandled(boolean newValue)
newValue
- The new value to assign the keyHandled property.isKeyHandled()
public void setModified(boolean newValue)
newValue
- The new value to assign the modified property.isModified()
public void setMouseCaptured(boolean newValue)
newValue
- The new value to assign the mouseCaptured property.isMouseCaptured()
public void setObsolete()
setObsolete
in class TableElement
TableElement.isTransient()
,
TableElement.equals(java.lang.Object)
public void writeObjectData() throws com.sas.table.TableException
TableException
- Propagated from call to model.getObjectData()
|
Components |
|
| |||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |