Top Description Methods
org.fxmisc.richtext

public Interface StyleActions<PS, S>

Known Direct Implementers
org.fxmisc.richtext.GenericStyledArea
Type Parameters
<PS>
the paragraph style
<S>
the segment's style
Imports
javafx.beans.property.BooleanProperty, javafx.scene.control.IndexRange, org.fxmisc.richtext.model.StyleSpans

Specifies actions related to getting and setting styles throughout a TextEditingArea.

Method Summary

Modifier and TypeMethod and Description
public default void
clearParagraphStyle(int paragraph)

Resets the style of the given paragraph to the initial style.

public default void
clearStyle(int from, int to)

Resets the style of the given range to the initial style.

public default void
clearStyle(int paragraph, int from, int to)

Resets the style of the given range in the given paragraph to the initial style.

public default void
clearStyle(int paragraph)

Resets the style of the given paragraph to the initial style.

public PS
getInitialParagraphStyle()

Style used by default when no other style is provided.

public S
getInitialTextStyle()

Style used by default when no other style is provided.

public PS
getParagraphStyleForInsertionAt(int pos)

Returns getInitialParagraphStyle() if getUseInitialStyleForInsertion() is true; otherwise, returns the paragraph style at the given position.

public S
getStyleAtPosition(int position)

Returns the style at the given position.

public S
getStyleAtPosition(int paragraph, int position)

Returns the style at the given position in the given paragraph.

public S
getStyleOfChar(int index)

Returns the style of the character with the given index.

public S
getStyleOfChar(int paragraph, int index)

Returns the style of the character with the given index in the given paragraph.

public IndexRange
getStyleRangeAtPosition(int position)

Returns the range of homogeneous style that includes the given position.

public IndexRange
getStyleRangeAtPosition(int paragraph, int position)

Returns the range of homogeneous style that includes the given position in the given paragraph.

public StyleSpans<S>
getStyleSpans(int from, int to)

Returns the styles in the given character range.

public default StyleSpans<S>
getStyleSpans(IndexRange range)

Returns the styles in the given character range.

public StyleSpans<S>
getStyleSpans(int paragraph)

Returns styles of the whole paragraph.

public StyleSpans<S>
getStyleSpans(int paragraph, int from, int to)

Returns the styles in the given character range of the given paragraph.

public default StyleSpans<S>
getStyleSpans(int paragraph, IndexRange range)

Returns the styles in the given character range of the given paragraph.

public S
getTextStyleForInsertionAt(int pos)

Returns getInitialTextStyle() if getUseInitialStyleForInsertion() is true; otherwise, returns the style at the given position.

public default boolean
getUseInitialStyleForInsertion()

Indicates whether the initial style should also be used for plain text inserted into this text area.

public boolean
isPreserveStyle()

Indicates whether style should be preserved on undo/redo (and in the future copy/paste and text move).

public void
setParagraphStyle(int paragraph, PS paragraphStyle)

Sets style for the whole paragraph.

public void
setStyle(int from, int to, S style)

Sets style for the given character range.

public void
setStyle(int paragraph, S style)

Sets style for the whole paragraph.

public void
setStyle(int paragraph, int from, int to, S style)

Sets style for the given range relative in the given paragraph.

public void
setStyleSpans(int from, StyleSpans<? extends S> styleSpans)

Set multiple style ranges at once.

public void
setStyleSpans(int paragraph, int from, StyleSpans<? extends S> styleSpans)

Set multiple style ranges of a paragraph at once.

public default void
public BooleanProperty

Method Detail

clearParagraphStyleback to summary
public default void clearParagraphStyle(int paragraph)

Resets the style of the given paragraph to the initial style.

clearStyleback to summary
public default void clearStyle(int from, int to)

Resets the style of the given range to the initial style.

clearStyleback to summary
public default void clearStyle(int paragraph, int from, int to)

Resets the style of the given range in the given paragraph to the initial style.

clearStyleback to summary
public default void clearStyle(int paragraph)

Resets the style of the given paragraph to the initial style.

getInitialParagraphStyleback to summary
public PS getInitialParagraphStyle()

Style used by default when no other style is provided.

getInitialTextStyleback to summary
public S getInitialTextStyle()

Style used by default when no other style is provided.

getParagraphStyleForInsertionAtback to summary
public PS getParagraphStyleForInsertionAt(int pos)

Returns getInitialParagraphStyle() if getUseInitialStyleForInsertion() is true; otherwise, returns the paragraph style at the given position.

getStyleAtPositionback to summary
public S getStyleAtPosition(int position)

