Copyright © 2011 Citra Technologies. All Rights Reserved.

com.citra.filter
Class DefaultFilterRenderer

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.CellRendererPane
              extended by com.citra.table.WrapperCellRendererPane
                  extended by com.citra.filter.DefaultFilterRenderer
All Implemented Interfaces:
FilterRenderer, ImageObserver, MenuContainer, Serializable, Accessible

public class DefaultFilterRenderer
extends WrapperCellRendererPane
implements FilterRenderer

DefaultFilterRenderer is the default FilterRenderer implementation that uses an arrow button to present users with filter options for a column.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.CellRendererPane
CellRendererPane.AccessibleCellRendererPane
 
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  ArrowButton arrow
          The button that is showing on the header.
protected  Color filteredColor
          the color of the arrow for a column that has filters
protected  boolean inline
          whether to display the filter arrow inside the renderer or use a separate component
protected  Component normalComponent
          the component returned from the unfiltered renderer
protected  Color unfilteredColor
          the color of the arrow for a column that has no filters
protected  boolean useRollOver
          flag that determines whether the arrow button will be visible only if the user rolls over the column with the mouse
 
Fields inherited from class com.citra.table.WrapperCellRendererPane
opaqueFalse
 
Fields inherited from class javax.swing.CellRendererPane
accessibleContext
 
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
DefaultFilterRenderer()
          Constructs a DefaultFilterRenderer.
 
Method Summary
 boolean checkForFilter(MouseEvent e, PopupFilterHeaderModel model)
          Determines whether the mouse event triggered the start of a filter action on the column.
 ArrowButton getArrowButton()
          Returns the arrow button that is showing when a filter is installed on the column.
 Component getFilterableComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column, int rollOverColumn, PopupFilterHeaderModel model, TableCellRenderer innerRenderer)
          Returns the component used for drawing the filterable header column.
 Color getFilteredColor()
          Determines the color of the arrow button for columns that have filters.
 Component getMainComponent()
          Returns the main wrapped component.
 Dimension getPreferredSize()
          Returns the preferred size of this container.
 String getToolTipText(MouseEvent event)
          Returns the string to be used as the tooltip for event.
 Color getUnfilteredColor()
          Determines the color of the arrow button for columns that do not have filters.
 boolean getUseInline()
          Determines whether the arrow button will be displayed inside the renderer or a separate component will be used.
 boolean getUseRollOver()
          Determines whether the arrow button will be visible only if the user rolls over the column with the mouse.
 void paint(Graphics g)
          Paints its children according to their size and location.
 void setBounds(int x, int y, int w, int h)
          Moves and resizes this component.
 void setFilteredColor(Color filteredColor)
          Assigns the color of the arrow button for columns that have filters.
 void setUnfilteredColor(Color unfilteredColor)
          Assigns the color of the arrow button for columns that do not have filters.
 void setUseInline(boolean inline)
          Determines whether the arrow button will be displayed inside the renderer or a separate component will be used.
 void setUseRollOver(boolean useRollOver)
          Determines whether the arrow button will be visible only if the user rolls over the column with the mouse.
 
Methods inherited from class com.citra.table.WrapperCellRendererPane
getMainComponent, paintComponent
 
Methods inherited from class javax.swing.CellRendererPane
addImpl, getAccessibleContext, invalidate, paintComponent, paintComponent, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getInsets, getLayout, getListeners, getMaximumSize, getMinimumSize, insets, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, paramString, preferredSize, print, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, removeNotify, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setFont, 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, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isOpaque, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, reshape, resize, resize, setBackground, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, setVisible, 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

normalComponent

protected Component normalComponent
the component returned from the unfiltered renderer


arrow

protected transient ArrowButton arrow
The button that is showing on the header.


unfilteredColor

protected Color unfilteredColor
the color of the arrow for a column that has no filters


filteredColor

protected Color filteredColor
the color of the arrow for a column that has filters


useRollOver

protected boolean useRollOver
flag that determines whether the arrow button will be visible only if the user rolls over the column with the mouse


inline

protected boolean inline
whether to display the filter arrow inside the renderer or use a separate component

Constructor Detail

DefaultFilterRenderer

public DefaultFilterRenderer()
Constructs a DefaultFilterRenderer.

Method Detail

checkForFilter

public boolean checkForFilter(MouseEvent e,
                              PopupFilterHeaderModel model)
Determines whether the mouse event triggered the start of a filter action on the column. If so, a popup menu containing available filter expression values is displayed for the column.

