org.jdesktop.swingx.decorator
Class AlignmentHighlighter

java.lang.Object
  extended by org.jdesktop.swingx.decorator.AbstractHighlighter
      extended by org.jdesktop.swingx.decorator.AlignmentHighlighter
All Implemented Interfaces:
Highlighter

public class AlignmentHighlighter
extends AbstractHighlighter

A Highlighter which sets the horizontal alignment.

Author:
Jeanette Winzenburg (slight cleanup), original contributed by swingx member martinm1000

Field Summary
 
Fields inherited from class org.jdesktop.swingx.decorator.AbstractHighlighter
listenerList
 
Constructor Summary
AlignmentHighlighter()
          Instantiates a AlignmentHighlighter with default alignment LEADING.
AlignmentHighlighter(HighlightPredicate predicate)
          Instantiates a FontHighlighter with the given HighlightPredicate and default horizontal alignement.
AlignmentHighlighter(HighlightPredicate predicate, int alignment)
          Instantiates a FontHighlighter with the given HighlightPredicate and null Font.
AlignmentHighlighter(int alignment)
          Instantiates a AlignmentHighlighter with the specified alignment.
 
Method Summary
protected  boolean canHighlight(java.awt.Component component, ComponentAdapter adapter)
          Subclasses may override to further limit the highlighting based on Highlighter state, f.i.
protected  java.awt.Component doHighlight(java.awt.Component renderer, ComponentAdapter adapter)
          Apply the highlights.
 int getHorizontalAlignment()
          Returns the alignment which is applied.
 void setHorizontalAlignment(int alignment)
          Sets the horizontal alignment to apply.
 
Methods inherited from class org.jdesktop.swingx.decorator.AbstractHighlighter
addChangeListener, areEqual, fireStateChanged, getChangeListeners, getHighlightPredicate, highlight, removeChangeListener, setHighlightPredicate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AlignmentHighlighter

public AlignmentHighlighter()
Instantiates a AlignmentHighlighter with default alignment LEADING. The Highlighter is applied always.


AlignmentHighlighter

public AlignmentHighlighter(int alignment)
Instantiates a AlignmentHighlighter with the specified alignment. The Highlighter is applied always.

Parameters:
alignment - the horizontal alignment to use.
Throws:
java.lang.IllegalArgumentException - if not one of the constants allowed as horizontal alignment, that is one of LEADING, LEFT, CENTER, RIGHT, TRAILING

AlignmentHighlighter

public AlignmentHighlighter(HighlightPredicate predicate)
Instantiates a FontHighlighter with the given HighlightPredicate and default horizontal alignement.

Parameters:
predicate - the HighlightPredicate to use, may be null to default to ALWAYS.

AlignmentHighlighter

public AlignmentHighlighter(HighlightPredicate predicate,
                            int alignment)
Instantiates a FontHighlighter with the given HighlightPredicate and null Font.

Parameters:
predicate - the HighlightPredicate to use, may be null to default to ALWAYS.
alignment - the horizontal alignment to use.
Throws:
java.lang.IllegalArgumentException - if not one of the constants allowed as horizontal alignment, that is one of LEADING, LEFT, CENTER, RIGHT, TRAILING
Method Detail

getHorizontalAlignment

public int getHorizontalAlignment()
Returns the alignment which is applied.

Returns:
the alignment

setHorizontalAlignment

public void setHorizontalAlignment(int alignment)
Sets the horizontal alignment to apply.

Parameters:
alignment - the horizontal alignment to set
Throws:
java.lang.IllegalArgumentException - if not one of the constants allowed as horizontal alignment, that is one of LEADING, LEFT, CENTER, RIGHT, TRAILING

doHighlight

protected java.awt.Component doHighlight(java.awt.Component renderer,
                                         ComponentAdapter adapter)
Apply the highlights.

Implemented to set the horizontal alignement of the rendering component.

Specified by:
doHighlight in class AbstractHighlighter
Parameters:
renderer - the cell renderer component that is to be decorated
adapter - the ComponentAdapter for this decorate operation
See Also:
AbstractHighlighter.highlight(Component, ComponentAdapter)

canHighlight

protected boolean canHighlight(java.awt.Component component,
                               ComponentAdapter adapter)
Subclasses may override to further limit the highlighting based on Highlighter state, f.i. a PainterHighlighter can only be applied to PainterAware components.

This implementation returns true always.

Implemented to return true for components of type JLabel, AbstractButton or JTextField, false otherwise.

Overrides:
canHighlight in class AbstractHighlighter
Returns:
a boolean indication if the adapter can be highlighted based general state. This implementation returns true always.