com.sas.swing.visuals.olaptableview
Class OLAPColumnHeader

com.sas.swing.visuals.olaptableview.OLAPColumnHeader
All Implemented Interfaces:
HoldInterface, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, java.util.EventListener, javax.accessibility.Accessible, javax.swing.event.TableColumnModelListener, javax.swing.SwingConstants

public class OLAPColumnHeader

See Also:
Serialized Form

Field Summary
protected  AxisInterface axis
           
protected  java.util.List columnLevelHeights
           
protected  javax.swing.SizeSequence levelHeights
           
static java.lang.String RB_KEY
           
 
Fields inherited from class com.sas.swing.visuals.tableview.ColumnHeader
cellsToSizeCount, height, heightSet, holdingEnabled, lastColumnSized, printing
 
Constructor Summary
OLAPColumnHeader()
          Constructs a OLAPColumnHeader with a default TableColumnModel.
OLAPColumnHeader(javax.swing.table.TableColumnModel model)
          Constructs a OLAPColumnHeader which is initialized with model as the Column model.
 
Method Summary
 int[] calculatePreferredWidthForColumns(int[] columns)
          Calculates the preferred widths for the given columns based on it's label and data.
 void columnAdded(javax.swing.event.TableColumnModelEvent e)
          Invoked when a column is added to the table column model.
protected  javax.swing.table.TableColumnModel createDefaultColumnModel()
          Returns the default column model object which is a javax.swing.table.DefaultTableColumnModel.
protected  javax.swing.table.TableCellRenderer createDefaultRenderer()
          Returns a default renderer to be used when no header renderer is defined by a TableColumn.
 AxisInterface getAxis()
          Returns the instance of the AxisInterface that is being used by the header.
 java.awt.Rectangle getHeaderRect(int column, int level)
          Returns the rectangle containing the header tile at column, level.
 java.awt.Component getHeaderRendererComponent(TupleElementInterface element, int level, int column)
          Returns the component that is used to renderer the given TupleElementInterface.
 int getLevelCount(int column)
          Returns the numbers of levels associated with the given column.
 int getLevelHeight(int level)
          Returns the actual height in pixels of the given level.
protected  javax.swing.SizeSequence getLevelHeights()
           
 int getMaxLevelCount()
          Returns the maximum number of levels currently being shown on the header.
 int getPreferredLevelHeight(int level)
          Returns the preferred height in pixels of the given level.
 java.lang.String getToolTipText(java.awt.event.MouseEvent event)
          Allows the renderer's tips to be used if there is text set.
 TupleElementInterface getTupleElementAt(int columnIndex, int levelIndex)
          Returns the instance of the TupleElementInterface at columnIndex, level.
 TupleElementInterface[] getTupleElementsForCoordinate(int axisCoordinate)
          Returns the set of TupleElementInterface associated with the given axis coordinate.
 java.lang.String getUIClassID()
          Returns the suffix used to construct the name of the look and feel (L&F) class used to render this component.
protected  void initializeLocalVars()
          Initializes the local variables and properties with default values.
 int levelAtPoint(java.awt.Point point)
          Returns the level at the given point.
 void setAxis(AxisInterface newAxis)
          Sets the new AxisInterface instance for the OLAPRowHeader.
 void setHoldingEnabled(boolean b)
          Holding is always not allowed.
 void setLevelHeight(int level, int levelHeight)
          Sets the height for the level to levelHeight, revalidates, and repaints.
 void setReorderingAllowed(boolean b)
          Reordering is always not allowed.
 void updateUI()
          Notification from the
Methods inherited from class com.sas.swing.visuals.tableview.ColumnHeader
calculatePreferredWidthForColumn, columnAtPoint, columnAtPoint, getCellsToSizeCount, getHeaderRect, getHeight, getHeldIndices, getHeldIndices, getHold, getLeadingHeldWidth, getPreferredHeaderWidthForColumn, getTrailingHeldWidth, getViewPosition, hold, hold, isHeightSet, isHeld, isHeld, isHoldingAllowed, isHoldingEnabled, paintComponent, prepareRenderer, printComponent, release, releaseAll, setCellsToSizeCount, setColumnModel, setHeight, setTable, sizeColumnsToFit, sizeColumnToFit
 

Field Detail

RB_KEY

public static final java.lang.String RB_KEY
See Also:
Constant Field Values

axis

protected AxisInterface axis

levelHeights

protected javax.swing.SizeSequence levelHeights

columnLevelHeights

protected java.util.List columnLevelHeights
Constructor Detail