Specified by:
checkForFilter in interface FilterRenderer
Parameters:
e - the mouse event generated on the table's header
model - the filter header model containing information about installed filters
Returns:
true if the arrow button was pressed

getArrowButton

public ArrowButton getArrowButton()
Returns the arrow button that is showing when a filter is installed on the column.

Returns:
the arrow button.

getFilterableComponent

public Component getFilterableComponent(JTable table,
                                        Object value,
                                        boolean isSelected,
                                        boolean hasFocus,
                                        int row,
                                        int column,
                                        int rollOverColumn,
                                        PopupFilterHeaderModel model,
                                        TableCellRenderer innerRenderer)
Returns the component used for drawing the filterable header column. This method is used to configure the renderer appropriately before drawing.

Specified by:
getFilterableComponent in interface FilterRenderer
Parameters:
table - the table that is asking the renderer to draw
value - the value of the column to be rendered
isSelected - true if the column is to be rendered with the selection highlighted, false otherwise
hasFocus - if true, render appropriately.
row - the row index of the column being drawn. usually -1
column - the column index of the column being drawn
rollOverColumn - the column that the mouse is rolled over at the time of drawing or -1 if there is no rollover column
model - the filter header model that contains information about installed filters
innerRenderer - the renderer of the 'unfiltered' component
Returns:
the component used for drawing the filterable header column

getFilteredColor

public Color getFilteredColor()
Determines the color of the arrow button for columns that have filters. The default is Color.blue.

Returns:
the arrow button's color for filtered columns

getMainComponent

public Component getMainComponent()
Returns the main wrapped component. By default, this is returned.

Overrides:
getMainComponent in class WrapperCellRendererPane
Returns:
the wrapped component

getPreferredSize

public Dimension getPreferredSize()
Returns the preferred size of this container.

Overrides:
getPreferredSize in class Container
Returns:
an instance of Dimension that represents the preferred size of this container.
See Also:
Container.getMinimumSize(), Container.getLayout(), LayoutManager.preferredLayoutSize(Container), Component.getPreferredSize()

getToolTipText

public String getToolTipText(MouseEvent event)
Returns the string to be used as the tooltip for event.

Overrides:
getToolTipText in class WrapperCellRendererPane
Parameters:
event - the mouse event producing the tooltip
Returns:
the tooltip's text

getUnfilteredColor

public Color getUnfilteredColor()
Determines the color of the arrow button for columns that do not have filters. The default is null.

Returns:
the arrow button's color for non-filtered columns

getUseRollOver

public boolean getUseRollOver()
Determines whether the arrow button will be visible only if the user rolls over the column with the mouse. The default value is false.

Returns:
true if the arrow button is only visible when rolling over, false otherwise

setBounds

public void setBounds(int x,
                      int y,
                      int w,
                      int h)
Moves and resizes this component. The new location of the top-left corner is specified by x and y, and the new size is specified by width and height.

Overrides:
setBounds in class Component
Parameters:
x - the new x-coordinate of this component
y - the new y-coordinate of this component
w - the new width of this component
h - the new height of this component
See Also:
Component.getBounds(), Component.setLocation(int, int), Component.setLocation(Point), Component.setSize(int, int), Component.setSize(Dimension)

setFilteredColor

public void setFilteredColor(Color filteredColor)
Assigns the color of the arrow button for columns that have filters. The default is Color.blue.

Parameters:
filteredColor - the arrow button's color for filtered columns

setUnfilteredColor

public void setUnfilteredColor(Color unfilteredColor)
Assigns the color of the arrow button for columns that do not have filters. The default is null.

Parameters:
unfilteredColor - the arrow button's color for non-filtered columns

setUseRollOver

public void setUseRollOver(boolean useRollOver)
Determines whether the arrow button will be visible only if the user rolls over the column with the mouse. The default value is false.

Parameters:
useRollOver - true if the arrow button is only visible when rolling over, false otherwise

paint

public void paint(Graphics g)
Paints its children according to their size and location.

Overrides:
paint in class WrapperCellRendererPane
Parameters:
g - the graphics component to use
See Also:
Component.update(Graphics)

setUseInline

public void setUseInline(boolean inline)
Determines whether the arrow button will be displayed inside the renderer or a separate component will be used. The default value is false.

Parameters:
inline - true if the arrow button will be displayed inside the renderer, false otherwise

getUseInline

public boolean getUseInline()
Determines whether the arrow button will be displayed inside the renderer or a separate component will be used. The default value is false.

Returns:
true if the arrow button will be displayed inside the renderer, false otherwise

Copyright © 2011 Citra Technologies. All Rights Reserved.