JIDE 3.5.15

com.jidesoft.plaf.basic
Class BasicCellStyleTableHeaderUIDelegate

java.lang.Object
  extended by com.jidesoft.plaf.TableHeaderUIDelegate
      extended by com.jidesoft.plaf.basic.BasicCellStyleTableHeaderUIDelegate
All Implemented Interfaces:
MouseListener, MouseMotionListener, PropertyChangeListener, EventListener, TableColumnModelListener, TableModelListener
Direct Known Subclasses:
BasicSortableTableHeaderUIDelegate

public class BasicCellStyleTableHeaderUIDelegate
extends TableHeaderUIDelegate
implements TableModelListener, PropertyChangeListener, TableColumnModelListener


Field Summary
protected  JTableHeader _header
           
protected  int _mouseXOffset
           
protected  CellRendererPane _rendererPane
           
 
Constructor Summary
BasicCellStyleTableHeaderUIDelegate(JTableHeader header, CellRendererPane rendererPane)
           
 
Method Summary
 void columnAdded(TableColumnModelEvent e)
           
 void columnMarginChanged(ChangeEvent e)
           
 void columnMoved(TableColumnModelEvent e)
           
 void columnRemoved(TableColumnModelEvent e)
           
 void columnSelectionChanged(ListSelectionEvent e)
           
protected  Border createMarginBorder(Insets insets, Border existingBorder)
           
protected  void customizePaint(Graphics g, TableColumn column, Rectangle cellRect)
           
protected  void customizeRendererComponent(Component comp, int rowIndex, int columnIndex, Rectangle cellRect)
          Customizes the renderer component to be painted.
protected  void dragColumn(int columnIndex, int targetX)
          Drags the column to a new position.
 Insets getBorderInsets(Graphics g, int columnIndex, Rectangle cellRect)
          Gets the border insets to be configured to the renderer component.
protected  int getHeaderPreferredHeight()
          Gets the preferred height of the header.
protected  TableCellRenderer getHeaderRenderer(TableColumn aColumn)
          Gets header renderer from the TableColumn instance and the column index.
 int getPreferredHeight(int column)
          Gets the column's preferred height assuming the column width is fixed.
 Dimension getPreferredSize(JComponent c)
          Gets the preferred size of the header.
 int getPreferredWidth(int columnIndex)
          Gets the column's preferred width.
 TableColumn getResizingColumn(Point p, int column)
          Gets current resizing column from the mouse point and the column index.
 boolean hasStyledLabelColumn()
          Returns if this UIDelegate have StyledLabel at least for one column.
 void invalidateCache(boolean originator)
          Invalidates all cache.
protected  boolean isMouseOverPaintArea(Point p, Rectangle cellRect, Insets insets)
          Checks if the mouse is over paint area.
 void mouseClicked(MouseEvent e)
           
 void mouseDragged(MouseEvent e)
           
 void mouseEntered(MouseEvent e)
           
 void mouseExited(MouseEvent e)
           
 void mouseMoved(MouseEvent e)
           
 void mousePressed(MouseEvent e)
           
 void mouseReleased(MouseEvent e)
           
 void paint(Graphics g, JComponent c)
          Paint method to paint the entire header.
protected  void paintCell(Graphics g, Rectangle cellRect, int columnIndex, Object value, boolean isSelected, boolean hasFocus, boolean paintCellDecorators)
          Paints the header cell.
 void propertyChange(PropertyChangeEvent evt)
           
protected  void releaseRendererComponent(Component comp, int rowIndex, int columnIndex, Rectangle cellRect)
          Releases the customization of the renderer component after being painted.
protected  void resizeColumn(TableColumn resizingColumn, int newWidth)
          Resizes the target column with new width.
protected  void startResizingColumn(Point p, TableColumn resizingColumn)
          Post-process to start to resize column.
 void tableChanged(TableModelEvent e)
           
 void uninstallAllListeners()
          Uninstall all listeners before setting new table header.
 int viewIndexForColumn(TableColumn aColumn)
          Gets the view column index from the TableColumn instance.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_header

protected JTableHeader _header

_rendererPane

protected CellRendererPane _rendererPane

_mouseXOffset

protected int _mouseXOffset
Constructor Detail

BasicCellStyleTableHeaderUIDelegate

public BasicCellStyleTableHeaderUIDelegate(JTableHeader header,
                                           CellRendererPane rendererPane)
Method Detail

uninstallAllListeners

public void uninstallAllListeners()
Description copied from class: TableHeaderUIDelegate
Uninstall all listeners before setting new table header. After invoking this method, this UI will not take effect any more.

Specified by:
uninstallAllListeners in class TableHeaderUIDelegate

viewIndexForColumn

public int viewIndexForColumn(TableColumn aColumn)
Gets the view column index from the TableColumn instance.

Parameters:
aColumn - the TableColumn instance
Returns:
the view index in the TableColumnModel. -1 if the TableColumn cannot be found in current TableColumnModel.

getHeaderRenderer

protected TableCellRenderer getHeaderRenderer(TableColumn aColumn)
Gets header renderer from the TableColumn instance and the column index.

Parameters:
aColumn - the TableColumn instance
Returns:
the cell renderer for the column.

getBorderInsets

public Insets getBorderInsets(Graphics g,
                              int columnIndex,
                              Rectangle cellRect)
Gets the border insets to be configured to the renderer component.

Parameters:
g - the Graphics instance
columnIndex - the view column index. -1 if the column is not included in TableColumnModel. For example, group column.
cellRect - the cell rect to paint the header
Returns:
the border insets reserved for the column to paint other components, like sort icon, filter icon, etc.