Returns the style at the given position. That is the style of the character immediately preceding position, except when position points to a paragraph boundary, in which case it is the style at the beginning of the latter paragraph.

In other words, most of the time getStyleAtPosition(p) is equivalent to getStyleOfChar(p-1), except when p points to a paragraph boundary, in which case it is equivalent to getStyleOfChar(p).

getStyleAtPositionback to summary
public S getStyleAtPosition(int paragraph, int position)

Returns the style at the given position in the given paragraph. This is equivalent to getStyleOfChar(paragraph, position-1).

getStyleOfCharback to summary
public S getStyleOfChar(int index)

Returns the style of the character with the given index. If index points to a line terminator character, the last style used in the paragraph terminated by that line terminator is returned.

getStyleOfCharback to summary
public S getStyleOfChar(int paragraph, int index)

Returns the style of the character with the given index in the given paragraph. If index is beyond the end of the paragraph, the style at the end of line is returned. If index is negative, it is the same as if it was 0.

getStyleRangeAtPositionback to summary
public IndexRange getStyleRangeAtPosition(int position)

Returns the range of homogeneous style that includes the given position. If position points to a boundary between two styled ranges, then the range preceding position is returned. If position points to a boundary between two paragraphs, then the first styled range of the latter paragraph is returned

Note

that the returned IndexRange is relative to the paragraph (NOT the document).

getStyleRangeAtPositionback to summary
public IndexRange getStyleRangeAtPosition(int paragraph, int position)

Returns the range of homogeneous style that includes the given position in the given paragraph. If position points to a boundary between two styled ranges, then the range preceding position is returned. The returned IndexRange is relative to the paragraph.

getStyleSpansback to summary
public StyleSpans<S> getStyleSpans(int from, int to)

Returns the styles in the given character range.

getStyleSpansback to summary
public default StyleSpans<S> getStyleSpans(IndexRange range)

Returns the styles in the given character range.

getStyleSpansback to summary
public StyleSpans<S> getStyleSpans(int paragraph)

Returns styles of the whole paragraph.

getStyleSpansback to summary
public StyleSpans<S> getStyleSpans(int paragraph, int from, int to)

Returns the styles in the given character range of the given paragraph.

getStyleSpansback to summary
public default StyleSpans<S> getStyleSpans(int paragraph, IndexRange range)

Returns the styles in the given character range of the given paragraph.

getTextStyleForInsertionAtback to summary
public S getTextStyleForInsertionAt(int pos)

Returns getInitialTextStyle() if getUseInitialStyleForInsertion() is true; otherwise, returns the style at the given position.

getUseInitialStyleForInsertionback to summary
public default boolean getUseInitialStyleForInsertion()

Indicates whether the initial style should also be used for plain text inserted into this text area. When false, the style immediately preceding the insertion position is used. Default value is false.

isPreserveStyleback to summary
public boolean isPreserveStyle()

Indicates whether style should be preserved on undo/redo (and in the future copy/paste and text move).

setParagraphStyleback to summary
public void setParagraphStyle(int paragraph, PS paragraphStyle)

Sets style for the whole paragraph.

setStyleback to summary
public void setStyle(int from, int to, S style)

Sets style for the given character range.

setStyleback to summary
public void setStyle(int paragraph, S style)

Sets style for the whole paragraph.

setStyleback to summary
public void setStyle(int paragraph, int from, int to, S style)

Sets style for the given range relative in the given paragraph.

setStyleSpansback to summary
public void setStyleSpans(int from, StyleSpans<? extends S> styleSpans)

Set multiple style ranges at once. This is equivalent to

for(StyleSpan<S> span: styleSpans) {
    setStyle(from, from + span.getLength(), span.getStyle());
    from += span.getLength();
}
but the actual implementation in org.fxmisc.richtext.model.SimpleEditableStyledDocument is more efficient.
setStyleSpansback to summary
public void setStyleSpans(int paragraph, int from, StyleSpans<? extends S> styleSpans)

Set multiple style ranges of a paragraph at once. This is equivalent to

for(StyleSpan<S> span: styleSpans) {
    setStyle(paragraph, from, from + span.getLength(), span.getStyle());
    from += span.getLength();
}
but the actual implementation in org.fxmisc.richtext.model.SimpleEditableStyledDocument is more efficient.
setUseInitialStyleForInsertionback to summary
public default void setUseInitialStyleForInsertion(boolean value)
useInitialStyleForInsertionPropertyback to summary
public BooleanProperty useInitialStyleForInsertionProperty()