OLAPColumnHeader

public OLAPColumnHeader()
Constructs a OLAPColumnHeader with a default TableColumnModel.

See Also:
createDefaultColumnModel()

OLAPColumnHeader

public OLAPColumnHeader(javax.swing.table.TableColumnModel model)
Constructs a OLAPColumnHeader which is initialized with model as the Column model. If model is null this method will initialize the table header with a default TableColumnModel.

Parameters:
model - the Column model for the table
See Also:
createDefaultColumnModel()
Method Detail

createDefaultColumnModel

protected javax.swing.table.TableColumnModel createDefaultColumnModel()
Returns the default column model object which is a javax.swing.table.DefaultTableColumnModel. A subclass can override this method to return a different column model object

Overrides:
createDefaultColumnModel in class javax.swing.table.JTableHeader
Returns:
the default column model object

createDefaultRenderer

protected javax.swing.table.TableCellRenderer createDefaultRenderer()
Returns a default renderer to be used when no header renderer is defined by a TableColumn.

Overrides:
createDefaultRenderer in class ColumnHeader
Parameters:
default - renderer to be used when there is no header renderer

levelAtPoint

public int levelAtPoint(java.awt.Point point)
Returns the level at the given point. The level return will be in the range of 0 to getMaxLevelCount() - 1. The level indicated by 0 is the topmost level, while a level value equal to getMaxLevelCount() - 1 is referring to the level that is bottommost (the level closest to the cell values).

Parameters:
point - The point whose level is queried for
Returns:
the 0 based level index for the given point, or -1 if the point is not over any level

getHeaderRect

public java.awt.Rectangle getHeaderRect(int column,
                                        int level)
Returns the rectangle containing the header tile at column, level. When the column parameter is out of bounds this method uses the same conventions as the OLAPTableView method getCellRect. The level should be in the range of 0 to getMaxLevelCount() - 1. The level indicated by 0 is the topmost level, while a level value equal to getMaxLevelCount() - 1 is referring to the level that is botommost (the level closest to the cell values).

Parameters:
column - the 0 based column index
level - the 0 based level index
Returns:
the rectangle containing the header tile at column, level
See Also:
TableView.getCellRect(int, int, boolean)

initializeLocalVars

protected void initializeLocalVars()
Initializes the local variables and properties with default values. Used by the constructor methods.

Overrides:
initializeLocalVars in class ColumnHeader

setReorderingAllowed

public void setReorderingAllowed(boolean b)
Reordering is always not allowed. Ignores the param, always set to false.

Overrides:
setReorderingAllowed in class javax.swing.table.JTableHeader
Parameters:
b - ignore, always set to false

setHoldingEnabled

public void setHoldingEnabled(boolean b)
Holding is always not allowed. Ignores the param, always set to false.

Specified by:
setHoldingEnabled in interface HoldInterface
Overrides:
setHoldingEnabled in class ColumnHeader
Parameters:
b - ignore, always set to false
See Also:
ColumnHeader.isHoldingEnabled()

updateUI

public void updateUI()
Notification from the UIManager that the look and feel (L&F) has changed. Replaces the current UI object with the latest version from the UIManager.

Overrides:
updateUI in class ColumnHeader
See Also:
JComponent.updateUI()

getUIClassID

public java.lang.String getUIClassID()
Returns the suffix used to construct the name of the look and feel (L&F) class used to render this component.

Overrides:
getUIClassID in class ColumnHeader
Returns:
the string "OLAPColumnHeaderUI"
See Also:
JComponent.getUIClassID(), UIDefaults.getUI(javax.swing.JComponent)

setAxis

public void setAxis(AxisInterface newAxis)
Sets the new AxisInterface instance for the OLAPRowHeader. The axis interface is used to retrieve the tuples which contain all the information needed for the header. This method is typically called by the OLAPTableView when a new model is set on it or is updated.

Parameters:
newAxis - the new AxisInterface instance
See Also:
getAxis()

getAxis

public AxisInterface getAxis()
Returns the instance of the AxisInterface that is being used by the header.

Returns:
an instance of an AxisInterface that maps to the columns axis in the OLAPDataSetInterface set on the OLAPTabelView
See Also:
setAxis(AxisInterface)

getTupleElementsForCoordinate

public TupleElementInterface[] getTupleElementsForCoordinate(int axisCoordinate)
Returns the set of TupleElementInterface associated with the given axis coordinate.

