com.sas.table
Class CellVector

com.sas.table.CellVector
All Implemented Interfaces:
TableElementInterface, com.sas.util.Countable
Direct Known Subclasses:
Column, Row

public abstract class CellVector
implements com.sas.util.Countable

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

See Also:
TableView, Column, Row, CellVectorStyle

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 CellVector(TableView table, int index)
          Constructor.
 
Method Summary
 int computePreferredSize(java.awt.Graphics g)
          Returns the preferred amount of space needed to display the cell vector in the given graphics context.
abstract  boolean contains(DataCell cell)
          Test for the presence of a cell in the cell vector.
 boolean contains(int coord)
          Checks whether the bounds of this vector contains the specified coordinate.
 boolean contains(java.lang.Object obj)
          Test for the presence of an object in the cell vector.
 int count()
          Returns the number of cells in the vector, not including the label.
abstract  int count(int maxCount)
          Returns the number of cells in the vector, not including the label, up to a specified count if the real number is not readily determined.
abstract  boolean equals(CellVector other)
          Compares this and a given cell vector for equality.
 boolean equals(TableElement obj)
          Compares this and a given table element for equality.
abstract  DataCell getCell(int index)
          Returns the cell at a given index.
 int getCellsToSizeCount()
          Helper method for determing the number of cells to consider when measuring the cell vector.
 int getDisplayedSize()
          Returns the size of the area allotted to the CellVector in the table's current display.
abstract  int getIndex()
          Returns the vector's one-based position in the table view's model.
abstract  LabelCell getLabel()
          Returns the label associated with the cell vector.
abstract  int getMaxPosition()
          Returns the right edge of the table if this is a Column and the bottom edge of the table if this is a Row.
 java.lang.String[] getModelTypes()
          Returns an empty array since support for querying a model for its column or row types is not yet available.
 com.sas.collection.StaticPropertyBagInterface[] getModelTypeStyles()
          Returns an empty array since support for querying a model for its column or row type styles is not yet available.
abstract  java.lang.String getPixelUnit()
          Returns the pixel unit, "px" or "py", that getSize is in terms of.
 int getPosition()
          Returns the value of the position property.
 int getPreferredSize()
          Returns the preferred amount of space needed to display the cell vector.
 int getSize()
          Returns the value of the size property.
protected  TableElement getThis()
          Returns the TableElement instance to delegate all variable access to.
protected abstract  CellVector getThisCellVector()
          Returns the CellVector instance to delegate all variable access to.
 int hashCode()
          Returns a hash code value for the cell vector.
 boolean isDisplayed()
          Indicates whether the cell vector is currently displayed by the table view.
abstract  boolean isHeld()
          Indicates whether the cell vector is "held".
 boolean isModified()
          Indicates whether the cell vector's data has been modified.
 boolean isPartiallyDisplayed()
          Indicates whether the cell vector is currently displayed by the table view, but also clipped.
 boolean isResizable()
          Indicates whether the cell vector can be resized interactively.
 boolean isResized()
          Indicates whether the cell vector has been resized.
 boolean isTransient()
          Indicates whether the cell vector is transient.
 CellVector next()
          Returns the next cell vector if any, otherwise null.
protected abstract  int onComputePreferredSize(java.awt.Graphics g)
          Framework method called by computePreferredSize.
protected abstract  CellVector onNext()
          Framework method called by next for determining the CellVector that follows this.
protected abstract  CellVector onPrevious()
          Framework method called by previous for determining the CellVector that precedes this.
protected abstract  void onResized()
          Framework method called by setSize to notify subclasses of a change in size.
 CellVector previous()
          Returns the previous cell vector if any, otherwise null.
 void remeasure()
          Remeasures the cell vector.
static int resize(com.sas.collection.OrderedCollection cellVectors, int newSize, boolean relative)
          Resizes a given set of CellVectors to conform to a given size.
