swingx
Version 2005-08-19

org.jdesktop.swingx.decorator
Class SearchHighlighter

java.lang.Object
  extended by org.jdesktop.swingx.decorator.Highlighter
      extended by org.jdesktop.swingx.decorator.ConditionalHighlighter
          extended by org.jdesktop.swingx.decorator.PatternHighlighter
              extended by org.jdesktop.swingx.decorator.SearchHighlighter
All Implemented Interfaces:
PatternMatcher

public class SearchHighlighter
extends PatternHighlighter

Convenience Highlighter to test and highlight cells in searching.


Nested Class Summary
 
Nested classes/interfaces inherited from class org.jdesktop.swingx.decorator.Highlighter
Highlighter.UIHighlighter
 
Field Summary
 
Fields inherited from class org.jdesktop.swingx.decorator.PatternHighlighter
pattern
 
Fields inherited from class org.jdesktop.swingx.decorator.ConditionalHighlighter
highlightColumn, mask, testColumn
 
Fields inherited from class org.jdesktop.swingx.decorator.Highlighter
changeEvent, immutable, ledgerBackground, listenerList, notePadBackground
 
Constructor Summary
SearchHighlighter()
          Instantiates a default SearchHighlighter.
SearchHighlighter(Color background, Color foreground)
          Instantiates a default SearchHighlighter with background/foreground colors.
 
Method Summary
protected  Color computeSelectedBackground(Component renderer, ComponentAdapter adapter)
          Computes a suitable selected background for the renderer component within the specified adapter and returns the computed color.
protected  boolean needsHighlight(ComponentAdapter adapter)
          Checks if the cell identified by the specified adapter is a potential candidate for highlighting, and returns true if so; otherwise, it returns false.
 void setEnabled(boolean enableHighlight)
          Toggle to enable/disable - if disabled never hightlights.
 void setHighlightAll()
          convenience method to test and highlight all rows/columns and enable.
 void setHighlightCell(int row, int modelColumn)
          Set's highlightRow to row, test- and highlight column = column
 void setHighlightRow(int row)
          set the row to match in test
protected  boolean test(ComponentAdapter adapter)
          Tests whether the string representation of the value of the cell identified by the specified adapter matches the pattern, if any, that is set for this PatternHighlighter, and returns true if the test succeeds; Otherwise, it returns false.
 
Methods inherited from class org.jdesktop.swingx.decorator.PatternHighlighter
getPattern, setPattern, setPattern
 
Methods inherited from class org.jdesktop.swingx.decorator.ConditionalHighlighter
computeSelectedForeground, doMask, getHighlightColumnIndex, getMask, getTestColumnIndex, highlight, maskBackground, maskForeground, setHighlightColumnIndex, setMask, setTestColumnIndex
 
Methods inherited from class org.jdesktop.swingx.decorator.Highlighter
addChangeListener, applyBackground, applyForeground, computeBackground, computeForeground, computeSelectedBackground, computeSelectedForeground, computeUnselectedBackground, computeUnselectedForeground, doHighlight, fireStateChanged, getBackground, getChangeListeners, getForeground, getSelectedBackground, getSelectedForeground, isImmutable, removeChangeListener, setBackground, setForeground, setSelectedBackground, setSelectedForeground
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SearchHighlighter

public SearchHighlighter()
Instantiates a default SearchHighlighter. The default colors are Yellow background and null foreground. The default matching state is Pattern == null, flags = 0, tests all columns and all rows.


SearchHighlighter

public SearchHighlighter(Color background,
                         Color foreground)
Instantiates a default SearchHighlighter with background/foreground colors. The default matching state is Pattern == null, flags = 0, tests all columns and all rows.

Parameters:
background - color of hightlight background
foreground - color of highlight foreground
Method Detail

setEnabled

public void setEnabled(boolean enableHighlight)
Toggle to enable/disable - if disabled never hightlights.

Parameters:
enableHighlight -

needsHighlight

protected boolean needsHighlight(ComponentAdapter adapter)
Description copied from class: ConditionalHighlighter
Checks if the cell identified by the specified adapter is a potential candidate for highlighting, and returns true if so; otherwise, it returns false.

Overrides:
needsHighlight in class ConditionalHighlighter
Returns:
true if the cell identified by the specified adapter needs highlight; false otherwise

test

protected boolean test(ComponentAdapter adapter)
Description copied from class: PatternHighlighter
Tests whether the string representation of the value of the cell identified by the specified adapter matches the pattern, if any, that is set for this PatternHighlighter, and returns true if the test succeeds; Otherwise, it returns false.

Overrides:
test in class PatternHighlighter
Parameters:
adapter - the current cell rendering adapter
Returns:
true if the test succeeds; false otherwise

computeSelectedBackground

protected Color computeSelectedBackground(Component renderer,
                                          ComponentAdapter adapter)

Computes a suitable selected background for the renderer component within the specified adapter and returns the computed color. This implementation returns super if != null, otherwise returns computeUnselectedBackground. The reason is to always show a match marker even if no selection specific colors are set. PENDING: move up to ConditionalHighlighter?

Overrides:
computeSelectedBackground in class Highlighter
Parameters:
renderer -
adapter -
Returns:

setHighlightRow

public void setHighlightRow(int row)
set the row to match in test. - 1 means all.

Parameters:
row -

setHighlightAll

public void setHighlightAll()
convenience method to test and highlight all rows/columns and enable.


setHighlightCell

public void setHighlightCell(int row,
                             int modelColumn)
Set's highlightRow to row, test- and highlight column = column

Parameters:
row -
modelColumn -

swingx
Version 2005-08-19