Class 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
    • 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 the Paint (usually a java.awt.Color) used to paint this highlight.
      void setPaintBorder​(boolean paint)
      Toggles whether a border is painted around highlights.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • DEFAULT_HIGHLIGHT_COLOR

        public static final java.awt.Color DEFAULT_HIGHLIGHT_COLOR
        The default highlight color.
      • borderColor

        private java.awt.Color borderColor
      • paintBorder

        private boolean paintBorder
    • Constructor Detail

      • SmartHighlightPainter

        public SmartHighlightPainter()
        Creates a highlight painter using a default color.
      • SmartHighlightPainter

        public SmartHighlightPainter​(java.awt.Paint paint)
        Constructor.
        Parameters:
        paint - The color or paint to use for this painter.
    • Method Detail

      • 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 class ChangeableHighlightPainter
        Parameters:
        g - the graphics context
        p0 - the starting model offset >= 0
        p1 - the ending model offset >= offs1
        viewBounds - the bounding box of the view, which is not necessarily the region to paint.
        c - the editor
        view - View painting for
        Returns:
        region drawing occurred in
      • 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)