com.sas.table
Class TableElement

com.sas.table.TableElement
All Implemented Interfaces:
TableElementInterface
Direct Known Subclasses:
Cell, CellVector

public abstract class TableElement
implements TableElementInterface

Defines an abstract base class for TableView's cells, columns, and rows.

TableElement anchors a hierarchy of classes that represent the elements of a TableView. Those elements are divided into two general categories, cells and cell vectors, which are represented by the abstract subclasses Cell and CellVector.

Cells are divided into labels (LabelCell) and data cells (DataCell).

Cell vectors are divided into columns (Column) and rows (Row).

See Also:
TableView, Cell, CellVector, Column, DataCell, LabelCell, Row

Field Summary
protected static java.lang.String[] emptyModelTypesArray
          Helper variable to use as return value from getModelTypes when no model types are available for the element.
protected static com.sas.collection.StaticPropertyBagInterface[] emptyModelTypeStylesArray
          Helper variable to use as return value from getModelTypeStyles when no model type styles are available for the element.
 TableView tableView
          Alias for getTableView().
 
Fields inherited from interface com.sas.table.TableElementInterface
REFRESH_ALL, REFRESH_DATA, REFRESH_DATA_STYLE, REFRESH_LABEL, REFRESH_LABEL_STYLE, REFRESH_STYLE
 
Constructor Summary
TableElement(TableView table)
          Constructor.
 
Method Summary
 boolean equals(java.lang.Object obj)
          Compares this and a given object for equality.
abstract  boolean equals(TableElement other)
          Compares this and a given table element for equality.
abstract  com.sas.collection.StaticPropertyBagInterface getDefaultStyle()
          Returns the default style associated with elements of this type by the table view.
 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.
abstract  com.sas.collection.StaticPropertyBagInterface getModelDefaultStyle()
          Returns the default style associated with elements of this type by the table view's model.
 com.sas.collection.StaticPropertyBagInterface getModelStyle()
          Returns the set of model-supplied style property keys and their associated values that serve as formatting and rendering defaults and hints for the element.
abstract  java.lang.String[] getModelTypes()
          Returns the types associated with this element by the table view's model.
abstract  com.sas.collection.StaticPropertyBagInterface[] getModelTypeStyles()
          Returns the styles associated with the element's model types.
 com.sas.collection.StaticPropertyBagInterface getStyle()
          Returns the set of style property keys and their associated values that serve as formatting and rendering defaults and hints for the element.
 TableView getTableView()
          Returns the instance of the TableView class that contains this element.
protected abstract  TableElement getThis()
          Returns the TableElement instance to delegate all variable access to.
 boolean isCurrent()
          Returns true if the element is the table view's currentElement, and false otherwise.
 boolean isTransient()
          Returns true if the element is transient and false otherwise.
protected  void onGetEffectiveStylePropertyBag(java.lang.String propertyID, com.sas.collection.PropertyBagInterface bag)
          TableElement framework method for determining the effective value of a style property of type StaticPropertyBagInterface.
protected  java.lang.Object onGetEffectiveStylePropertyValue(java.lang.String propertyID, java.lang.Object defaultValue)
          TableElement framework method for determining the effective value of a style property.
protected abstract  com.sas.collection.StaticPropertyBagInterface onGetModelStyle()
          TableElement framework method for querying the table view's model for any style properties associated with the element.
 void refresh(int flags)
          Refreshes the element to its state as maintained by the table view's model.
abstract  void setObsolete()
          Indicates that the element should be considered obsolete.
 void setStyle(com.sas.collection.StaticPropertyBagInterface newValue)
          Sets the set of style property keys and their associated values that serve as formatting and rendering defaults and hints for the element.
 
Methods inherited from interface com.sas.table.TableElementInterface
isDisplayed, isModified, isSelected, repaint
 

Field Detail

emptyModelTypesArray

protected static final java.lang.String[] emptyModelTypesArray
Helper variable to use as return value from getModelTypes when no model types are available for the element.

See Also:
getModelTypes()

emptyModelTypeStylesArray

protected static final com.sas.collection.StaticPropertyBagInterface[] emptyModelTypeStylesArray
Helper variable to use as return value from getModelTypeStyles when no model type styles are available for the element.

See Also:
getModelTypeStyles()

tableView

public final TableView tableView
Alias for getTableView().