static int resize(com.sas.collection.OrderedCollection cellVectors, int newSize, boolean relative, boolean preserve)
          Resizes a given set of CellVectors to conform to a given size.
 void setPreferredSize(int newValue)
          Specifies the preferred amount of space needed to display the cell vector.
 void setSize(int newValue)
          Sets the value of the size property.
 
Methods inherited from class com.sas.table.TableElement
equals, getDefaultStyle, getEffectiveStylePropertyBag, getEffectiveStylePropertyValue, getModelDefaultStyle, getModelStyle, getStyle, getTableView, isCurrent, onGetEffectiveStylePropertyBag, onGetEffectiveStylePropertyValue, onGetModelStyle, refresh, setObsolete, setStyle
 
Methods inherited from interface com.sas.table.TableElementInterface
isSelected, repaint
 

Constructor Detail

CellVector

protected CellVector(TableView table,
                     int index)
Constructor.

Parameters:
table - The TableView instance that contains this cell vector.
index - The one-based position of the cell vector in the table view's model.
Method Detail

contains

public boolean contains(int coord)
Checks whether the bounds of this vector contains the specified coordinate.

Parameters:
coord - The coordinate to test.
Returns:
true if the coordinate is within the bounds; false otherwise.

contains

public final boolean contains(java.lang.Object obj)
Test for the presence of an object in the cell vector.

Parameters:
obj - The object to check for.
Throws:
java.lang.ClassCastException - Thrown if the object is not a DataCell.

contains

public abstract boolean contains(DataCell cell)
Test for the presence of a cell in the cell vector.

Parameters:
cell - The cell to check for.

count

public final int count()
Returns the number of cells in the vector, not including the label. This number is equivalent to the number of columns in the table view's model in the case of a Row, and the number of rows in the table view's model in the case of a Column.

Note that some models do not readily know how many columns or rows they have, but calling this method will force them to compute it which could be expensive. Therefore WARNING, be wary of calling this method without knowing the nature of your model. In such a case, consider using count(int maxCount) with a non-zero maxCount as this method simply does count(0).

Specified by:
count in interface com.sas.util.Countable
Returns:
The number of cells in the vector.
See Also:
StaticTableInterface.countColumns(int), StaticTableInterface.countRows(int)

count

public abstract int count(int maxCount)
Returns the number of cells in the vector, not including the label, up to a specified count if the real number is not readily determined.

Parameters:
maxCount - Defines a limiting factor for cases where the number of cells is not readily determined. Such a case is a function of the table view's model. maxCount allows you to limit how much computation is done. If the count is already known to be larger than maxCount without doing any computation, then the larger number is returned. Specifying a maxCount of zero will force the computation of the total count no matter the cost.
Returns:
The number of cells in the vector.
See Also:
StaticTableInterface.countColumns(int), StaticTableInterface.countRows(int)

equals

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

Specified by:
equals in class TableElement
Returns:
true if obj is a CellVector and equals((CellVector)obj) returns true; false otherwise.

equals

public abstract boolean equals(CellVector other)
Compares this and a given cell vector for equality.

Returns:
true if this cell vector is equivalent to other; false otherwise.

getCell

public abstract DataCell getCell(int index)
Returns the cell at a given index.

Parameters:
index - The position of the cell using one-based indexing.
Returns:
The cell associated with index.
Throws:
java.lang.IndexOutOfBoundsException - If index is not in the range [1, count()].

getCellsToSizeCount

public int getCellsToSizeCount()
Helper method for determing the number of cells to consider when measuring the cell vector.

Returns:
The effective value of CellVectorStyle.CELLS_TO_SIZE_COUNT.

getDisplayedSize

public int getDisplayedSize()
Returns the size of the area allotted to the CellVector in the table's current display.

Returns:
The value of the displayedSize property in pixels.
See Also:
getSize()

getIndex

public abstract int getIndex()
Returns the vector's one-based position in the table view's model.

Returns:
The value of the index property.

