edu.rice.cs.util.swing
Class HighlightManager
java.lang.Object
|
+--edu.rice.cs.util.swing.HighlightManager
- public class HighlightManager
- extends Object
Inner 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. |
Field Summary |
private JTextComponent |
_component
The component necessary for creating positions in in the document, which is also
contained within this component. |
private gj.util.Vector |
_highlights
An unsorted Vector of Stack, each of which corresponds to a unique
region in the document. |
Methods inherited from class java.lang.Object |
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait |
_highlights
private gj.util.Vector _highlights
- An unsorted Vector of Stack, each of which corresponds to a unique
region in the document. All HighlightInfo objects within a given stack must correspond
to the same region but must have unique Highlighter.HighlightPainters.
Each stack is ordered so the most recent highlight is at the top.
_component
private JTextComponent _component
- The component necessary for creating positions in in the document, which is also
contained within this component.
HighlightManager
public HighlightManager(JTextComponent jtc)
- Constructor
- Parameters:
jtc
- the component whose document will have positions created therein.
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
_getStackAt
private gj.util.Stack _getStackAt(int from,
int to)
- Returning the Stack corresponding to the given region in the document, or null
if there is none. Requires every Stack in the vector to have a unique region.
- Parameters:
from
- the starting offsetto
- the ending offset- Returns:
- the corresponding Stack, or null
removeHighlight
public void removeHighlight(int startOffset,
int endOffset,
Highlighter.HighlightPainter p)
- Convenience method for removing 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