StyledTextModel based on a collection of styled segments.
This model is suitable for relatively small documents as it has neither disk storage backing nor storage of incremental changes.
| Modifier and Type | Class and Description |
|---|---|
| private static class | RichTextModel.
Model paragraph is a list of RSegments. |
| private static class | RichTextModel.
Represents a rich text segment having the same style attributes. |
| Modifier and Type | Field and Description |
|---|---|
| public static final double | DEFAULT_TAB_STOPS_DISABLED
This value of the |
| public static final double | DEFAULT_TAB_STOPS_FIXED
This value of the |
| private DoubleProperty | |
| private final ArrayList | |
| private static final String | |
| private final HashMap |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| protected void | applyParagraphStyle(int index, StyleAttributeMap attrs)
Implements abstract jfx. Applies paragraph styles in the specified paragraph. |
| protected void | applyStyle(int index, int start, int end, StyleAttributeMap attrs, boolean merge)
Implements abstract jfx. Applies style to the specified text range within a single paragraph. |
| private StyleAttributeMap | |
| public final DoubleProperty | Returns: the default tab stop interval propertySpecifies the default tab stop interval for tabs beyond the last stop provided
by the paragraph's
|
| protected Map | documentProperties()
Overrides jfx. This method is called by |
| private static void | dump(StyledTextModel
the model model, PrintStream the output out)Temporary method added for testing; will be removed in production. |
| private void | |
| private void | |
| public final double | |
| public RichParagraph | getParagraph(int index)
Implements abstract jfx. Returns a |
| public int | getParagraphLength(int index)
Overrides jfx. Returns the length of text in a paragraph at the specified index. |
| public String | getPlainText(int index)
Implements abstract jfx. Returns the plain text string for the specified paragraph. |
| public StyleAttributeMap | getStyleAttributeMap(StyleResolver resolver, TextPos pos, boolean forInsert)
Implements abstract jfx. Returns the |
| protected void | handleDocumentProperties(Map<String, String> p, boolean completeReplacement)
Overrides jfx. This method is called by any of the |
| protected void | insertLineBreak(int index, int offset)
Implements abstract jfx. Inserts a line break at the specified position. |
| protected void | insertParagraph(int index, Supplier<Region> generator)
Implements abstract jfx. Inserts a paragraph that contains a single |
| protected int | insertTextSegment(int index, int offset, String text, StyleAttributeMap attrs)
Implements abstract jfx. This method is called to insert a single styled text segment at the given position. |
| public final boolean | isWritable()
Implements abstract jfx. Indicates whether the model supports content modifications made via
|
| protected RichParagraph. | Returns: the builderthe paragraph index index)Prepares the paragraph by populating a builder with the paragraph content. |
| protected void | removeRange(TextPos start, TextPos end)
Implements abstract jfx. Removes the specified text range. |
| public final void | |
| protected void | setParagraphStyle(int index, StyleAttributeMap attrs)
Implements abstract jfx. Replaces the paragraph styles in the specified paragraph. |
| public int | size()
Implements abstract jfx. Returns the number of paragraphs in the model. |
| protected String | versionString()
Overrides jfx. This method is called by |
| DEFAULT_TAB_STOPS_DISABLED | back to summary |
|---|---|
| public static final double DEFAULT_TAB_STOPS_DISABLED This value of the
| |
| DEFAULT_TAB_STOPS_FIXED | back to summary |
|---|---|
| public static final double DEFAULT_TAB_STOPS_FIXED This value of the
| |
| defaultTabStops | back to summary |
|---|---|
| private DoubleProperty defaultTabStops | |
| paragraphs | back to summary |
|---|---|
| private final ArrayList<RichTextModel. | |
| PROP_TABS | back to summary |
|---|---|
| private static final String PROP_TABS | |
| styleCache | back to summary |
|---|---|
| private final HashMap<StyleAttributeMap, StyleAttributeMap> styleCache | |
| RichTextModel | back to summary |
|---|---|
| public RichTextModel() Constructs the empty model. | |
| applyParagraphStyle | back to summary |
|---|---|
| protected void applyParagraphStyle(int index, StyleAttributeMap attrs) Implements abstract jfx. Doc from jfx. Applies paragraph styles in the specified paragraph.
| |
| applyStyle | back to summary |
|---|---|
| protected void applyStyle(int index, int start, int end, StyleAttributeMap attrs, boolean merge) Implements abstract jfx. Doc from jfx. Applies style to the specified text range within a single paragraph.
The
| |
| dedup | back to summary |
|---|---|
| private StyleAttributeMap dedup(StyleAttributeMap a) deduplicates style attributes. | |
| defaultTabStopsProperty | back to summary |
|---|---|
| public final DoubleProperty defaultTabStopsProperty() Specifies the default tab stop interval for tabs beyond the last stop provided
by the paragraph's
Value
| |
| documentProperties | back to summary |
|---|---|
| protected Map Overrides jfx. Doc from jfx. This method is called by
| |
| dump | back to summary |
|---|---|
| private static void dump(StyledTextModel model, PrintStream out) Temporary method added for testing; will be removed in production.
| |
| dump | back to summary |
|---|---|
| private void dump(PrintStream out) | |
| dump | back to summary |
|---|---|
| private void dump(RichTextModel. | |
| getDefaultTabStops | back to summary |
|---|---|
| public final double getDefaultTabStops() | |
| getParagraph | back to summary |
|---|---|
| public RichParagraph getParagraph(int index) Implements abstract jfx. Doc from jfx. Returns a This method makes no guarantees that the same paragraph instance will be returned for the same model index.
| |
| getParagraphLength | back to summary |
|---|---|
| public int getParagraphLength(int index) Overrides jfx. Doc from jfx. Returns the length of text in a paragraph at the specified index.
| |
| getPlainText | back to summary |
|---|---|
| public String getPlainText(int index) Implements abstract jfx. Doc from jfx. Returns the plain text string for the specified paragraph. The returned text string cannot be null
and must not contain any control characters other than TAB.
The callers must ensure that the value of
| |
| getStyleAttributeMap | back to summary |
|---|---|
| public StyleAttributeMap getStyleAttributeMap(StyleResolver resolver, TextPos pos, boolean forInsert) Implements abstract jfx. Doc from jfx. Returns the
When the position points to the boundary between two text segments with different attributes,
the value of
| |
| handleDocumentProperties | back to summary |
|---|---|
| protected void handleDocumentProperties(Map<String, String> p, boolean completeReplacement) Overrides jfx. Doc from jfx. This method is called by any of the
| |
| insertLineBreak | back to summary |
|---|---|
| protected void insertLineBreak(int index, int offset) Implements abstract jfx. Doc from jfx. Inserts a line break at the specified position.
| |
| insertParagraph | back to summary |
|---|---|
| protected void insertParagraph(int index, Supplier<Region> generator) Implements abstract jfx. Doc from jfx. Inserts a paragraph that contains a single
The model should not cache or otherwise retain references to the created
This method allows for embedding
| |
| insertTextSegment | back to summary |
|---|---|
| protected int insertTextSegment(int index, int offset, String text, StyleAttributeMap attrs) Implements abstract jfx. Doc from jfx. This method is called to insert a single styled text segment at the given position.
| |
| isWritable | back to summary |
|---|---|
| public final boolean isWritable() Implements abstract jfx. Doc from jfx. Indicates whether the model supports content modifications made via
Note that even when this method returns
| |
| prepareParagraph | back to summary |
|---|---|
| protected RichParagraph. Prepares the paragraph by populating a builder with the paragraph content. This method allows the custom model to add highlights and decorations without affecting the base class storage model.
| |
| removeRange | back to summary |
|---|---|
| protected void removeRange(TextPos start, TextPos end) Implements abstract jfx. Doc from jfx. Removes the specified text range.
This method gets called only if the model is editable.
The caller guarantees that
| |
| setDefaultTabStops | back to summary |
|---|---|
| public final void setDefaultTabStops(double value) | |
| setParagraphStyle | back to summary |
|---|---|
| protected void setParagraphStyle(int index, StyleAttributeMap attrs) Implements abstract jfx. Doc from jfx. Replaces the paragraph styles in the specified paragraph.
| |
| size | back to summary |
|---|---|
| public int size() Implements abstract jfx. Doc from jfx. Returns the number of paragraphs in the model.
| |
| versionString | back to summary |
|---|---|
| protected String versionString() Overrides jfx. Doc from jfx. This method is called by
| |
| Modifier and Type | Field and Description |
|---|---|
| private StyleAttributeMap |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public void | append(RichTextModel.
the paragraph to append pAppends the specified paragraph by adding all of its segments. |
| public void | |
| public void | applyStyle(int start, int end, StyleAttributeMap attrs, boolean merge, Function<StyleAttributeMap, StyleAttributeMap> dedup)
|
| private boolean | Returns: true if this segment has been merged with the previous segmentthe paragraph index ix, RichTextModel.the segment seg,the attributes a, boolean whether to merge or set merge, Function<StyleAttributeMap, StyleAttributeMap> the deduplicator dedup)Applies style to the segment. |
| private RichParagraph. | |
| public StyleAttributeMap | |
| public String | |
| public StyleAttributeMap | Returns: the style attributes, non-nullthe character index charIndex, boolean the leading/trailing bias leading, boolean whether to pick preceding style at the segment boundary forInsert)Retrieves the style attributes at the specified position. |
| public int | |
| public RichTextModel. | Returns: the remaining portion of paragraphthe offset offset)Trims this paragraph and returns the remaining text to be inserted after the line break. |
| private boolean | Returns: true if the new segment has been merged with the previous segmentinserts a new segment with the specified, deduplicated attributes. |
| private boolean | Returns: true if a segment has been added.the segment index ix, String the plain text text, StyleAttributeMap the style attributes a)Inserts a new segment, or merges with adjacent segment if styles are the same. |
| public void | insertText(int
the insertion offset offset, String the plain text text, StyleAttributeMap the style attributes attrs)Inserts styled text at the specified offset. |
| private boolean | |
| private boolean | |
| public void | |
| public void | |
| private static int | whichCase(int off, int max, int start, int end)
paragraph: start [=============] end
case:
0: |-
0: |-
1: -------------------->
2: |----------------->
3: |-------------|
4: |--------|
5: |------------->
6: |---------|
7: |----|
8: -----------|
9: ----------------|
|
| paragraphAttrs | back to summary |
|---|---|
| private StyleAttributeMap paragraphAttrs | |
| RParagraph | back to summary |
|---|---|
| public RParagraph() Creates an instance | |
| append | back to summary |
|---|---|
| public void append(RichTextModel. Appends the specified paragraph by adding all of its segments.
| |
| applyParagraphAttributes | back to summary |
|---|---|
| public void applyParagraphAttributes(StyleAttributeMap a) | |
| applyStyle | back to summary |
|---|---|
| public void applyStyle(int start, int end, StyleAttributeMap attrs, boolean merge, Function<StyleAttributeMap, StyleAttributeMap> dedup) | |
| applyStyle | back to summary |
|---|---|
| private boolean applyStyle(int ix, RichTextModel. Applies style to the segment. If the new style is exactly the same as the style of the previous segment, it simply merges the two segments.
| |
| buildParagraph | back to summary |
|---|---|
| private RichParagraph. | |
| getParagraphAttributes | back to summary |
|---|---|
| public StyleAttributeMap getParagraphAttributes() | |
| getPlainText | back to summary |
|---|---|
| public String getPlainText() | |
| getStyleAttributeMap | back to summary |
|---|---|
| public StyleAttributeMap getStyleAttributeMap(int charIndex, boolean leading, boolean forInsert) Retrieves the style attributes at the specified position.
| |
| getTextLength | back to summary |
|---|---|
| public int getTextLength() | |
| insertLineBreak | back to summary |
|---|---|
| public RichTextModel. Trims this paragraph and returns the remaining text to be inserted after the line break.
| |
| insertSegment | back to summary |
|---|---|
| private boolean insertSegment(int ix, String text, StyleAttributeMap a) inserts a new segment with the specified, deduplicated attributes. if the new style is the same as the previous segment, merges text with the previous segment instead.
| |
| insertSegment2 | back to summary |
|---|---|
| private boolean insertSegment2(int ix, String text, StyleAttributeMap a) Inserts a new segment, or merges with adjacent segment if styles are the same. Returns true if a segment has been added.
| |
| insertText | back to summary |
|---|---|
| public void insertText(int offset, String text, StyleAttributeMap attrs) Inserts styled text at the specified offset.
| |
| isMerge | back to summary |
|---|---|
| private boolean isMerge(RichTextModel. | |
| isZeroWidth | back to summary |
|---|---|
| private boolean isZeroWidth() | |
| removeSpan | back to summary |
|---|---|
| public void removeSpan(int start, int end) | |
| setParagraphAttributes | back to summary |
|---|---|
| public void setParagraphAttributes(StyleAttributeMap a) | |
| whichCase | back to summary |
|---|---|
private static int whichCase(int off, int max, int start, int end)
paragraph: start [=============] end
case:
0: |-
0: |-
1: -------------------->
2: |----------------->
3: |-------------|
4: |--------|
5: |------------->
6: |---------|
7: |----|
8: -----------|
9: ----------------|
| |
| Modifier and Type | Field and Description |
|---|---|
| private StyleAttributeMap | |
| private String |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public void | |
| public StyleAttributeMap | |
| public StyleAttributeMap | |
| public int | |
| public boolean | |
| public void | |
| public void | |
| public String |
| attrs | back to summary |
|---|---|
| private StyleAttributeMap attrs | |
| text | back to summary |
|---|---|
| private String text | |
| RSegment | back to summary |
|---|---|
| public RSegment(String text, StyleAttributeMap attrs) | |
| append | back to summary |
|---|---|
| public void append(String s) | |
| attrs | back to summary |
|---|---|
| public StyleAttributeMap attrs() | |
| getStyleAttributeMap | back to summary |
|---|---|
| public StyleAttributeMap getStyleAttributeMap() | |
| getTextLength | back to summary |
|---|---|
| public int getTextLength() | |
| removeRegion | back to summary |
|---|---|
| public boolean removeRegion(int start, int end) returns true if this segment becomes empty as a result | |
| setAttrs | back to summary |
|---|---|
| public void setAttrs(StyleAttributeMap a) | |
| setText | back to summary |
|---|---|
| public void setText(String s) | |
| text | back to summary |
|---|---|
| public String text() | |