Package org.fxmisc.richtext.model
Class GenericEditableStyledDocument<PS,SEG,S>
- java.lang.Object
-
- org.fxmisc.richtext.model.GenericEditableStyledDocument<PS,SEG,S>
-
- Type Parameters:
PS
- type of style that can be applied to paragraphs (e.g.TextFlow
.SEG
- type of segment used inParagraph
. Can be onlytext
(plain or styled) or a type that combines text and otherNode
s viaEither<String, Node>
.S
- type of style that can be applied to a segment.
- All Implemented Interfaces:
EditableStyledDocument<PS,SEG,S>
,StyledDocument<PS,SEG,S>
,TwoDimensional
public final class GenericEditableStyledDocument<PS,SEG,S> extends java.lang.Object implements EditableStyledDocument<PS,SEG,S>
Provides a basic implementation ofEditableStyledDocument
while still allowing a developer to specify its generics. SeeSimpleEditableStyledDocument
for a version that specifies its segment style toString
.
-
-
Property Summary
Properties Type Property Description SuspendableNo
beingUpdated
Val<java.lang.Integer>
length
Val<java.lang.String>
text
-
Properties inherited from interface org.fxmisc.richtext.model.EditableStyledDocument
beingUpdated, length, text
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.fxmisc.richtext.model.TwoDimensional
TwoDimensional.Bias, TwoDimensional.Position
-
-
Constructor Summary
Constructors Constructor Description GenericEditableStyledDocument(Paragraph<PS,SEG,S> initialParagraph)
Creates anEditableStyledDocument
with given paragraph as its initial contentGenericEditableStyledDocument(ReadOnlyStyledDocument<PS,SEG,S> initialContent)
Creates anEditableStyledDocument
with the given document as its initial contentGenericEditableStyledDocument(PS initialParagraphStyle, S initialStyle, SegmentOps<SEG,S> segmentOps)
Creates an emptyEditableStyledDocument
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description SuspendableNo
beingUpdatedProperty()
StyledDocument<PS,SEG,S>
concat(StyledDocument<PS,SEG,S> that)
int
getLength()
Gets the value of the property length.LiveList<Paragraph<PS,SEG,S>>
getParagraphs()
java.lang.String
getText()
boolean
isBeingUpdated()
int
length()
Val<java.lang.Integer>
lengthProperty()
EventStream<java.util.List<RichTextChange<PS,SEG,S>>>
multiRichChanges()
Returns anEventStream
that emits aList
ofRichTextChange
s every time a change is made to this document, even when such a change does not modify the underlying document in any way.TwoDimensional.Position
offsetToPosition(int offset, TwoDimensional.Bias bias)
Creates a two dimensional position in some entity (e.g.TwoDimensional.Position
position(int major, int minor)
Creates a two dimensional position in some entity (e.g.void
replace(int start, int end, StyledDocument<PS,SEG,S> replacement)
Replaces the portion of this document"from..to"
with the givenreplacement
.void
replaceMulti(java.util.List<Replacement<PS,SEG,S>> replacements)
Replaces multiple portions of this document in one update.void
setParagraphStyle(int paragraphIndex, PS style)
Sets the given paragraph to the given paragraph stylevoid
setStyle(int paragraphIndex, int fromCol, int toCol, S style)
Sets the given range "fromCol..toCol" in the given paragraph to the given stylevoid
setStyle(int from, int to, S style)
Sets the style of all segments in the given "from..to" range to the given style.void
setStyle(int paragraphIndex, S style)
Sets all segments in the given paragraph to the given stylevoid
setStyleSpans(int paragraphIndex, int from, StyleSpans<? extends S> styleSpans)
Replaces the style spans for the given range"from..(from + styleSpans.length())"
in the given paragraph with the given style spansvoid
setStyleSpans(int from, StyleSpans<? extends S> styleSpans)
Replaces the style spans for the given range"from..(from + styleSpans.length())"
with the given style spansReadOnlyStyledDocument<PS,SEG,S>
snapshot()
Read-only snapshot of the current state of this document.StyledDocument<PS,SEG,S>
subSequence(int start, int end)
Val<java.lang.String>
textProperty()
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.fxmisc.richtext.model.EditableStyledDocument
beingUpdatedProperty, getLength, getParagraphs, isBeingUpdated, lengthProperty, multiPlainChanges, multiRichChanges, plainChanges, replace, replace, replaceMulti, richChanges, setParagraphStyle, setStyle, setStyle, setStyle, setStyleSpans, setStyleSpans, snapshot, textProperty
-
Methods inherited from interface org.fxmisc.richtext.model.StyledDocument
charAt, concat, getAbsolutePosition, getParagraph, getParagraphLength, getParagraphStyle, getParagraphStyleAtPosition, getStyleAtPosition, getStyleAtPosition, getStyleOfChar, getStyleOfChar, getStyleRangeAtPosition, getStyleRangeAtPosition, getStyleSpans, getStyleSpans, getStyleSpans, getText, getText, getText, getText, length, subDocument, subSequence, subSequence
-
Methods inherited from interface org.fxmisc.richtext.model.TwoDimensional
offsetToPosition, position
-
-
-
-
Property Detail
-
text
public Val<java.lang.String> textProperty
- Specified by:
textProperty
in interfaceEditableStyledDocument<PS,SEG,S>
-
length
public Val<java.lang.Integer> lengthProperty
- Specified by:
lengthProperty
in interfaceEditableStyledDocument<PS,SEG,S>
- See Also:
EditableStyledDocument.getLength()
-
beingUpdated
public final SuspendableNo beingUpdatedProperty
- Specified by:
beingUpdatedProperty
in interfaceEditableStyledDocument<PS,SEG,S>
-
-
Constructor Detail
-
GenericEditableStyledDocument
public GenericEditableStyledDocument(ReadOnlyStyledDocument<PS,SEG,S> initialContent)
Creates anEditableStyledDocument
with the given document as its initial content
-
GenericEditableStyledDocument
public GenericEditableStyledDocument(Paragraph<PS,SEG,S> initialParagraph)
Creates anEditableStyledDocument
with given paragraph as its initial content
-
GenericEditableStyledDocument
public GenericEditableStyledDocument(PS initialParagraphStyle, S initialStyle, SegmentOps<SEG,S> segmentOps)
Creates an emptyEditableStyledDocument
-
-
Method Detail
-
multiRichChanges
public EventStream<java.util.List<RichTextChange<PS,SEG,S>>> multiRichChanges()
Description copied from interface:EditableStyledDocument
Returns anEventStream
that emits aList
ofRichTextChange
s every time a change is made to this document, even when such a change does not modify the underlying document in any way. The emitted list will only have one item in it unless one usedEditableStyledDocument.replaceMulti(List)
.- Specified by:
multiRichChanges
in interfaceEditableStyledDocument<PS,SEG,S>
-
getText
public java.lang.String getText()
- Specified by:
getText
in interfaceStyledDocument<PS,SEG,S>
-
textProperty
public Val<java.lang.String> textProperty()
- Specified by:
textProperty
in interfaceEditableStyledDocument<PS,SEG,S>
-
getLength
public int getLength()
Description copied from interface:EditableStyledDocument
Gets the value of the property length.- Specified by:
getLength
in interfaceEditableStyledDocument<PS,SEG,S>
-
lengthProperty
public Val<java.lang.Integer> lengthProperty()
- Specified by:
lengthProperty
in interfaceEditableStyledDocument<PS,SEG,S>
- See Also:
EditableStyledDocument.getLength()
-
length
public int length()
- Specified by:
length
in interfaceStyledDocument<PS,SEG,S>
-
getParagraphs
public LiveList<Paragraph<PS,SEG,S>> getParagraphs()
- Specified by:
getParagraphs
in interfaceEditableStyledDocument<PS,SEG,S>
- Specified by:
getParagraphs
in interfaceStyledDocument<PS,SEG,S>
-
snapshot
public ReadOnlyStyledDocument<PS,SEG,S> snapshot()
Description copied from interface:EditableStyledDocument
Read-only snapshot of the current state of this document.- Specified by:
snapshot
in interfaceEditableStyledDocument<PS,SEG,S>
-
beingUpdatedProperty
public final SuspendableNo beingUpdatedProperty()
- Specified by:
beingUpdatedProperty
in interfaceEditableStyledDocument<PS,SEG,S>
-
isBeingUpdated
public final boolean isBeingUpdated()
- Specified by:
isBeingUpdated
in interfaceEditableStyledDocument<PS,SEG,S>
-
position
public TwoDimensional.Position position(int major, int minor)
Description copied from interface:TwoDimensional
Creates a two dimensional position in some entity (e.g. area, list of lists, list of some object with length) where themajor
value is the index within the outer list) and theminor
value is either the index within the inner list or some amount of length in a list of objects that have length.- Specified by:
position
in interfaceTwoDimensional
-
offsetToPosition
public TwoDimensional.Position offsetToPosition(int offset, TwoDimensional.Bias bias)
Description copied from interface:TwoDimensional
Creates a two dimensional position in some entity (e.g. area, list of lists, list of some object with length) where theoffset
value is an absolute position in that entity.- Specified by:
offsetToPosition
in interfaceTwoDimensional
-
replaceMulti
public void replaceMulti(java.util.List<Replacement<PS,SEG,S>> replacements)
Description copied from interface:EditableStyledDocument
Replaces multiple portions of this document in one update.- Specified by:
replaceMulti
in interfaceEditableStyledDocument<PS,SEG,S>
-
replace
public void replace(int start, int end, StyledDocument<PS,SEG,S> replacement)
Description copied from interface:EditableStyledDocument
Replaces the portion of this document"from..to"
with the givenreplacement
.- Specified by:
replace
in interfaceEditableStyledDocument<PS,SEG,S>
- Parameters:
start
- the absolute position in the document that starts the portion to replaceend
- the absolute position in the document that ends the portion to replacereplacement
- the document that replaces the removed portion of this document
-
setStyle
public void setStyle(int from, int to, S style)
Description copied from interface:EditableStyledDocument
Sets the style of all segments in the given "from..to" range to the given style.- Specified by:
setStyle
in interfaceEditableStyledDocument<PS,SEG,S>
- Parameters:
from
- the absolute position in the document that starts the range to re-styleto
- the absolute position in the document that ends the range to re-style
-
setStyle
public void setStyle(int paragraphIndex, S style)
Description copied from interface:EditableStyledDocument
Sets all segments in the given paragraph to the given style- Specified by:
setStyle
in interfaceEditableStyledDocument<PS,SEG,S>
-
setStyle
public void setStyle(int paragraphIndex, int fromCol, int toCol, S style)
Description copied from interface:EditableStyledDocument
Sets the given range "fromCol..toCol" in the given paragraph to the given style- Specified by:
setStyle
in interfaceEditableStyledDocument<PS,SEG,S>
-
setStyleSpans
public void setStyleSpans(int from, StyleSpans<? extends S> styleSpans)
Description copied from interface:EditableStyledDocument
Replaces the style spans for the given range"from..(from + styleSpans.length())"
with the given style spans- Specified by:
setStyleSpans
in interfaceEditableStyledDocument<PS,SEG,S>
-
setStyleSpans
public void setStyleSpans(int paragraphIndex, int from, StyleSpans<? extends S> styleSpans)
Description copied from interface:EditableStyledDocument
Replaces the style spans for the given range"from..(from + styleSpans.length())"
in the given paragraph with the given style spans- Specified by:
setStyleSpans
in interfaceEditableStyledDocument<PS,SEG,S>
-
setParagraphStyle
public void setParagraphStyle(int paragraphIndex, PS style)
Description copied from interface:EditableStyledDocument
Sets the given paragraph to the given paragraph style- Specified by:
setParagraphStyle
in interfaceEditableStyledDocument<PS,SEG,S>
-
concat
public StyledDocument<PS,SEG,S> concat(StyledDocument<PS,SEG,S> that)
- Specified by:
concat
in interfaceStyledDocument<PS,SEG,S>
-
subSequence
public StyledDocument<PS,SEG,S> subSequence(int start, int end)
- Specified by:
subSequence
in interfaceStyledDocument<PS,SEG,S>
-
-