Parameters:
axisCoordinate - A zero-based integer that identifies a point along the axis.
Returns:
An array of tuple elements ordered from least to most specific. For example, [North America, USA, North Carolina, Cary]. The returned array will never be null, but on error it will have a length of zero.

getMaxLevelCount

public int getMaxLevelCount()
Returns the maximum number of levels currently being shown on the header.

Returns:
the maximum number of levels associated with the AxisInterface

getLevelCount

public int getLevelCount(int column)
Returns the numbers of levels associated with the given column. The value returned from this method with be less then or equal to getMaxLevelCount(). This will return the true level count for the column, that is, if the column has a TupleElement that spans more then one level, the level count for this column will be less then that of a call to getMaxLevelCount(), otherwise it will be equal.

Parameters:
column - a 0 based column index
Returns:
the number of levels associated with the given column

getLevelHeights

protected javax.swing.SizeSequence getLevelHeights()

getLevelHeight

public int getLevelHeight(int level)
Returns the actual height in pixels of the given level. The level should be in the range of 0 to getMaxLevelCount() - 1. The level indicated by 0 is the topmost level, while a level value equal to getMaxLevelCount() - 1 is referring to the level that is bottommost (the level closest to the cell values).

Parameters:
level - the 0 based level index
Returns:
the actual height in pixels that the given level is sized to

getPreferredLevelHeight

public int getPreferredLevelHeight(int level)
Returns the preferred height in pixels of the given level. The level should be in the range of 0 to getMaxLevelCount() - 1. The level indicated by 0 is the topmost level, while a level value equal to getMaxLevelCount() - 1 is referring to the level that is bottommost (the level closest to the cell values).

Parameters:
level - the 0 based level index
Returns:
the preferred height in pixels of the given level

getHeaderRendererComponent

public java.awt.Component getHeaderRendererComponent(TupleElementInterface element,
                                                     int level,
                                                     int column)
Returns the component that is used to renderer the given TupleElementInterface.

Parameters:
element - the tupleElement being renderered
level - the level index of the TupleElementInterface
column - the column index of the TupleElementInterface
Returns:
the component that is renderering the given TupleElementInterface

setLevelHeight

public void setLevelHeight(int level,
                           int levelHeight)
Sets the height for the level to levelHeight, revalidates, and repaints.

Parameters:
level - the level whose height is being changed
levelHeight - the new level height, in pixels
Throws:
java.lang.IllegalArgumentException - if levelHeight is less then 0

getTupleElementAt

public TupleElementInterface getTupleElementAt(int columnIndex,
                                               int levelIndex)
Returns the instance of the TupleElementInterface at columnIndex, level. The levelIndex should be in the range of 0 to getMaxLevelCount() - 1. If a TupleElementInterface spans multiple levels, the same TupleElementInterface will be returned for each level.

Parameters:
columnIndex - the 0 based column index
levelIndex - level the 0 based level index
Returns:
an instance of TupleElementInterface or null if the columnIndex, levelIndex is invalid

getToolTipText

public java.lang.String getToolTipText(java.awt.event.MouseEvent event)
Allows the renderer's tips to be used if there is text set.

Overrides:
getToolTipText in class javax.swing.table.JTableHeader
Parameters:
event - the location of the event identifies the proper renderer and, therefore, the proper tip
Returns:
the tool tip for this component

calculatePreferredWidthForColumns

public int[] calculatePreferredWidthForColumns(int[] columns)
Calculates the preferred widths for the given columns based on it's label and data. The method uses the value from getCellToSizeCount() to determine the number of cells to measure to determine the columns width. This is compared with the preferred width of each column label and the larger size is returned for each column. The widths may not be the best fit as the value returned from getCellToSizeCount() may be too small so that too few of cells were measured to determine each column width.

Overrides:
calculatePreferredWidthForColumns in class ColumnHeader
Parameters:
columns - an array of integers of the columns requesting their size calculated
Returns:
an array on integers that indicate the size for each column, or an empty array if no columns were requested or allowed to be resized
See Also:
ColumnHeader.getCellsToSizeCount(), ColumnHeader.setCellsToSizeCount(int)

columnAdded

public void columnAdded(javax.swing.event.TableColumnModelEvent e)
Invoked when a column is added to the table column model.

Application code will not use these methods explicitly, they are used internally by OLAPTableView.

Specified by:
columnAdded in interface javax.swing.event.TableColumnModelListener
Overrides:
columnAdded in class javax.swing.table.JTableHeader
Parameters:
e - the event received
See Also:
TableColumnModelListener



Copyright © 2009 SAS Institute Inc. All Rights Reserved.