getLabel

public abstract LabelCell getLabel()
Returns the label associated with the cell vector.

Returns:
The value of the label property; will never be null.

getMaxPosition

public abstract int getMaxPosition()
Returns the right edge of the table if this is a Column and the bottom edge of the table if this is a Row.

Returns:
The value of the maxPosition property in pixels.

getModelTypes

public java.lang.String[] getModelTypes()
Returns an empty array since support for querying a model for its column or row types is not yet available.

Specified by:
getModelTypes in class TableElement
Returns:
A string array of the element's types; will never be null.
See Also:
TableElement.getModelTypes()

getModelTypeStyles

public com.sas.collection.StaticPropertyBagInterface[] getModelTypeStyles()
Returns an empty array since support for querying a model for its column or row type styles is not yet available.

Specified by:
getModelTypeStyles in class TableElement
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:
TableElement.getModelTypeStyles()

getPixelUnit

public abstract java.lang.String getPixelUnit()
Returns the pixel unit, "px" or "py", that getSize is in terms of. For Columns size is a width, so x-pixels are used. For Rows size is a height, so y-pixels are used.

Returns:
"px" or "py".

getPosition

public int getPosition()
Returns the value of the position property. position is undefined when displayed is false.

Returns:
The value of the position property in pixels.

getPreferredSize

public int getPreferredSize()
Returns the preferred amount of space needed to display the cell vector. Will return zero until setPreferredSize has been called with a non-zero value.

For Columns, the preferred size will represent a width or horizontal distance.

For Rows, it will represent a height or vertical distance.

Returns:
The cell vector's preferred size in pixels.
See Also:
computePreferredSize(java.awt.Graphics), setPreferredSize(int), getSize()

setPreferredSize

public void setPreferredSize(int newValue)
Specifies the preferred amount of space needed to display the cell vector. Usually will be called with the result from computePreferredSize. The new size, unless it's zero, is constrained by any specified style.MIN_SIZE and/or style.MAX_SIZE.

For Columns, the preferred size will represent a width or horizontal distance.

For Rows, it will represent a height or vertical distance.

Parameters:
newValue - The newValue to assign the preferredSize property.
See Also:
computePreferredSize(java.awt.Graphics), getPreferredSize(), setSize(int)

computePreferredSize

public int computePreferredSize(java.awt.Graphics g)
Returns the preferred amount of space needed to display the cell vector in the given graphics context.

For Columns, the preferred size will represent a width or horizontal distance.

For Rows, it will represent a height or vertical distance.

Parameters:
g - The graphics context to measure the cell vector in.
Returns:
The cell vector's preferred size in pixels.

getSize

public int getSize()
Returns the value of the size property. Will return getPreferredSize() until setSize has been called with a non-zero value.

Returns:
The value of the size property in pixels.
See Also:
setSize(int), getPreferredSize()

getThis

protected final 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.

Specified by:
getThis in class TableElement
Returns:
The proxy for accessing our variables.
See Also:
TableElement.setObsolete()

getThisCellVector

protected abstract CellVector getThisCellVector()
Returns the CellVector 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:
TableElement.setObsolete()

hashCode

public int hashCode()
Returns a hash code value for the cell vector.

Overrides:
hashCode in class java.lang.Object
Returns:
getIndex().
See Also:
equals(com.sas.table.TableElement)

isDisplayed

public boolean isDisplayed()
Indicates whether the cell vector is currently displayed by the table view. In other words, is it scrolled into view.

Specified by:
isDisplayed in interface TableElementInterface
Returns:
true if the cell vector is displayed, and false otherwise.
See Also:
isPartiallyDisplayed()

isHeld

public abstract boolean isHeld()
Indicates whether the cell vector is "held". A held cell vector is one that has been made non-scrollable and is thus always, space permitting, displayed; i.e. it is never scrolled out of view.

