swingx
Version 2005-08-19

org.jdesktop.swingx.decorator
Class PatternHighlighter

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

public class PatternHighlighter
extends ConditionalHighlighter
implements PatternMatcher

PatternHighlighter


Nested Class Summary
 
Nested classes/interfaces inherited from class org.jdesktop.swingx.decorator.Highlighter
Highlighter.UIHighlighter
 
Field Summary
protected  Pattern 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
PatternHighlighter()
          Constructs a PatternHighlighter instance with no background or foreground color and no pattern
PatternHighlighter(Color background, Color foreground, String regExString, int matchFlags, int testColumn)
           Constructs a PatternHighlighter instance with the specified background and foreground colors that will be used to decorate the renderer component for all cell in a row if and only if the specified regExString defines a valid Pattern, and the value of the cell in the specified testColumn of that row matches that pattern.
PatternHighlighter(Color background, Color foreground, String regExString, int matchFlags, int testColumn, int decorateColumn)
           Constructs a PatternHighlighter instance with the specified background and foreground colors that will be used to decorate the renderer component for a cell in the specified decorateColumn of any row if and only if the specified regExString and matchFlags define a valid Pattern, and the value of the cell in the specified testColumn of the same row matches that pattern.
 
Method Summary
 Pattern getPattern()
          Returns the pattern used by this cell decorator for matching against a cell's value to determine if the conditions for cell decoration are met.
 void setPattern(Pattern pattern)
          Sets the pattern used by this cell decorator to match against a cell's value to determine if the conditions for cell decoration are met.
 void setPattern(String regularExpr, int matchFlags)
           
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.ConditionalHighlighter
computeSelectedForeground, doMask, getHighlightColumnIndex, getMask, getTestColumnIndex, highlight, maskBackground, maskForeground, needsHighlight, setHighlightColumnIndex, setMask, setTestColumnIndex
 
Methods inherited from class org.jdesktop.swingx.decorator.Highlighter
addChangeListener, applyBackground, applyForeground, computeBackground, computeForeground, computeSelectedBackground, 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
 

Field Detail

pattern

protected Pattern pattern
Constructor Detail

PatternHighlighter

public PatternHighlighter()
Constructs a PatternHighlighter instance with no background or foreground color and no pattern


PatternHighlighter

public PatternHighlighter(Color background,
                          Color foreground,
                          String regExString,
                          int matchFlags,
                          int testColumn)
                   throws PatternSyntaxException

Constructs a PatternHighlighter instance with the specified background and foreground colors that will be used to decorate the renderer component for all cell in a row if and only if the specified regExString defines a valid Pattern, and the value of the cell in the specified testColumn of that row matches that pattern.

Parameters:
background - background color for decorated cells, or null, if background should not be changed
foreground - foreground color for decorated cells, or null, if foreground should not be changed
regExString - the regular expression string to compile, or null to leave the pattern undefined
testColumn - column to which the pattern matching test is applied; must be a valid column index in model coordinates
Throws:
PatternSyntaxException - if regExString is not null, but it does not define a valid Pattern
See Also:
Pattern

PatternHighlighter

public PatternHighlighter(Color background,
                          Color foreground,
                          String regExString,
                          int matchFlags,
                          int testColumn,
                          int decorateColumn)
                   throws PatternSyntaxException

Constructs a PatternHighlighter instance with the specified background and foreground colors that will be used to decorate the renderer component for a cell in the specified decorateColumn of any row if and only if the specified regExString and matchFlags define a valid Pattern, and the value of the cell in the specified testColumn of the same row matches that pattern.

Parameters:
background - background color for decorated cells, or null, if background should not be changed
foreground - foreground color for decorated cells, or null, if foreground should not be changed
regExString - the regular expression string to compile, or null to leave the pattern undefined
matchFlags - a bit mask that may include Pattern.CASE_INSENSITIVE, Pattern.MULTILINE, Pattern.DOTALL, Pattern.UNICODE_CASE, and Pattern.CANON_EQ
testColumn - column to which the pattern matching test is applied; must be a valid column index in model coordinates
decorateColumn - column to which decorator attributes will be applied; may be a valid column index in model coordinates, or -1 to indicate all columns
Throws:
PatternSyntaxException - if regExString is not null, but regExString and matchFlags do not define a valid Pattern
See Also:
Pattern
Method Detail

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.

Specified by:
test in class ConditionalHighlighter
Parameters:
adapter - the current cell rendering adapter
Returns:
true if the test succeeds; false otherwise

getPattern

public Pattern getPattern()
Returns the pattern used by this cell decorator for matching against a cell's value to determine if the conditions for cell decoration are met.

Specified by:
getPattern in interface PatternMatcher
Returns:
the pattern used by this cell decorator for matching
See Also:
Pattern

setPattern

public void setPattern(String regularExpr,
                       int matchFlags)

setPattern

public void setPattern(Pattern pattern)
Sets the pattern used by this cell decorator to match against a cell's value to determine if the conditions for cell decoration are met.

Specified by:
setPattern in interface PatternMatcher
Parameters:
pattern - the pattern used by this cell decorator for matching
See Also:
Pattern

swingx
Version 2005-08-19