Class ContentChange
java.lang.Object
jfx.incubator.scene.control.richtext.model.ContentChange
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
.......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 Summary
Modifier and TypeMethodDescriptionint
The number of characters added at the beginning of the existing paragraph which contains the end position.int
The number of characters added at the end of the paragraph which contains the start position.getEnd()
Returns the end position.int
The number of whole paragraphs inserted.getStart()
Returns the start position.boolean
isEdit()
Determines whether the change is an edit (true
) or affects styling only (false
).static ContentChange
Creates the content change event which represents an edit.static ContentChange
ofStyleChange
(TextPos start, TextPos end) Creates the content change event which represents a styling update.
-
Method Details
-
getStart
-
getEnd
-
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 positionend
- the end positioncharsAddedTop
- the number of characters appended to the paragraph containing the start positionlinesAdded
- the number of full paragraphs insertedcharsAddedBottom
- the number of characters inserted at the beginning of the paragraph containing the end position- Returns:
- the change instance
-
ofStyleChange
Creates the content change event which represents a styling update.- Parameters:
start
- the start positionend
- the end position- Returns:
- the change instance
-