Class ContentChange

java.lang.Object
jfx.incubator.scene.control.richtext.model.ContentChange

public abstract class ContentChange extends Object
Contains information about StyledTextModel content change.

This class represents two kinds of changes made to the model: one that modifies the textual content and embedded Nodes, and one that only changes styling of the content.

A content change can be though of as a replacement of content between the two positions start and end with a different styled content (or no content). The change object does not include the actual content, but only the information about inserted symbols:

  • the number of characters inserted to the first affected paragraph
  • the number of complete paragraphs inserted
  • the number of characters inserted into the first paragraph following the inserted lines
The following diagram illustrates the inserted content relative to the start position (S) and the end position (E):
 .......STTTTTTT
 AAAAAAAAAAAAAAA
 AAAAAAAAAAAAAAA
 BBBE...........
 
Where T are the characters inserted following the start position, A are the inserted complete paragraphs, and B are the characters inserted at the beginning of the paragraph that contains the end position.
Since:
24
  • Method Details

    • getStart

      public TextPos getStart()
      Returns the start position.
      Returns:
      the start position
    • getEnd

      public TextPos getEnd()
      Returns the end position.
      Returns:
      the end position
    • getCharsAddedTop

      public int getCharsAddedTop()
      The number of characters added at the end of the paragraph which contains the start position.
      Returns:
      the number of characters inserted
    • getLinesAdded

      public int getLinesAdded()
      The number of whole paragraphs inserted.
      Returns:
      the number of paragraphs
    • getCharsAddedBottom

      public int getCharsAddedBottom()
      The number of characters added at the beginning of the existing paragraph which contains the end position.
      Returns:
      the number of characters
    • isEdit

      public boolean isEdit()
      Determines whether the change is an edit (true) or affects styling only (false).
      Returns:
      true if change is an edit
    • ofEdit

      public static ContentChange ofEdit(TextPos start, TextPos end, int charsAddedTop, int linesAdded, int charsAddedBottom)
      Creates the content change event which represents an edit.
      Parameters:
      start - the start position
      end - the end position
      charsAddedTop - the number of characters appended to the paragraph containing the start position
      linesAdded - the number of full paragraphs inserted
      charsAddedBottom - the number of characters inserted at the beginning of the paragraph containing the end position
      Returns:
      the change instance
    • ofStyleChange

      public static ContentChange ofStyleChange(TextPos start, TextPos end)
      Creates the content change event which represents a styling update.
      Parameters:
      start - the start position
      end - the end position
      Returns:
      the change instance