Top Description Interfaces Classes
[default module]

Package org.fxmisc.richtext.model


Defines the support classes and operations related to org.fxmisc.richtext.model.EditableStyledDocument, the immutable model of rich-text content that can be rendered and edited.

An org.fxmisc.richtext.model.EditableStyledDocument acts as an immutable model for rich-text content that will be rendered by an object implementing the org.fxmisc.richtext.TextEditingArea interface. A org.fxmisc.richtext.model.StyledDocument is composed of a list of org.fxmisc.richtext.model.Paragraphs. Paragraphs are nothing more than an object containing a paragraph style (type PS), a list of a generic segments (type SEG), and a list of generic styles (type S) that can apply to a segment. Most of the time, either org.fxmisc.richtext.model.EditableStyledDocument or org.fxmisc.richtext.model.ReadOnlyStyledDocument are being used to implement that interface.

The document can include more than just text; thus, the segment generic can be specified as regular text (java.lang.String) or as an org.reactfx.util.Either (e.g. Either<String, Image> or as a nested Either (e.g. Either<String, Either<Image, Either<Circle, Square>) if one wanted to have four different kinds of segments (ways to specify a segment generic in a way that still makes the code easy to read are not described here).

To allow these generics, one must supply a org.fxmisc.richtext.model.SegmentOps object that can correctly operate on the generic segments and their generic styles. In addition, a org.fxmisc.richtext.model.TextOps adds one more method to its base interface by adding a method that maps a java.lang.String to a given segment. For text-based custom segments, one should use org.fxmisc.richtext.model.SegmentOpsBase and for node-based custom segments, one should use org.fxmisc.richtext.model.NodeSegmentOpsBase.

The document also uses org.fxmisc.richtext.model.StyleSpans to store styles in a memory-efficient way. To construct one, use org.fxmisc.richtext.model.StyleSpans#singleton(org.fxmisc.richtext.model.StyleSpan) or org.fxmisc.richtext.model.StyleSpansBuilder.

To navigate throughout the document, read through the javadoc of org.fxmisc.richtext.model.TwoDimensional and org.fxmisc.richtext.model.TwoDimensional.Bias. Also, read the difference between "position" and "index" in org.fxmisc.richtext.model.StyledDocument#getAbsolutePosition(int, int).

To serialize things correctly, see org.fxmisc.richtext.model.Codec and its static factory methods.

Lastly, the org.fxmisc.richtext.model.EditableStyledDocument can emit org.fxmisc.richtext.model.PlainTextChanges or org.fxmisc.richtext.model.RichTextChanges that can be used to undo/redo various changes.

See Also
org.fxmisc.richtext.model.EditableStyledDocument, org.fxmisc.richtext.model.Paragraph, org.fxmisc.richtext.model.SegmentOps, org.fxmisc.richtext.model.TwoDimensional, org.fxmisc.richtext.model.TwoDimensional.Bias

Interface Summary

Modifier and TypeInterface and Description
public interface
Codec<
the type of object to serialize
T
>

Specifies a way to serialize an object to/from a data stream

public interface
EditableStyledDocument<
the paragraph style type
PS
,
the segment type
SEG
,
the segment's style
S
>

Content model for org.fxmisc.richtext.GenericStyledArea.

public interface
SegmentOps<
The segment type
SEG
,
The style type for the segment
S
>

Defines the operations which are supported on a specific segment type.

public interface
StyledDocument<
The type of the paragraph style.
PS
,
The type of the segments in the paragraph (e.g. String).
SEG
,
The type of the style of individual segments.
S
>

An object (document) that is a list of styleable Paragraph that each contain a list of styleable segments.

public interface
StyleSpans<
the style type
S
>

Essentially, a list of StyleSpan objects.

pack-priv interface
SuperCodec<
the super class type
S
,
the regular class type
T extends S
>

Codec that can serialize an object and its super class; helpful when using generics and captures.

public interface
TextOps<
the type of segment
SEG
,
the type of style
S
>

Extends SegmentOps by adding create(String), which can create a SEG segment from a given String

public interface
TwoDimensional

TwoDimensional is an interface for any item which can be navigated in two dimensions, such as a List of Lists.

Class Summary

Modifier and TypeClass and Description
pack-priv class
pack-priv class
pack-priv class
EitherStyledSegmentOps<LSeg, RSeg, LStyle, RStyle>

public class
GenericEditableStyledDocument<
type of style that can be applied to paragraphs (e.g. javafx.scene.text.TextFlow.
PS
,
type of segment used in Paragraph. Can be only text (plain or styled) or a type that combines text and other javafx.scene.Nodes via Either<String, Node>.
SEG
,
type of style that can be applied to a segment.
S
>

Provides a basic implementation of EditableStyledDocument while still allowing a developer to specify its generics.

pack-priv class
pack-priv class
LeftTextOps<L, R, S>

public abstract class
NodeSegmentOpsBase<
type of segment
SEG
,
type of style
S
>

Properly implements SegmentOps when implementing a non-text custom object, such as a shape or image, and reduces boilerplate.

public class
Paragraph<
The type of the paragraph style.
PS
,
The type of the content segments in the paragraph (e.g. String). Every paragraph, even an empty paragraph, must have at least one SEG object (even if that SEG object itself represents an empty segment).
SEG
,
The type of the style of individual segments.
S
>

One paragraph in the document that can itself be styled and which contains a list of styled segments.

public class
PlainTextChange

An object that specifies where a non-style change occurred in a org.fxmisc.richtext.GenericStyledArea.

pack-priv class
public class
ReadOnlyStyledDocument<
The type of the paragraph style.
PS
,
The type of the segments in the paragraph (e.g. String).
SEG
,
The type of the style of individual segments.
S
>

An immutable implementation of StyledDocument that does not allow editing.

public class
ReadOnlyStyledDocumentBuilder<
the paragraph style type
PS
,
the segment type
SEG
,
the segment style type
S
>

Helper class via constructDocument(SegmentOps, Object, Consumer) or one of its constructors and build() for easily creating a ReadOnlyStyledDocument from a list of Paragraphs that is constructed via "addParagraph(s)" methods.

public class
Replacement<PS, SEG, S>

Encapsulates the all the arguments for EditableStyledDocument#replace(int, int, StyledDocument).

public class
RichTextChange<PS, SEG, S>

An object that specifies where a change occurred in a org.fxmisc.richtext.GenericStyledArea.

pack-priv class
RightTextOps<L, R, S>

public abstract class
SegmentOpsBase<
the type of segment
SEG
,
the type of style
S
>

Provides a base for properly implementing the SegmentOps interface and reduces boilerplate, so that a developer only needs to implement methods for real segments, not empty ones.

public class
SimpleEditableStyledDocument<PS, S>

Provides an implementation of EditableStyledDocument that specifies its segment type as String.

pack-priv class
public class
StyledSegment<
the segment type
SEG
,
the style type
S
>

Essentially, an immutable org.reactfx.util.Tuple2 that combines a segment object and a style object together.

public class
StyleSpan<
the style type
S
>

Essentially, a org.reactfx.util.Tuple2 of a given style S that spans a given length.

pack-priv abstract class
public class
StyleSpansBuilder<
the segment style type
S
>

A one-time-use builder that Builds a memory efficient StyleSpans object.

pack-priv class
public abstract class
TextChange<
type of data that was removed and inserted in the org.fxmisc.richtext.TextEditingArea.
S
,
a subclass of TextChange
Self extends TextChange<S, Self>
>

Base change class for style changes (RichTextChange) and non-style changes (PlainTextChange) in a org.fxmisc.richtext.TextEditingArea.

public abstract class
TextOpsBase<
the type of segment
SEG
,
the type of segment style
S
>

Base class for a TextOps implementation that uses a text-based segment

public class
TwoLevelNavigator

Default implementation of TwoDimensional that makes it trivial to calculate a position within a two dimensional object.

pack-priv class