SmartHighlightPainter
Date: 2017-02-11

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.
  See Also:
    Serialized Form

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `SmartHighlightPainter()` Creates a highlight painter that defaults to blue.
    `SmartHighlightPainter(java.awt.Paint paint)` Constructor.

  - ### Method Summary

    Methods
    Modifier and Type | Method and 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 org.fife.ui.rtextarea.ChangeableHighlightPainter

      `getAlpha, getPaint, getRoundedEdges, paint, setAlpha, setRoundedEdges`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### SmartHighlightPainter

          public SmartHighlightPainter()

      Creates a highlight painter that defaults to blue.

    - #### SmartHighlightPainter

          public SmartHighlightPainter(java.awt.Paint paint)

      Constructor.
      Parameters:
        `paint` - The color or paint to use for this painter.

  - ### 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)

      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

    - #### setPaint

          public void setPaint(java.awt.Paint paint)

      Sets the `Paint` (usually a `java.awt.Color`) used to paint this highlight.
      Overrides:
        `setPaint` in class `ChangeableHighlightPainter`
      Parameters:
        `paint` - The new `Paint`.
      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)`