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 otherNodes 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 Object implements EditableStyledDocument<PS,SEG,S>
Provides a basic implementation ofEditableStyledDocumentwhile still allowing a developer to specify its generics. SeeSimpleEditableStyledDocumentfor a version that specifies its segment style toString.
-
-
Property Summary
Properties Type Property Description SuspendableNobeingUpdatedVal<Integer>lengthVal<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 anEditableStyledDocumentwith given paragraph as its initial contentGenericEditableStyledDocument(ReadOnlyStyledDocument<PS,SEG,S> initialContent)Creates anEditableStyledDocumentwith 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 SuspendableNobeingUpdatedProperty()StyledDocument<PS,SEG,S>concat(StyledDocument<PS,SEG,S> that)intgetLength()Gets the value of the property length.LiveList<Paragraph<PS,SEG,S>>getParagraphs()StringgetText()booleanisBeingUpdated()intlength()Val<Integer>lengthProperty()EventStream<List<RichTextChange<PS,SEG,S>>>multiRichChanges()Returns anEventStreamthat emits aListofRichTextChanges every time a change is made to this document, even when such a change does not modify the underlying document in any way.TwoDimensional.PositionoffsetToPosition(int offset, TwoDimensional.Bias bias)Creates a two dimensional position in some entity (e.g.TwoDimensional.Positionposition(int major, int minor)Creates a two dimensional position in some entity (e.g.voidreplace(int start, int end, StyledDocument<PS,SEG,S> replacement)Replaces the portion of this document"from..to"with the givenreplacement.voidreplaceMulti(List<Replacement<PS,SEG,S>> replacements)Replaces multiple portions of this document in one update.voidsetParagraphStyle(int paragraphIndex, PS style)Sets the given paragraph to the given paragraph stylevoidsetStyle(int paragraphIndex, int fromCol, int toCol, S style)Sets the given range "fromCol..toCol" in the given paragraph to the given stylevoidsetStyle(int from, int to, S style)Sets the style of all segments in the given "from..to" range to the given style.voidsetStyle(int paragraphIndex, S style)Sets all segments in the given paragraph to the given stylevoidsetStyleSpans(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 spansvoidsetStyleSpans(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<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<String> textProperty
- Specified by:
textPropertyin interfaceEditableStyledDocument<PS,SEG,S>
-
length
public Val<Integer> lengthProperty
- Specified by:
lengthPropertyin interfaceEditableStyledDocument<PS,SEG,S>- See Also:
EditableStyledDocument.getLength()
-
beingUpdated
public final SuspendableNo beingUpdatedProperty
- Specified by:
beingUpdatedPropertyin interfaceEditableStyledDocument<PS,SEG,S>
-
-
Constructor Detail
-
GenericEditableStyledDocument
public GenericEditableStyledDocument(ReadOnlyStyledDocument<PS,SEG,S> initialContent)
Creates anEditableStyledDocumentwith the given document as its initial content
-
GenericEditableStyledDocument
public GenericEditableStyledDocument(Paragraph<PS,SEG,S> initialParagraph)
Creates anEditableStyledDocumentwith 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<List<RichTextChange<PS,SEG,S>>> multiRichChanges()
Description copied from interface:EditableStyledDocumentReturns anEventStreamthat emits aListofRichTextChanges 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:
multiRichChangesin interfaceEditableStyledDocument<PS,SEG,S>
-
getText
public String getText()
- Specified by:
getTextin interfaceStyledDocument<PS,SEG,S>
-
textProperty
public Val<String> textProperty()
- Specified by:
textPropertyin interfaceEditableStyledDocument<PS,SEG,S>
-
getLength
public int getLength()
Description copied from interface:EditableStyledDocumentGets the value of the property length.- Specified by:
getLengthin interfaceEditableStyledDocument<PS,SEG,S>
-
lengthProperty
public Val<Integer> lengthProperty()
- Specified by:
lengthPropertyin interfaceEditableStyledDocument<PS,SEG,S>- See Also:
EditableStyledDocument.getLength()
-
length
public int length()
- Specified by:
lengthin interfaceStyledDocument<PS,SEG,S>
-
getParagraphs
public LiveList<Paragraph<PS,SEG,S>> getParagraphs()
- Specified by:
getParagraphsin interfaceEditableStyledDocument<PS,SEG,S>- Specified by:
getParagraphsin interfaceStyledDocument<PS,SEG,S>
-
snapshot
public ReadOnlyStyledDocument<PS,SEG,S> snapshot()
Description copied from interface:EditableStyledDocumentRead-only snapshot of the current state of this document.- Specified by:
snapshotin interfaceEditableStyledDocument<PS,SEG,S>
-
beingUpdatedProperty
public final SuspendableNo beingUpdatedProperty()
- Specified by:
beingUpdatedPropertyin interfaceEditableStyledDocument<PS,SEG,S>
-
isBeingUpdated
public final boolean isBeingUpdated()
- Specified by:
isBeingUpdatedin interfaceEditableStyledDocument<PS,SEG,S>
-
position
public TwoDimensional.Position position(int major, int minor)
Description copied from interface:TwoDimensionalCreates a two dimensional position in some entity (e.g. area, list of lists, list of some object with length) where themajorvalue is the index within the outer list) and theminorvalue is either the index within the inner list or some amount of length in a list of objects that have length.- Specified by:
positionin interfaceTwoDimensional
-
offsetToPosition
public TwoDimensional.Position offsetToPosition(int offset, TwoDimensional.Bias bias)
Description copied from interface:TwoDimensionalCreates a two dimensional position in some entity (e.g. area, list of lists, list of some object with length) where theoffsetvalue is an absolute position in that entity.- Specified by:
offsetToPositionin interfaceTwoDimensional
-
replaceMulti
public void replaceMulti(List<Replacement<PS,SEG,S>> replacements)
Description copied from interface:EditableStyledDocumentReplaces multiple portions of this document in one update.- Specified by:
replaceMultiin interfaceEditableStyledDocument<PS,SEG,S>
-
replace
public void replace(int start, int end, StyledDocument<PS,SEG,S> replacement)Description copied from interface:EditableStyledDocumentReplaces the portion of this document"from..to"with the givenreplacement.- Specified by:
replacein 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:EditableStyledDocumentSets the style of all segments in the given "from..to" range to the given style.- Specified by:
setStylein 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:EditableStyledDocumentSets all segments in the given paragraph to the given style- Specified by:
setStylein interfaceEditableStyledDocument<PS,SEG,S>
-
setStyle
public void setStyle(int paragraphIndex, int fromCol, int toCol, S style)Description copied from interface:EditableStyledDocumentSets the given range "fromCol..toCol" in the given paragraph to the given style- Specified by:
setStylein interfaceEditableStyledDocument<PS,SEG,S>
-
setStyleSpans
public void setStyleSpans(int from, StyleSpans<? extends S> styleSpans)Description copied from interface:EditableStyledDocumentReplaces the style spans for the given range"from..(from + styleSpans.length())"with the given style spans- Specified by:
setStyleSpansin interfaceEditableStyledDocument<PS,SEG,S>
-
setStyleSpans
public void setStyleSpans(int paragraphIndex, int from, StyleSpans<? extends S> styleSpans)Description copied from interface:EditableStyledDocumentReplaces the style spans for the given range"from..(from + styleSpans.length())"in the given paragraph with the given style spans- Specified by:
setStyleSpansin interfaceEditableStyledDocument<PS,SEG,S>
-
setParagraphStyle
public void setParagraphStyle(int paragraphIndex, PS style)Description copied from interface:EditableStyledDocumentSets the given paragraph to the given paragraph style- Specified by:
setParagraphStylein interfaceEditableStyledDocument<PS,SEG,S>
-
concat
public StyledDocument<PS,SEG,S> concat(StyledDocument<PS,SEG,S> that)
- Specified by:
concatin interfaceStyledDocument<PS,SEG,S>
-
subSequence
public StyledDocument<PS,SEG,S> subSequence(int start, int end)
- Specified by:
subSequencein interfaceStyledDocument<PS,SEG,S>
-
-