JIDE 3.5.15

com.jidesoft.grid
Class CellStyleTableHeader

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by javax.swing.table.JTableHeader
                  extended by com.jidesoft.grid.DraggingTableHeader
                      extended by com.jidesoft.grid.CellStyleTableHeader
All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, EventListener, Accessible, TableColumnModelListener
Direct Known Subclasses:
SortableTableHeader

public class CellStyleTableHeader
extends DraggingTableHeader

This is a table header which is able to paint designated style in the header while keeping original header renderer in its maximum effort.

Since NestedTableHeader has multiple rows, CellStyleTableHeader will get its renderer component with row index as 0 instead of -1.

Since:
3.2.0
See Also:
Serialized Form

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.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
 
Field Summary
protected  List<CellStyle> _cellStyleList
           
 
Fields inherited from class com.jidesoft.grid.DraggingTableHeader
PROPERTY_DRAGGED_COLUMN, PROPERTY_DRAGGED_DISTANCE, PROPERTY_RESIZING_COLUMN
 
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
CellStyleTableHeader()
           
CellStyleTableHeader(JTable table)
           
CellStyleTableHeader(TableColumnModel cm)
           
 
Method Summary
 void addCellDecorator(int index, TableHeaderCellDecorator cellDecorator)
          Adds a table header cell decorator.
 void addCellDecorator(TableHeaderCellDecorator cellDecorator)
          Adds a table header cell decorator to the end.
 void addCellStyleCustomizer(CellStyleCustomizer customizer)
          Adds a new CellStyleCustomizer.
 void clearCellStyleCustomizers()
          Clears all the CellStyleCustomizers.
protected  void collectCellStyles(int row, int column)
          Collects the cell style of the cell and put into a sorted ArrayList which is a field called _cellStyleList.
 JToolTip createToolTip()
           
 void customizeRendererComponent(Component component, int rowIndex, int columnIndex, Rectangle cellRect)
          Customizes the renderer component to be painted.
 int getActualHeaderY()
          Gets the start Y of actual table header.
 String getActualUIClassID()
          Returns a string that actually represents the UI class ID of this class.
 TableHeaderCellDecorator[] getCellDecorators()
          Get all header cell decorators.
 CellStyle getCellStyleAt(int row, int column)
          Get the merged cell style for the cell from all its underlying HeaderStyleModel.
 CellStyleCustomizer[] getCellStyleCustomizers()
          Gets all the CellStyleCustomizers.
 Cursor getDefaultCursor()
          Gets the default cursor of the CellStyleTableHeader.
 String getUIDelegateClassID()
          Returns a string that specifies the name of the UIDelegate class that paints this component.
protected static CellStyle mergeCellStyles(List<CellStyle> cellStyles)
          Merges the cell styles in the list into one CellStyle.
 int originalColumnAtPoint(Point point)
          Gets column at point disregarding the Y.
 void releaseRendererComponent(Component component, int rowIndex, int columnIndex, Rectangle cellRect)
          Releases the customization of the renderer component after being painted.
 void removeCellDecorator(TableHeaderCellDecorator cellDecorator)
          Removes the existing table header cell decorator.
 void removeCellStyleCustomizer(CellStyleCustomizer customizer)
          Removes an existing CellStyleCustomizer.
 void setCursor(Cursor cursor)
           
 void setDefaultRenderer(TableCellRenderer defaultRenderer)
           
 void updateUI()
           
 
Methods inherited from class com.jidesoft.grid.DraggingTableHeader
getPreferredSize, getToolTipText, paintComponent, setDraggedColumn, setDraggedDistance, setResizingColumn
 
Methods inherited from class javax.swing.table.JTableHeader
columnAdded, columnAtPoint, columnMarginChanged, columnMoved, columnRemoved, columnSelectionChanged, createDefaultColumnModel, createDefaultRenderer, getAccessibleContext, getColumnModel, getDefaultRenderer, getDraggedColumn, getDraggedDistance, getHeaderRect, getReorderingAllowed, getResizingAllowed, getResizingColumn, getTable, getUI, getUIClassID, getUpdateTableInRealTime, initializeLocalVars, paramString, resizeAndRepaint, setColumnModel, setReorderingAllowed, setResizingAllowed, setTable, setUI, setUpdateTableInRealTime
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusBackward, transferFocusDownCycle, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

_cellStyleList

protected final List<CellStyle> _cellStyleList
Constructor Detail

CellStyleTableHeader

public CellStyleTableHeader()

CellStyleTableHeader

public CellStyleTableHeader(JTable table)

CellStyleTableHeader

public CellStyleTableHeader(TableColumnModel cm)
Method Detail

getUIDelegateClassID

public String getUIDelegateClassID()
Returns a string that specifies the name of the UIDelegate class that paints this component.

Returns:
the string "TableHeader.sortableTableHeaderUIDelegate"

getActualUIClassID

public String getActualUIClassID()
Returns a string that actually represents the UI class ID of this class.

