edu.rice.cs.util.swing
Class HighlightManager

java.lang.Object
  extended by edu.rice.cs.util.swing.HighlightManager

public class HighlightManager
extends Object

This class has synchronized public methods because it is accessed outside of the event thread.


Nested Class Summary
 class HighlightManager.HighlightInfo
          The public inner class defining a "smart" highlight, which can return the value of its start and end offsets for comparison with other highlights.
 
Constructor Summary
HighlightManager(JTextComponent jtc)
          Constructor
 
Method Summary
 HighlightManager.HighlightInfo addHighlight(int startOffset, int endOffset, Highlighter.HighlightPainter p)
          Adds a highlight using the supplied painter to the vector element(Stack) that exactly corresponds to the specified bounds.
 void removeHighlight(HighlightManager.HighlightInfo newLite)
          Removes a given highlight (HighlightInfo) from the highlighter
 void removeHighlight(int startOffset, int endOffset, Highlighter.HighlightPainter p)
          Removes a highlight with the specified start/end offsets and the given painter.
 int size()
          Size of highlight stack; used only for unit testing
 String toString()
          Overrides to toString() to support unit testing
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

HighlightManager

public HighlightManager(JTextComponent jtc)
Constructor

Parameters:
jtc - the component whose document will have positions created therein.
Method Detail

toString

public String toString()
Overrides to toString() to support unit testing

Overrides:
toString in class Object

size

public int size()
Size of highlight stack; used only for unit testing


addHighlight

public HighlightManager.HighlightInfo addHighlight(int startOffset,
                                                   int endOffset,
                                                   Highlighter.HighlightPainter p)
Adds a highlight using the supplied painter to the vector element(Stack) that exactly corresponds to the specified bounds. The most recently added highlights over a given range appear on top of the older highlights. All highlights in a given range(Stack) must be unique, that is, each must use a different painter--redundant highlights are shifted to the top of the stack, but not added twice.

Parameters:
startOffset - the offset at which the highlight is to begin.
endOffset - the offset at which the highlight is to end.
p - the Highlighter.HighlightPainter for painting
Returns:
HighlightInfo the HighlightInfo object, for keeping a tag of a given highlight

removeHighlight

public void removeHighlight(int startOffset,
                            int endOffset,
                            Highlighter.HighlightPainter p)
Removes a highlight with the specified start/end offsets and the given painter.

Parameters:
startOffset - the offset at which the desired highlight should start.
endOffset - the offset at which the desired highlight shoud end.
p - the Highlighter.HighlightPainter for painting

removeHighlight

public void removeHighlight(HighlightManager.HighlightInfo newLite)
Removes a given highlight (HighlightInfo) from the highlighter

Parameters:
newLite - the HighlightInfo object corresponding to the highlight needed to be removed