|
Copyright © 2005 Scientific Applications. All Rights Reserved. | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.table.JTableHeader
com.sciapp.table.AdvancedTableHeader
com.sciapp.table.GroupTableHeader
public class GroupTableHeader
GroupTableHeader provides for a TableHeader that is able to group columns together.
Nested Class Summary |
---|
Nested classes/interfaces inherited from class javax.swing.table.JTableHeader |
---|
JTableHeader.AccessibleJTableHeader |
Nested classes/interfaces inherited from class javax.swing.JComponent |
---|
JComponent.AccessibleJComponent |
Nested classes/interfaces inherited from class java.awt.Container |
---|
Container.AccessibleAWTContainer |
Nested classes/interfaces inherited from class java.awt.Component |
---|
Component.AccessibleAWTComponent, Component.BltBufferStrategy, Component.FlipBufferStrategy |
Field Summary | |
---|---|
protected boolean |
allowGroupColumnReordering
a flag that is true if group columns can be reordered with the mouse, false otherwise |
protected boolean |
allowGroupReordering
boolean flag that controls the reordering of group columns. |
protected TableCellRendererFactory |
factory
a factory for creating new table cell renderer components. |
protected GroupTableColumnModel |
groupTableColumnModel
the group table column model |
Fields inherited from class javax.swing.table.JTableHeader |
---|
columnModel, draggedColumn, draggedDistance, reorderingAllowed, resizingAllowed, resizingColumn, table, updateTableInRealTime |
Fields inherited from class javax.swing.JComponent |
---|
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW |
Fields inherited from class java.awt.Component |
---|
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT |
Fields inherited from interface java.awt.image.ImageObserver |
---|
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH |
Constructor Summary | |
---|---|
GroupTableHeader()
Constructs a GroupTableHeader. |
|
GroupTableHeader(TableColumnModel cm)
Constructs a GroupTableHeader. |
Method Summary | |
---|---|
void |
addGroupColumn(GroupTableColumn aColumn)
Adds a group column to the header. |
protected boolean |
canMove(int fromIndex,
int toIndex)
Determines whether the column at fromIndex can be moved to toIndex . |
void |
columnAdded(TableColumnModelEvent e)
Invoked when a column is added to the table column model. |
void |
columnMoved(TableColumnModelEvent e)
Invoked when a column is repositioned. |
void |
columnRemoved(TableColumnModelEvent e)
Invoked when a column is removed from the table column model. |
void |
columnWillBeMoved(TableColumnModelEvent e)
Invoked whenever a table column is about to be moved. |
protected GroupTableColumnModel |
createDefaultGroupColumnModel()
Creates and returns the default GroupTableColumnModel. |
protected TableCellRenderer |
createDefaultGroupRenderer(int level)
Returns a default renderer at a specified level to be used when no header renderer is defined by a GroupTableColumn. |
boolean |
getAllowGroupColumnReordering()
Determines whether group columns can be reordered with the mouse. |
boolean |
getAllowGroupReordering()
Determines whether columns that are part of a group can be reordered with the mouse. |
TableCellRenderer |
getDefaultGroupRenderer(int level)
Returns the default renderer at the specified level used when no header renderer is defined by a GroupTableColumn. |
TableCellRendererFactory |
getFactory()
Returns the factory that is used to create a new table cell renderer for a group column. |
GroupTableColumn |
getGroupColumn(TableColumn column)
Returns the parent group column of the specified column. |
GroupTableColumnModel |
getGroupColumnModel()
Returns the group column model. |
int |
getGroupLevel(Component hit)
Returns the group level of the component passed as argument. |
protected GroupTableColumn[] |
getPathToRoot(GroupTableColumn aNode,
int depth)
Returns the path from the root group column to this column. |
GroupTableColumn[] |
getPathToRoot(TableColumn tc)
Returns the path from the root group column to this column. |
protected int |
getPreferredHeight(Component comp,
TableColumn tableColumn,
int level,
int column)
Returns the preferred height of the component that renders the specified column. |
boolean |
getResizingAllowed()
Returns true if the user is allowed to resize columns by dragging between their headers, false otherwise. |
TableColumn |
groupColumnAtPoint(Point p)
Returns the group column at the specified point. |
void |
groupColumnsInserted(GroupTableColumnModelEvent e)
Tells listeners that group columns were added to the model. |
void |
groupColumnsRemoved(GroupTableColumnModelEvent e)
Tells listeners that group columns were removed from the model. |
int |
groupLevelAtPoint(Point p)
Returns the group level at the specified point. |
protected boolean |
handleEvent(MouseEvent e,
Component comp)
Handles a mouse event on the header. |
boolean |
isReorderingAllowed(int index)
Returns true if the column at index is reorderable. |
boolean |
isReorderingAllowed(Point p)
Returns true if column reordering at the specified coordinate can be initiated. |
protected Component |
prepareRenderer(TableCellRenderer renderer,
Object value,
GroupTableColumn groupColumn,
int level,
int column)
Prepares the renderer by returning a suitable component. |
void |
removeGroupColumn(GroupTableColumn aColumn)
Removes a group column from the model. |
void |
setAllowGroupColumnReordering(boolean allowGroupColumnReordering)
Assigns a flag that controls whether group columns can be reordered with the mouse. |
void |
setAllowGroupReordering(boolean allowGroupReordering)
Assigns a flag that controls whether columns that are part of a group can be reordered with the mouse. |
void |
setColumnModel(TableColumnModel newModel)
Sets the column model for this table to newModel and registers
for listener notifications from the new column model. |
void |
setDefaultGroupRenderer(TableCellRenderer renderer,
int level)
Sets the default renderer at the specified level used when no header renderer is defined by a GroupTableColumn. |
void |
setFactory(TableCellRendererFactory newFactory)
Assigns a new table cell renderer factory. |
void |
setGroupColumnModel(GroupTableColumnModel groupModel)
Assigns a new group column model. |
void |
setResizingColumn(TableColumn aColumn)
Sets the header's resizingColumn to aColumn . |
void |
setTable(JTable aTable)
Sets the table associated with this header. |
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 . |
Methods inherited from class com.sciapp.table.AdvancedTableHeader |
---|
addNotify, columnWillBeAdded, columnWillBeRemoved, createDefaultColumnModel, doProcessMouseEvent, doProcessMouseMotionEvent, getComponentAtPoint, getDraggedDistance, getReorderingAllowed, getToolTipLocation, getToolTipText, initializeLocalVars, processMouseEvent, processMouseMotionEvent, setDraggedColumn |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected boolean allowGroupReordering
protected GroupTableColumnModel groupTableColumnModel
protected boolean allowGroupColumnReordering
protected transient TableCellRendererFactory factory
Constructor Detail |
---|
public GroupTableHeader()
public GroupTableHeader(TableColumnModel cm)
Method Detail |
---|
public void addGroupColumn(GroupTableColumn aColumn)
aColumn
- the group column to addprotected boolean canMove(int fromIndex, int toIndex)
fromIndex
can be moved to toIndex
.
By default, this method returns true. You will need to override it in order to
define conditions for which columns cannot be moved.
canMove
in class AdvancedTableHeader
fromIndex
- the current view index of the column being movedtoIndex
- the index the column is being moved to
public void columnAdded(TableColumnModelEvent e)
Application code will not use these methods explicitly, they
are used internally by JTable
.
columnAdded
in interface TableColumnModelListener
columnAdded
in class JTableHeader
e
- the event receivedTableColumnModelListener
public void columnMoved(TableColumnModelEvent e)
Application code will not use these methods explicitly, they
are used internally by JTable
.
columnMoved
in interface TableColumnModelListener
columnMoved
in class JTableHeader
e
- the event receivedTableColumnModelListener
public void columnRemoved(TableColumnModelEvent e)
Application code will not use these methods explicitly, they
are used internally by JTable
.
columnRemoved
in interface TableColumnModelListener
columnRemoved
in class JTableHeader
e
- the event receivedTableColumnModelListener
public void columnWillBeMoved(TableColumnModelEvent e) throws ColumnModelVetoException
columnWillBeMoved
in interface VetoableTableColumnModelListener
columnWillBeMoved
in class AdvancedTableHeader
e
- the event identifying the move.
ColumnModelVetoException
protected GroupTableColumnModel createDefaultGroupColumnModel()
protected TableCellRenderer createDefaultGroupRenderer(int level)
level
- the group table column's level
public boolean getAllowGroupColumnReordering()
public boolean getAllowGroupReordering()
public TableCellRenderer getDefaultGroupRenderer(int level)
level
- the group table column's level
public TableCellRendererFactory getFactory()
public GroupTableColumn getGroupColumn(TableColumn column)
column
- the column being part of a group column
public GroupTableColumnModel getGroupColumnModel()
public int getGroupLevel(Component hit)
getComponentAtPoint
method.
If hit targets a non-group table column, this method will return -1.
hit
- the component for which the group level is evaluated
protected GroupTableColumn[] getPathToRoot(GroupTableColumn aNode, int depth)
aNode
- the column for which the path is returneddepth
- the passed node's depth
public GroupTableColumn[] getPathToRoot(TableColumn tc)
tc
- the column for which the path is returned
protected int getPreferredHeight(Component comp, TableColumn tableColumn, int level, int column)
comp
- the component that renders the columntableColumn
- the column that is being renderedlevel
- the level of the columncolumn
- the column being drawn
public boolean getResizingAllowed()
getResizingAllowed
in class JTableHeader
resizingAllowed
propertyJTableHeader.setResizingAllowed(boolean)
public TableColumn groupColumnAtPoint(Point p)
p
- the point for which a group column exists
public void groupColumnsInserted(GroupTableColumnModelEvent e)
groupColumnsInserted
in interface GroupTableColumnModelListener
e
- the event that identifies the addition.public void groupColumnsRemoved(GroupTableColumnModelEvent e)
groupColumnsRemoved
in interface GroupTableColumnModelListener
e
- the event that identifies the removalpublic int groupLevelAtPoint(Point p)
p
- the point for which a group column exists
protected boolean handleEvent(MouseEvent e, Component comp)
handleEvent
in class AdvancedTableHeader
e
- the mouse event that triggered the methodcomp
- the drawn table cell component
public boolean isReorderingAllowed(int index)
setFirstColumnFixed
).
isReorderingAllowed
in class AdvancedTableHeader
index
- the index of the table column
public boolean isReorderingAllowed(Point p)
isReorderingAllowed
in class AdvancedTableHeader
p
- object containing the x and y coordinates of the mouse event
protected Component prepareRenderer(TableCellRenderer renderer, Object value, GroupTableColumn groupColumn, int level, int column)
renderer
- the renderer to return a component fromvalue
- the value used to initialize the renderergroupColumn
- the groupColumn being drawn or null if there is no group columnlevel
- the level of the group columncolumn
- the column
public void removeGroupColumn(GroupTableColumn aColumn)
aColumn
- the group column to removepublic void setAllowGroupColumnReordering(boolean allowGroupColumnReordering)
allowGroupColumnReordering
- true if group columns
can be reordered with the mouse, false otherwisepublic void setAllowGroupReordering(boolean allowGroupReordering)
allowGroupReordering
- true if columns that are part of a group
can be reordered with the mouse, false otherwisepublic void setColumnModel(TableColumnModel newModel)
newModel
and registers
for listener notifications from the new column model.
setColumnModel
in class AdvancedTableHeader
newModel
- the new data source for this tableJTableHeader.getColumnModel()
public void setDefaultGroupRenderer(TableCellRenderer renderer, int level)
renderer
- the default header renderer for group columnslevel
- the group table column's levelpublic void setFactory(TableCellRendererFactory newFactory)
newFactory
- the new table cell renderer factory to assign.public void setGroupColumnModel(GroupTableColumnModel groupModel)
groupModel
- the new group column model to assign.public void setResizingColumn(TableColumn aColumn)
resizingColumn
to aColumn
.
Application code will not use this method explicitly, it is used internally by the column sizing mechanism.
setResizingColumn
in class JTableHeader
aColumn
- the column being resized, or null
if
no column is being resizedpublic void setTable(JTable aTable)
setTable
in class AdvancedTableHeader
aTable
- the new tablepublic void updateUI()
UIManager
that the look and feel
(L&F) has changed.
Replaces the current UI object with the latest version from the
UIManager
.
updateUI
in class AdvancedTableHeader
JComponent.updateUI()
|
Copyright © 2005 Scientific Applications. All Rights Reserved. | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |