Class RichBlocks

java.lang.Object
com.codename1.ui.editor.RichBlocks

public final class RichBlocks extends Object
The per paragraph block attribute model for the pure rich text editor. Each logical line (paragraph, delimited by newlines) has a BlockAttr describing its block type (paragraph / heading / preformatted / blockquote), text alignment, list membership and indentation. The model is kept in lockstep with the paragraph structure through #applyEdit.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static final class 
    A single paragraph's block attributes.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
    Center alignment.
    static final int
    Left alignment.
    static final int
    Right alignment.
    static final int
    Block type: a block quote.
    static final int
    Block type: heading level 1 through 6 are H1..H1 + 5.
    static final int
    Not a list item.
    static final int
    An ordered (numbered) list item.
    static final int
    An unordered (bulleted) list item.
    static final int
    Block type: a normal paragraph.
    static final int
    Block type: preformatted text.
  • Constructor Summary

    Constructors
    Constructor
    Description
    RichBlocks(int paragraphCount)
    Creates a model with the given paragraph count, all default paragraphs.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    applyEdit(int startParagraph, int removedNewlines, int addedNewlines)
    Keeps the model in sync with a text edit that changed the paragraph structure.
    int
    Returns the number of paragraphs.
    get(int paragraph)
    Returns the block attributes for the given paragraph (clamped to the valid range).
    void
    reset(int paragraphCount)
    Resets the model to the given paragraph count, all default paragraphs.

    Methods inherited from class Object

    clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • PARAGRAPH

      public static final int PARAGRAPH
      Block type: a normal paragraph.
      See Also:
    • H1

      public static final int H1
      Block type: heading level 1 through 6 are H1..H1 + 5.
      See Also:
    • PRE

      public static final int PRE
      Block type: preformatted text.
      See Also:
    • BLOCKQUOTE

      public static final int BLOCKQUOTE
      Block type: a block quote.
      See Also:
    • ALIGN_LEFT

      public static final int ALIGN_LEFT
      Left alignment.
      See Also:
    • ALIGN_CENTER

      public static final int ALIGN_CENTER
      Center alignment.
      See Also:
    • ALIGN_RIGHT

      public static final int ALIGN_RIGHT
      Right alignment.
      See Also:
    • LIST_NONE

      public static final int LIST_NONE
      Not a list item.
      See Also:
    • LIST_ORDERED

      public static final int LIST_ORDERED
      An ordered (numbered) list item.
      See Also:
    • LIST_UNORDERED

      public static final int LIST_UNORDERED
      An unordered (bulleted) list item.
      See Also:
  • Constructor Details

    • RichBlocks

      public RichBlocks(int paragraphCount)
      Creates a model with the given paragraph count, all default paragraphs.
  • Method Details

    • reset

      public void reset(int paragraphCount)
      Resets the model to the given paragraph count, all default paragraphs.
    • count

      public int count()
      Returns the number of paragraphs.
    • get

      public RichBlocks.BlockAttr get(int paragraph)
      Returns the block attributes for the given paragraph (clamped to the valid range).
    • applyEdit

      public void applyEdit(int startParagraph, int removedNewlines, int addedNewlines)

      Keeps the model in sync with a text edit that changed the paragraph structure.

      Parameters
      • startParagraph: the paragraph containing the edit offset

      • removedNewlines: number of newlines in the removed text (paragraphs merged away)

      • addedNewlines: number of newlines in the inserted text (paragraphs created)