See Also:
getTableView()
Constructor Detail

TableElement

public TableElement(TableView table)
Constructor.

Parameters:
table - The TableView instance that contains this element.
Method Detail

equals

public final boolean equals(java.lang.Object obj)
Compares this and a given object for equality.

Overrides:
equals in class java.lang.Object
Returns:
true if obj is a TableElement and equals((TableElement)obj) returns true; false otherwise.

equals

public abstract boolean equals(TableElement other)
Compares this and a given table element for equality.

Returns:
true if this table element is equivalent to other; false otherwise.

getTableView

public final TableView getTableView()
Returns the instance of the TableView class that contains this element.

Specified by:
getTableView in interface TableElementInterface
Returns:
The value of the tableView property (will never be null).

getStyle

public com.sas.collection.StaticPropertyBagInterface getStyle()
Returns the set of style property keys and their associated values that serve as formatting and rendering defaults and hints for the element. There are no style properties by default, but any that are provided will override any model-supplied style properties.

Returns:
The value of the style property.
See Also:
setStyle(com.sas.collection.StaticPropertyBagInterface), getModelStyle(), getDefaultStyle(), getModelDefaultStyle()

setStyle

public void setStyle(com.sas.collection.StaticPropertyBagInterface newValue)
Sets the set of style property keys and their associated values that serve as formatting and rendering defaults and hints for the element. There are no style properties by default, but any that are provided will override any model-supplied style properties.

The style is saved as a reference, not a copy, but the element does not listen for events from the style so a change to the style's properties will not be immediately reflected by the element. Usually this is not an issue as styles will be created and assigned and won't change after that. However if you do plan to change the style after calling setStyle() and want the element to immediately reflect the change (e.g. new foreground color), then you can register the table as listener for changes to the style via style.addPropertyBagChangedListener (getTableView()).

Parameters:
newValue - The new value to assign the style property.
See Also:
getStyle(), getModelStyle(), getDefaultStyle(), getModelDefaultStyle(), getTableView(), PropertyBag.addPropertyBagChangedListener(com.sas.collection.PropertyBagChangedListener)

getModelStyle

public com.sas.collection.StaticPropertyBagInterface getModelStyle()
Returns the set of model-supplied style property keys and their associated values that serve as formatting and rendering defaults and hints for the element. A model-supplied style property will be overridden by a view-supplied counterpart.

Returns:
The value of the modelStyle property.
See Also:
getStyle(), getDefaultStyle(), getModelDefaultStyle()

getDefaultStyle

public abstract com.sas.collection.StaticPropertyBagInterface getDefaultStyle()
Returns the default style associated with elements of this type by the table view.

Returns:
The value of the defaultStyle property.
See Also:
getStyle(), getModelStyle(), getModelDefaultStyle()

getModelDefaultStyle

public abstract com.sas.collection.StaticPropertyBagInterface getModelDefaultStyle()
Returns the default style associated with elements of this type by the table view's model.

Returns:
The value of the modelDefaultStyle property.
See Also:
getStyle(), getModelStyle(), getDefaultStyle()

getEffectiveStylePropertyValue

public java.lang.Object getEffectiveStylePropertyValue(java.lang.String propertyID,
                                                       java.lang.Object defaultValue)
Returns the effective value of the specified style property. The effective value is the value from the prioritized set of styles associated with this element that is "in effect", i.e. overrides the others. The default set of styles in priority order are the styles returned by getStyle(), getModelStyle(), getTypeStyles(), getDefaultStyle(), and getModelDefaultStyle(). The latter two are called by onGetEffectiveStylePropertyValue, so subclasses that want to check additional styles before going to the defaults should override that method.

Parameters:
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.
Returns:
The effective property value.
See Also:
onGetEffectiveStylePropertyValue(java.lang.String, java.lang.Object)

getEffectiveStylePropertyBag

public 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. The effective value is the value from the prioritized set of styles associated with this element that is "in effect", i.e. overrides the others. The default set of styles in priority order are the styles returned by getStyle(), getModelStyle(), getTypeStyles(), getDefaultStyle(), and getModelDefaultStyle(). The latter two are called by onGetEffectiveStylePropertyBag, so subclasses that want to check additional styles before going to the defaults should override that method.

