Jitsi: the OpenSource Java VoIP and Instant Messaging client.

net.java.sip.communicator.plugin.spellcheck
Class DocUnderliner

java.lang.Object
  extended by net.java.sip.communicator.plugin.spellcheck.DocUnderliner
All Implemented Interfaces:
EventListener, DocumentListener

abstract class DocUnderliner
extends Object
implements DocumentListener

Notifies subclasses when words are changed and lets them decide if text should be underlined with a red squiggle. Text appended to the end isn't formatted until the word's completed.

Author:
Damian Johnson

Constructor Summary
DocUnderliner(Highlighter docHighlighter)
           
 
Method Summary
 void changedUpdate(DocumentEvent e)
           
 void format(Word word)
          Formats the word with the appropriate underlining (or lack thereof).
(package private) abstract  int getCaretPosition()
          Provides the index of the character the cursor is in front of.
 CaretListener getEndChecker()
          Provides a listener that prompts the last word to be checked when the cursor moves away from it.
(package private) abstract  boolean getFormatting(String word)
          Queries to see if a word should be underlined.
 void insertUpdate(DocumentEvent event)
           
static void main(String[] args)
           
(package private) abstract  void promptRepaint()
          Prompts the text field to repaint.
 void removeUpdate(DocumentEvent event)
           
 void reset(String message)
          Clears underlining and re-evaluates message's contents
 void setEnabled(boolean enable, String message)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DocUnderliner

DocUnderliner(Highlighter docHighlighter)
Method Detail

getFormatting

abstract boolean getFormatting(String word)
Queries to see if a word should be underlined. This is called on every internal change and whenever a word's completed so it should be a lightweight process.

Parameters:
word - word to be checked
Returns:
true if the word should be underlined, false otherwise

getCaretPosition

abstract int getCaretPosition()
Provides the index of the character the cursor is in front of.

Returns:
index of caret

promptRepaint

abstract void promptRepaint()
Prompts the text field to repaint.


main

public static void main(String[] args)

insertUpdate

public void insertUpdate(DocumentEvent event)
Specified by:
insertUpdate in interface DocumentListener

removeUpdate

public void removeUpdate(DocumentEvent event)
Specified by:
removeUpdate in interface DocumentListener

changedUpdate

public void changedUpdate(DocumentEvent e)
Specified by:
changedUpdate in interface DocumentListener

getEndChecker

public CaretListener getEndChecker()
Provides a listener that prompts the last word to be checked when the cursor moves away from it.

Returns:
listener for caret position that formats last word when appropriate

format

public void format(Word word)
Formats the word with the appropriate underlining (or lack thereof).

Parameters:
word - word to be formatted

setEnabled

public void setEnabled(boolean enable,
                       String message)

reset

public void reset(String message)
Clears underlining and re-evaluates message's contents

Parameters:
message - textual contents of document

Jitsi: the OpenSource Java VoIP and Instant Messaging client.

Jitsi, the OpenSource Java VoIP and Instant Messaging client.
Distributable under LGPL license.