Returns:
the string "CellStyleTableHeaderUI".

updateUI

public void updateUI()
Overrides:
updateUI in class JTableHeader

setDefaultRenderer

public void setDefaultRenderer(TableCellRenderer defaultRenderer)
Overrides:
setDefaultRenderer in class JTableHeader

createToolTip

public JToolTip createToolTip()
Overrides:
createToolTip in class JComponent

getActualHeaderY

public int getActualHeaderY()
Gets the start Y of actual table header.

In NestedTableHeader and GroupTableHeader scenarios, this method will return different value other than 0.

Returns:
0 by default.

addCellDecorator

public void addCellDecorator(TableHeaderCellDecorator cellDecorator)
Adds a table header cell decorator to the end.

Parameters:
cellDecorator - the table header cell decorator to add

addCellDecorator

public void addCellDecorator(int index,
                             TableHeaderCellDecorator cellDecorator)
Adds a table header cell decorator.

Parameters:
index - the order the cell decorator will be invoked
cellDecorator - the table header cell decorator to add

removeCellDecorator

public void removeCellDecorator(TableHeaderCellDecorator cellDecorator)
Removes the existing table header cell decorator.

Parameters:
cellDecorator - the cell decorator to remove

getCellDecorators

public TableHeaderCellDecorator[] getCellDecorators()
Get all header cell decorators.

Returns:
the header cell decorators array. Empty array if no cell decorators at all.

originalColumnAtPoint

public int originalColumnAtPoint(Point point)
Gets column at point disregarding the Y.

Parameters:
point - the mouse point
Returns:
the view column index. -1 if no column is found on the header.

getCellStyleAt

public CellStyle getCellStyleAt(int row,
                                int column)
Get the merged cell style for the cell from all its underlying HeaderStyleModel.

Parameters:
row - the row index
column - the view column index
Returns:
the merged cell style.

mergeCellStyles

protected static CellStyle mergeCellStyles(List<CellStyle> cellStyles)
Merges the cell styles in the list into one CellStyle.

Parameters:
cellStyles - the list of CellStyles.
Returns:
a CellStyle that merges all the CellStyles in the list.

collectCellStyles

protected void collectCellStyles(int row,
                                 int column)
Collects the cell style of the cell and put into a sorted ArrayList which is a field called _cellStyleList.

Parameters:
row - the row index.
column - the view column index.

customizeRendererComponent

public void customizeRendererComponent(Component component,
                                       int rowIndex,
                                       int columnIndex,
                                       Rectangle cellRect)
Customizes the renderer component to be painted.

The default implementation is just applying the component orientation. You could override this method to configure alignment, etc.

Parameters:
component - the renderer component
rowIndex - the view row index inside the table header. Should be 0 unless it is a NestedTableHeader.
columnIndex - the view column index
cellRect - the cell rectangle to paint the component

releaseRendererComponent

public void releaseRendererComponent(Component component,
                                     int rowIndex,
                                     int columnIndex,
                                     Rectangle cellRect)
Releases the customization of the renderer component after being painted.

The default implementation is just applying the component orientation back. You could override this method to release your configurations done at customizeRendererComponent(java.awt.Component, int, int, java.awt.Rectangle)

Parameters:
component - the renderer component
rowIndex - the view row index inside the table header. Should be 0 unless it is a NestedTableHeader.
columnIndex - the view column index
cellRect - the cell rectangle to paint the component

setCursor

public void setCursor(Cursor cursor)
Overrides:
setCursor in class Component

getDefaultCursor

public Cursor getDefaultCursor()
Gets the default cursor of the CellStyleTableHeader.

The header ui will set the header's cursor dynamically when the mouse is moved over the table header. This method is to get the default cursor other than the resizing cursor that the table header is using. It will be changed by invoking setCursor(java.awt.Cursor). Only one cursor, Cursor.E_RESIZE_CURSOR, won't be returned here.

Returns:
the default cursor.
Since:
3.3.5

addCellStyleCustomizer

public void addCellStyleCustomizer(CellStyleCustomizer customizer)
Adds a new CellStyleCustomizer. When you add extra non-default styles to CellStyle class and use this interface to read the style from CellStyle and customizes the renderer component or the editor component. Without this method, you need to override customizeRendererComponent(java.awt.Component, int, int, java.awt.Rectangle) methods.

Parameters:
customizer - a new CellStyleCustomizer.

removeCellStyleCustomizer

public void removeCellStyleCustomizer(CellStyleCustomizer customizer)
Removes an existing CellStyleCustomizer.

Parameters:
customizer - the CellStyleCustomizer to be removed

getCellStyleCustomizers

public CellStyleCustomizer[] getCellStyleCustomizers()
Gets all the CellStyleCustomizers.

Returns:
all the CellStyleCustomizers.

clearCellStyleCustomizers

public void clearCellStyleCustomizers()
Clears all the CellStyleCustomizers.


JIDE 3.5.15