Class Proofreader

java.lang.Object
com.codename1.spellcheck.Proofreader

public final class Proofreader extends Object

Spelling and grammar checks together, as a DocumentView uses them to underline problems. Results are remembered per text, so a paragraph is checked again only when it changes.

DocumentModel model = new DocumentModel(new Document());
model.insertBlock(0, new Paragraph(model.newId('p'), RichText.of("Quarterly review")));
Proofreader p = new Proofreader(SpellChecker.forLanguage("en_US"), GrammarChecker.english());
DocumentView view = new DocumentView(model);
view.setProofreader(p);
Form form = new Form("Proofreading", new BorderLayout());
form.add(BorderLayout.CENTER, view);
form.show();
  • Constructor Details

    • Proofreader

      public Proofreader(SpellChecker spelling, GrammarChecker grammar)

      Creates a proofreader; either checker may be null.

      Parameters
      • spelling: the spell checker, or null

      • grammar: the grammar checker, or null

  • Method Details

    • getSpellChecker

      public SpellChecker getSpellChecker()

      The spell checker.

      Returns

      the checker, or null

    • getGrammarChecker

      public GrammarChecker getGrammarChecker()

      The grammar checker.

      Returns

      the checker, or null

    • check

      public List<ProofIssue> check(String text)

      The problems in a text, by position, without spelling suggestions.

      Parameters
      • text: the text, typically a paragraph
      Returns

      the issues; do not modify the list

    • issueAt

      public ProofIssue issueAt(String text, int offset, int max)

      The problem at a character of a text, with suggestions filled in for a misspelling.

      Parameters
      • text: the text

      • offset: the character

      • max: the most suggestions

      Returns

      the issue, or null when there is none there

    • invalidate

      public void invalidate()
      Forgets remembered results, after the user dictionary or the rules changed.