paintCell

protected void paintCell(Graphics g,
                         Rectangle cellRect,
                         int columnIndex,
                         Object value,
                         boolean isSelected,
                         boolean hasFocus,
                         boolean paintCellDecorators)
Paints the header cell.

Parameters:
g - the Graphics instance
cellRect - the cell rectangle to be painted in
columnIndex - the view column index to paint
value - the header value to paint
isSelected - if the column is selected
hasFocus - if the column has focus
paintCellDecorators - if the cell decorators should be used as well

createMarginBorder

protected Border createMarginBorder(Insets insets,
                                    Border existingBorder)

isMouseOverPaintArea

protected boolean isMouseOverPaintArea(Point p,
                                       Rectangle cellRect,
                                       Insets insets)
Checks if the mouse is over paint area.

Parameters:
p - the mouse position
cellRect - the cell rect to paint
insets - the paint insets returned by TableHeaderCellDecorator
Returns:
true if the mouse is in the area TableHeaderCellDecorator want to paint. Otherwise false.

customizeRendererComponent

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

The default implementation is to invoke CellStyleTableHeader.customizeRendererComponent(java.awt.Component, int, int, java.awt.Rectangle)

Parameters:
comp - 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

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

The default implementation is to invoke CellStyleTableHeader.releaseRendererComponent(java.awt.Component, int, int, java.awt.Rectangle)

Please be noted that the native table header row will always be 0. In NestedTableHeader scenario, if there were 3 rows, the row indices from top to bottom would be -2, -1, 0.

Parameters:
comp - 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

customizePaint

protected void customizePaint(Graphics g,
                              TableColumn column,
                              Rectangle cellRect)

paint

public void paint(Graphics g,
                  JComponent c)
Paint method to paint the entire header.

Parameters:
g - the Graphics instance
c - the component to be painted

getHeaderPreferredHeight

protected int getHeaderPreferredHeight()
Gets the preferred height of the header.

Returns:
the header's preferred height.

getPreferredSize

public Dimension getPreferredSize(JComponent c)
Gets the preferred size of the header.

Parameters:
c - the component
Returns:
the preferred size of the header.

mouseClicked

public void mouseClicked(MouseEvent e)
Specified by:
mouseClicked in interface MouseListener

mouseDragged

public void mouseDragged(MouseEvent e)
Specified by:
mouseDragged in interface MouseMotionListener

dragColumn

protected void dragColumn(int columnIndex,
                          int targetX)
Drags the column to a new position.

Parameters:
columnIndex - the dragging column index
targetX - the X position of target point

resizeColumn

protected void resizeColumn(TableColumn resizingColumn,
                            int newWidth)
Resizes the target column with new width.

Parameters:
resizingColumn - the column to resize
newWidth - the new width

mousePressed

public void mousePressed(MouseEvent e)
Specified by:
mousePressed in interface MouseListener

mouseMoved

public void mouseMoved(MouseEvent e)
Specified by:
mouseMoved in interface MouseMotionListener

mouseReleased

public void mouseReleased(MouseEvent e)
Specified by:
mouseReleased in interface MouseListener

mouseEntered

public void mouseEntered(MouseEvent e)
Specified by:
mouseEntered in interface MouseListener

mouseExited

public void mouseExited(MouseEvent e)
Specified by:
mouseExited in interface MouseListener

getResizingColumn

public TableColumn getResizingColumn(Point p,
                                     int column)
Gets current resizing column from the mouse point and the column index.

Parameters:
p - the point
column - the view column index
Returns:
the TableColumn instance. null if no column is resizing.

startResizingColumn

protected void startResizingColumn(Point p,
                                   TableColumn resizingColumn)
Post-process to start to resize column.

Parameters:
p - the mouse point
resizingColumn - the resizing column

hasStyledLabelColumn

public boolean hasStyledLabelColumn()
Returns if this UIDelegate have StyledLabel at least for one column.

Returns:
true if StyledLabel is used at least for one column.Otherwise false.
Since:
3.3.4

tableChanged

public void tableChanged(TableModelEvent e)
Specified by:
tableChanged in interface TableModelListener

columnAdded

public void columnAdded(TableColumnModelEvent e)
Specified by:
columnAdded in interface TableColumnModelListener

columnRemoved

public void columnRemoved(TableColumnModelEvent e)
Specified by:
columnRemoved in interface TableColumnModelListener

columnMoved

public void columnMoved(TableColumnModelEvent e)
Specified by:
columnMoved in interface TableColumnModelListener

columnMarginChanged

public void columnMarginChanged(ChangeEvent e)
Specified by:
columnMarginChanged in interface TableColumnModelListener

columnSelectionChanged

public void columnSelectionChanged(ListSelectionEvent e)
Specified by:
columnSelectionChanged in interface TableColumnModelListener

propertyChange

public void propertyChange(PropertyChangeEvent evt)
Specified by:
propertyChange in interface PropertyChangeListener

invalidateCache

public void invalidateCache(boolean originator)
Invalidates all cache.

Parameters:
originator - the flag indicating if the other table header inside the same TableScrollPane should be invalidated.

getPreferredHeight

public int getPreferredHeight(int column)
Gets the column's preferred height assuming the column width is fixed.

Parameters:
column - the visual column
Returns:
the preferred height for the column.

getPreferredWidth

public int getPreferredWidth(int columnIndex)
Description copied from class: TableHeaderUIDelegate
Gets the column's preferred width.

Specified by:
getPreferredWidth in class TableHeaderUIDelegate
Parameters:
columnIndex - the visual column
Returns:
the preferred width for the column.

JIDE 3.5.15