com.jivesoftware.spark.component.spelling
Class BackgroundChecker.ZigZagHighlightPainter

java.lang.Object
  extended bycom.jivesoftware.spark.component.spelling.BackgroundChecker.ZigZagHighlightPainter
All Implemented Interfaces:
javax.swing.text.Highlighter.HighlightPainter
Enclosing class:
BackgroundChecker

protected class BackgroundChecker.ZigZagHighlightPainter
extends java.lang.Object
implements javax.swing.text.Highlighter.HighlightPainter

HighlightPainter that underlines highlighted text with a zig-zag line.


Field Summary
protected  java.awt.Color color
          Color used to paint the zig-zag line.
 
Constructor Summary
BackgroundChecker.ZigZagHighlightPainter()
          Constructor.
BackgroundChecker.ZigZagHighlightPainter(java.awt.Color c)
          Construct a new ZigZagHighlightPainter.
 
Method Summary
 java.awt.Color getColor()
          Obtain the color used to highlight text.
 void paint(java.awt.Graphics g, int start, int end, java.awt.Shape bounds, javax.swing.text.JTextComponent component)
          Paint the highlight.
 void setColor(java.awt.Color c)
          Change the color used to highlight text.
protected  void zigzag(java.awt.Graphics g, int xStart, int xEnd, int y)
          Draw a zig-zag line.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

color

protected java.awt.Color color
Color used to paint the zig-zag line.

Constructor Detail

BackgroundChecker.ZigZagHighlightPainter

public BackgroundChecker.ZigZagHighlightPainter(java.awt.Color c)
Construct a new ZigZagHighlightPainter.

Parameters:
c - The color to use when highlighting.

BackgroundChecker.ZigZagHighlightPainter

public BackgroundChecker.ZigZagHighlightPainter()
Constructor.

Method Detail

getColor

public java.awt.Color getColor()
Obtain the color used to highlight text.

Returns:
Color used to highlight text.

paint

public void paint(java.awt.Graphics g,
                  int start,
                  int end,
                  java.awt.Shape bounds,
                  javax.swing.text.JTextComponent component)
Paint the highlight. This method is called by the text component's Highlighter when it's necessary to paint the highlight. Adapted from an example in by Eckstein, Loy, and Wood.

Specified by:
paint in interface javax.swing.text.Highlighter.HighlightPainter
Parameters:
g - Graphics context to use for painting
start - Offset of the first character in the component's text to highlight
end - Offset of the last character in the component's text to highlight
bounds - Defines the bounds of the component the painter must paint within.
component - The text component to highlight.

setColor

public void setColor(java.awt.Color c)
Change the color used to highlight text.

Parameters:
c - The new color.

zigzag

protected void zigzag(java.awt.Graphics g,
                      int xStart,
                      int xEnd,
                      int y)
Draw a zig-zag line.

Parameters:
g - The graphics context to use when drawing.
xStart - The leftmost part of the line
xEnd - The rightmost part of the line
y - The vertical position of the line.