Package org.fife.ui.rtextarea
Class SmartHighlightPainter
- java.lang.Object
-
- javax.swing.text.LayeredHighlighter.LayerPainter
-
- org.fife.ui.rtextarea.ChangeableHighlightPainter
-
- org.fife.ui.rtextarea.SmartHighlightPainter
-
- All Implemented Interfaces:
java.io.Serializable
,javax.swing.text.Highlighter.HighlightPainter
public class SmartHighlightPainter extends ChangeableHighlightPainter
A "smart" highlight painter designed for use in RSyntaxTextArea. Adds the following features:- Rendered highlights don't "grow" when users append text to the "end" of them. This is implemented by assuming that the highlights themselves specify their end offset as one offset "too short". This behavior is baked into various RSTA highlights (mark all, mark occurrences, etc.).
- Ability to paint a border line around highlights.
- Version:
- 1.0
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description private java.awt.Color
borderColor
static java.awt.Color
DEFAULT_HIGHLIGHT_COLOR
The default highlight color.private boolean
paintBorder
-
Constructor Summary
Constructors Constructor Description SmartHighlightPainter()
Creates a highlight painter using a default color.SmartHighlightPainter(java.awt.Paint paint)
Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
getPaintBorder()
Returns whether a border is painted around marked occurrences.java.awt.Shape
paintLayer(java.awt.Graphics g, int p0, int p1, java.awt.Shape viewBounds, javax.swing.text.JTextComponent c, javax.swing.text.View view)
Paints a portion of a highlight.void
setPaint(java.awt.Paint paint)
Sets thePaint
(usually ajava.awt.Color
) used to paint this highlight.void
setPaintBorder(boolean paint)
Toggles whether a border is painted around highlights.-
Methods inherited from class org.fife.ui.rtextarea.ChangeableHighlightPainter
getAlpha, getPaint, getRoundedEdges, paint, setAlpha, setRoundedEdges
-
-
-
-
Method Detail
-
getPaintBorder
public boolean getPaintBorder()
Returns whether a border is painted around marked occurrences.- Returns:
- Whether a border is painted.
- See Also:
setPaintBorder(boolean)
,ChangeableHighlightPainter.getPaint()
-
paintLayer
public java.awt.Shape paintLayer(java.awt.Graphics g, int p0, int p1, java.awt.Shape viewBounds, javax.swing.text.JTextComponent c, javax.swing.text.View view)
Description copied from class:ChangeableHighlightPainter
Paints a portion of a highlight.- Overrides:
paintLayer
in classChangeableHighlightPainter
- Parameters:
g
- the graphics contextp0
- the starting model offset >= 0p1
- the ending model offset >= offs1viewBounds
- the bounding box of the view, which is not necessarily the region to paint.c
- the editorview
- View painting for- Returns:
- region drawing occurred in
-
setPaint
public void setPaint(java.awt.Paint paint)
Description copied from class:ChangeableHighlightPainter
Sets thePaint
(usually ajava.awt.Color
) used to paint this highlight.- Overrides:
setPaint
in classChangeableHighlightPainter
- Parameters:
paint
- The newPaint
.- See Also:
ChangeableHighlightPainter.getPaint()
-
setPaintBorder
public void setPaintBorder(boolean paint)
Toggles whether a border is painted around highlights.- Parameters:
paint
- Whether to paint a border.- See Also:
getPaintBorder()
,setPaint(Paint)
-
-