When a property represents a set of subproperties, like a PropertyBag does, it is the effective value of those subproperties that is interesting, not the effective value of the property itself. For example, the default FontStyle associated with a table might define a Helvetica 10pt REGULAR ROMAN font, while the FontStyle associated with an individual column might override REGULAR with BOLD, and the FontStyle associated with a cell in that column might override ROMAN with ITALIC.

Parameters:
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.
See Also:
onGetEffectiveStylePropertyBag(java.lang.String, com.sas.collection.PropertyBagInterface), getEffectiveStylePropertyValue(java.lang.String, java.lang.Object), Cell.getEffectiveFont()

getModelTypes

public abstract java.lang.String[] getModelTypes()
Returns the types associated with this element by the table view's model. For elements that have more than one type, the types will be ordered (if applicable) in the array from most important to least important.

Returns:
A string array of the element's types; will never be null.
See Also:
StaticTableTypeInterface, getModelTypeStyles()

getModelTypeStyles

public abstract com.sas.collection.StaticPropertyBagInterface[] getModelTypeStyles()
Returns the styles associated with the element's model types.

Returns:
An array of styles ordered such that there is a one-to-one correspondence between its elements and the elements of the array returned by getModelTypes. Neither the array nor any of its elements will ever be null.
See Also:
StaticTableTypeStylesInterface, getModelTypes()

isCurrent

public final boolean isCurrent()
Returns true if the element is the table view's currentElement, and false otherwise.

Returns:
The value of the current property.

isTransient

public boolean isTransient()
Returns true if the element is transient and false otherwise. A transient element has no data associated with it that can't be derived from another source. For example, having a model supplied style (see getModelStyle()) does not make an element non-transient because the style can be requeried from the model. While a style assigned via setStyle does make the element non-transient since the element is responsible for maintaining that relationship.

Returns:
The value of the transient property.

refresh

public void refresh(int flags)
Refreshes the element to its state as maintained by the table view's model. What gets refreshed -- data and/or style information -- is controlled by flags. Includes a call to repaint().

Specified by:
refresh in interface TableElementInterface
Parameters:
flags - Bitmask of REFRESH_DATA and/or REFRESH_STYLE.

setObsolete

public abstract void setObsolete()
Indicates that the element should be considered obsolete.

An obsolete element is one that has been released or orphaned by its table view. The table view maintains a cache of elements. When the cache is full it will begin removing the least recently used transient elements from that cache. Those elements will be marked as obsolete. Once an element has been marked obsolete it will always be obsolete and will never again be referenced by its table view.

If the logical entity that the element represents, e.g. row five, is later referenced by the table view, the table view will create a new element instance to represent it. The obsolete instance will be logically and functionally equivalent to this new one (comparing the two with the equals method will yield true) except that its implementation must now delegate all variable access to the new instance.

See Also:
isTransient(), equals(java.lang.Object)

getThis

protected abstract TableElement getThis()
Returns the TableElement instance to delegate all variable access to. Usually the instance will be this, but if this has been obsoleted then a different, but equivalent, instance will be returned.

Returns:
The proxy for accessing our variables.
See Also:
setObsolete()

onGetModelStyle

protected abstract com.sas.collection.StaticPropertyBagInterface onGetModelStyle()
                                                                          throws com.sas.table.TableException
TableElement framework method for querying the table view's model for any style properties associated with the element.

Returns:
Model supplied style properties for element.
Throws:
TableException - Propagated from call to model.
See Also:
getModelStyle()

onGetEffectiveStylePropertyValue

protected java.lang.Object onGetEffectiveStylePropertyValue(java.lang.String propertyID,
                                                            java.lang.Object defaultValue)
TableElement framework method for determining the effective value of a style property. Overrides should call super if and only if value not found at their level.

Parameters:
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.
Returns:
The effective property value.
See Also:
getEffectiveStylePropertyValue(java.lang.String, java.lang.Object)

onGetEffectiveStylePropertyBag

protected void onGetEffectiveStylePropertyBag(java.lang.String propertyID,
                                              com.sas.collection.PropertyBagInterface bag)
TableElement framework method for determining the effective value of a style property of type StaticPropertyBagInterface. Overrides should always call super (usually last).

Parameters:
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.
See Also:
getEffectiveStylePropertyBag(java.lang.String, com.sas.collection.PropertyBagInterface, boolean)



Copyright © 2009 SAS Institute Inc. All Rights Reserved.