Returns:
true if the cell vector is held and false otherwise.
See Also:
TableView.getHeldColumns(), TableView.getHeldRows()

isModified

public boolean isModified()
Indicates whether the cell vector's data has been modified.

Specified by:
isModified in interface TableElementInterface
Returns:
true if the label or at least one of the data cells are modified, and false otherwise.

isPartiallyDisplayed

public boolean isPartiallyDisplayed()
Indicates whether the cell vector is currently displayed by the table view, but also clipped. In other words, is it scrolled into view but can't be fully seen.

Returns:
true if the cell vector is displayed but clipped, and false otherwise.
See Also:
isDisplayed()

isResizable

public boolean isResizable()
Indicates whether the cell vector can be resized interactively.

Returns:
true if the cell vector can be resized interactively, and false otherwise.
See Also:
isResized()

isResized

public boolean isResized()
Indicates whether the cell vector has been resized. A cell vector is considered resized if setSize() has been called with a non-zero value.

Returns:
true if the cell vector has been resized, and false otherwise.
See Also:
isResizable()

isTransient

public boolean isTransient()
Indicates whether the cell vector is transient. See TableElement.isTransient() for a definition of "transient".

Augments super to treat cell vectors that have been resized as intransient.

Overrides:
isTransient in class TableElement
Returns:
true if the cell vector is transient, and false otherwise.
See Also:
TableElement.isTransient()

next

public CellVector next()
Returns the next cell vector if any, otherwise null.

Returns:
The CellVector that follows this one or null.
See Also:
previous()

onComputePreferredSize

protected abstract int onComputePreferredSize(java.awt.Graphics g)
Framework method called by computePreferredSize.

Parameters:
g - The graphics context to measure the cell vector in.
Returns:
The cell vector's preferred size in pixels.
See Also:
computePreferredSize(java.awt.Graphics)

onNext

protected abstract CellVector onNext()
Framework method called by next for determining the CellVector that follows this.

Returns:
The CellVector that follows this one or null.
See Also:
next()

onPrevious

protected abstract CellVector onPrevious()
Framework method called by previous for determining the CellVector that precedes this.

Returns:
The CellVector that precedes this one or null.
See Also:
previous()

onResized

protected abstract void onResized()
Framework method called by setSize to notify subclasses of a change in size.

See Also:
setSize(int)

previous

public CellVector previous()
Returns the previous cell vector if any, otherwise null.

Returns:
The CellVector that precedes this one or null.
See Also:
next()

remeasure

public void remeasure()
Remeasures the cell vector. The vector's size is recalculated and the table's display is updated appropriately.


resize

public static int resize(com.sas.collection.OrderedCollection cellVectors,
                         int newSize,
                         boolean relative)
Resizes a given set of CellVectors to conform to a given size.

See Also:
resize(OrderedCollection, int, boolean, boolean)

resize

public static int resize(com.sas.collection.OrderedCollection cellVectors,
                         int newSize,
                         boolean relative,
                         boolean preserve)
Resizes a given set of CellVectors to conform to a given size. Each CellVector in the set is resized proportionally based on the ratio of its individual size to the cumulative size of the set.

Parameters:
cellVectors - The set of CellVectors to resize.
newSize - If relative is false, specifies the new cumulative size in pixels. If relative is true, specifies a size offset (positive or negative) in pixels, i.e. the amount to change the current cumulative size by.
relative - See newSize.
preserve - If true, the size of any cellVectors that have been resized will be preserved.
Returns:
The resulting cumulative size of the CellVectors in pixels. May be less than or greater than newSize depending on the value of preserve.

setSize

public final void setSize(int newValue)
Sets the value of the size property. The new size, unless it's zero, is constrained by any specified style.MIN_SIZE and/or style.MAX_SIZE. A size of zero causes getSize() to return getPreferredSize().

Parameters:
newValue - The new value to assign the size property.
See Also:
getSize()



Copyright © 2009 SAS Institute Inc. All Rights Reserved.