JIDE 3.5.15

com.jidesoft.grid
Class FilterableTableHeaderCellDecorator

java.lang.Object
  extended by com.jidesoft.grid.FilterableTableHeaderCellDecorator
All Implemented Interfaces:
TableHeaderCellDecorator

public class FilterableTableHeaderCellDecorator
extends Object
implements TableHeaderCellDecorator

This class is to paint filter button. By default, it will not paint anything on the header cell. When the mouse is over the header, it will paint a filter icon on the right side of the cell. Clicking on it will bring up the drop down list for auto-filter. If a column has filters, then a filter icon will remain on the cell even the mouse is not over.

Since:
3.1.0

Field Summary
static int GAP
           
 
Constructor Summary
FilterableTableHeaderCellDecorator()
           
 
Method Summary
 Insets getInsets(Graphics g, JTableHeader header, int columnIndex, Rectangle cellRect)
          Gets the margin insets where this cell decorator will paint in.
 boolean isShowVerticalLine()
          Gets the flag indicating if the vertical line to separate the column name and the filter icon should be painted.
protected  boolean needPaintFilterIcon(JTableHeader header, int columnIndex)
          Checks if the decorator should paint filter icon for the visual column index of the table header.
 void paint(Graphics g, JTableHeader header, int columnIndex, Rectangle cellRect, boolean mouseOverPaintArea)
          Paints the table header cell.
 void setShowVerticalLine(boolean showVerticalLine)
          Sets the flag indicating if the vertical line to separate the column name and the filter icon should be painted.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

GAP

public static final int GAP
See Also:
Constant Field Values
Constructor Detail

FilterableTableHeaderCellDecorator

public FilterableTableHeaderCellDecorator()
Method Detail

getInsets

public Insets getInsets(Graphics g,
                        JTableHeader header,
                        int columnIndex,
                        Rectangle cellRect)
Description copied from interface: TableHeaderCellDecorator
Gets the margin insets where this cell decorator will paint in. Even though the table header could be in RTL or LTR orientation, we require you return the insets as in LTR orientation and we will properly adjust it based on the actual table header orientation.

Specified by:
getInsets in interface TableHeaderCellDecorator
Parameters:
g - the Graphics instance
header - the table header
columnIndex - the view column index to be painted
cellRect - the original cell rectangle for the column
Returns:
the margin area so the original header cell will not paint over this margin. Null if you don't need to restrict the painting of original header.

paint

public void paint(Graphics g,
                  JTableHeader header,
                  int columnIndex,
                  Rectangle cellRect,
                  boolean mouseOverPaintArea)
Description copied from interface: TableHeaderCellDecorator
Paints the table header cell. This paint method will be called after the original table header cell is painted. Theoretically, you can paint whatever you want but in most cases, you probably want to make sure the painting code is consistent with insets returned from TableHeaderCellDecorator.getInsets(java.awt.Graphics, javax.swing.table.JTableHeader, int, java.awt.Rectangle), i.e., paint only in the area as specified in the insets. You do need to consider both RTL and LTR orientations in your code when doing the painting.

Specified by:
paint in interface TableHeaderCellDecorator
Parameters:
g - the Graphics instance
header - the table header
columnIndex - the view column index to be painted
cellRect - the original cell rectangle for the column
mouseOverPaintArea - the flag indicating if the mouse is over the paint area of this cell decorator

needPaintFilterIcon

protected boolean needPaintFilterIcon(JTableHeader header,
                                      int columnIndex)
Checks if the decorator should paint filter icon for the visual column index of the table header.

Parameters:
header - the table header
columnIndex - the visual column index, could be negative when it is a group column
Returns:
true if the filter icon is to be painted. Otherwise false.
Since:
3.2.3

isShowVerticalLine

public boolean isShowVerticalLine()
Gets the flag indicating if the vertical line to separate the column name and the filter icon should be painted.

Returns:
true if the vertical line should be painted. Otherwise false.
Since:
3.4.1
See Also:
setShowVerticalLine(boolean)

setShowVerticalLine

public void setShowVerticalLine(boolean showVerticalLine)
Sets the flag indicating if the vertical line to separate the column name and the filter icon should be painted.

By default, the value is true to keep the behavior backward compatibility.

Parameters:
showVerticalLine - the flag
Since:
3.4.1

JIDE 3.5.15