com.sas.swing.visuals.olaptableview
Class OLAPRowHeader

com.sas.swing.visuals.olaptableview.OLAPRowHeader
All Implemented Interfaces:
HoldInterface, TableRowModelListener, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, java.util.EventListener, javax.swing.SwingConstants

public class OLAPRowHeader

See Also:
Serialized Form

Field Summary
protected  AxisInterface axis
           
protected  javax.swing.SizeSequence levelWidths
           
protected  java.util.List rowLevelWidths
           
 
Fields inherited from class com.sas.swing.visuals.tableview.RowHeader
cellsToSizeCount, draggedDistance, draggedRow, heldRows, heldRowsBottom, heldRowsTop, holdingEnabled, numRowsSized, printing, RB_KEY, reorderingAllowed, resizingAllowed, resizingRow, rowModel, rowsSized, table, width, widthSet
 
Constructor Summary
OLAPRowHeader()
          Constructs a default OLAPRowHeader
OLAPRowHeader(TableRowModel model)
          Constructs a OLAPRowHeader which is initialized with model as the row model.
 
Method Summary
 int calculatePreferredHeightForRow(int row)
          Calculates the preferred height for the given row based on it's label and data.
protected  javax.swing.table.TableCellRenderer createDefaultRenderer()
          Returns a default renderer to be used.
 AxisInterface getAxis()
          Returns the instance of the AxisInterface that is being used by the header.
 java.awt.Rectangle getHeaderRect(int row, int level)
          Returns the rectangle containing the header tile at row, level.
 java.awt.Component getHeaderRendererComponent(TupleElementInterface element, int level, int row)
          Returns the component that is used to renderer the given TupleElementInterface.
 int getLevelCount(int rowNumber)
          Returns the numbers of levels associated with the given rowNumber.
 int getLevelWidth(int level)
          Returns the actual width in pixels of the given level.
protected  javax.swing.SizeSequence getLevelWidths()
           
 int getMaxLevelCount()
          Returns the maximum number of levels currently being shown on the header.
 int getPreferredLevelWidth(int level)
          Returns the preferred width 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 rowIndex, int levelIndex)
          Returns the instance of the TupleElementInterface at row, 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.
 java.lang.Object getValueAt(int rowIndex)
          Returns the row label for the TupleElementInterface associated with the given row's cells.
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 setLevelWidth(int level, int levelWidth)
          Sets the width for the level to levelWidth, 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.RowHeader
createDefaultRowModel, getBottomHeldHeight, getCellsToSizeCount, getDefaultRenderer, getDraggedDistance, getDraggedRow, getHeaderRect, getHeldIndices, getHeldIndices, getReorderingAllowed, getResizingAllowed, getResizingRow, getRowModel, getTable, getTopHeldHeight, getUI, getViewPosition, getWidth, hold, hold, isHeld, isHeld, isHoldingAllowed, isHoldingEnabled, isWidthSet, paintComponent, prepareRenderer, printComponent, release, releaseAll, resizeAndRepaint, rowAtPoint, rowAtPoint, rowMarginChanged, rowMoved, rowSelectionChanged, setCellsToSizeCount, setDefaultRenderer, setDraggedDistance, setDraggedRow, setResizingAllowed, setResizingRow, setRowModel, setTable, setUI, setWidth, sizeRowsToFit, sizeRowsToFit, sizeRowToFit, tableRowsDeleted, tableRowsInserted
 

Field Detail

axis

protected AxisInterface axis

levelWidths

protected javax.swing.SizeSequence levelWidths

rowLevelWidths

protected java.util.List rowLevelWidths
Constructor Detail

OLAPRowHeader

public OLAPRowHeader()
Constructs a default OLAPRowHeader


OLAPRowHeader

public OLAPRowHeader(TableRowModel model)
Constructs a OLAPRowHeader which is initialized with model as the row model. If model is null this method will initialize the row header with a default TableRowModel.

Parameters:
model - the row model for the table
See Also:
RowHeader.createDefaultRowModel()
Method Detail

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 leftmost level, while a level value equal to getMaxLevelCount() - 1 is referring to the level that is rightmost (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 row,
                                        int level)
Returns the rectangle containing the header tile at row, level. When the row 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 leftmost level, while a level value equal to getMaxLevelCount() - 1 is referring to the level that is rightmost (the level closest to the cell values).

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

initializeLocalVars

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

Overrides:
initializeLocalVars in class RowHeader

setReorderingAllowed

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

Overrides:
setReorderingAllowed in class RowHeader
Parameters:
b - ignore, always set to false
See Also:
RowHeader.getReorderingAllowed()

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 RowHeader
Parameters:
b - ignore, always set to false
See Also:
RowHeader.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 RowHeader
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 RowHeader
Returns:
the string "OLAPRowHeaderUI"
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 rows axis in the OLAPDataSetInterface set on the OLAPTabelView
See Also:
setAxis(AxisInterface)

getValueAt

public java.lang.Object getValueAt(int rowIndex)
Returns the row label for the TupleElementInterface associated with the given row's cells.

Overrides:
getValueAt in class RowHeader
Parameters:
rowIndex - the 0 based row index
Returns:
an Object which is used as the label for the given row

getTupleElementAt

public TupleElementInterface getTupleElementAt(int rowIndex,
                                               int levelIndex)
Returns the instance of the TupleElementInterface at row, 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:
rowIndex - the 0 based row index
levelIndex - level the 0 based level index
Returns:
an instance of TupleElementInterface or null if the rowIndex, 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 RowHeader
Parameters:
event - the location of the event identifies the proper renderer and, therefore, the proper tip
Returns:
the tool tip for this component

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 rowNumber)
Returns the numbers of levels associated with the given rowNumber. The value returned from this method with be less then or equal to getMaxLevelCount(). This will return the true level count for the row, that is, if the row has a TupleElement that spans more then one level, the level count for this row will be less then that of a call to getMaxLevelCount(), otherwise it will be equal.

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

getLevelWidths

protected javax.swing.SizeSequence getLevelWidths()

getLevelWidth

public int getLevelWidth(int level)
Returns the actual width 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 leftmost level, while a level value equal to getMaxLevelCount() - 1 is referring to the level that is rightmost (the level closest to the cell values).

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

getPreferredLevelWidth

public int getPreferredLevelWidth(int level)
Returns the preferred width 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 leftmost level, while a level value equal to getMaxLevelCount() - 1 is referring to the level that is rightmost (the level closest to the cell values).

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

getHeaderRendererComponent

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

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

createDefaultRenderer

protected javax.swing.table.TableCellRenderer createDefaultRenderer()
Returns a default renderer to be used.

Overrides:
createDefaultRenderer in class RowHeader
Parameters:
default - renderer to be used for renderering the row label cells

setLevelWidth

public void setLevelWidth(int level,
                          int levelWidth)
Sets the width for the level to levelWidth, revalidates, and repaints.

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

calculatePreferredHeightForRow

public int calculatePreferredHeightForRow(int row)
Calculates the preferred height for the given row 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 row height. This is compared with the preferred height of the row label and the larger size is returned for the row. This height 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 the row height.

Overrides:
calculatePreferredHeightForRow in class RowHeader
Parameters:
row - the viewer index of the row to measure
See Also:
RowHeader.getCellsToSizeCount(), RowHeader.setCellsToSizeCount(int), RowHeader.sizeRowsToFit(boolean, boolean), RowHeader.sizeRowsToFit(int, int, boolean), RowHeader.sizeRowToFit(int)



Copyright © 2009 SAS Institute Inc. All Rights Reserved.