Package org.fxmisc.richtext
Interface StyleActions<PS,S>
-
- Type Parameters:
PS
- the paragraph styleS
- the segment's style
- All Known Implementing Classes:
CodeArea
,GenericStyledArea
,InlineCssTextArea
,InlineCssTextField
,StyleClassedTextArea
,StyleClassedTextField
,StyledTextArea
,StyledTextField
public interface StyleActions<PS,S>
Specifies actions related to getting and setting styles throughout aTextEditingArea
.
-
-
Property Summary
Properties Type Property Description BooleanProperty
useInitialStyleForInsertion
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default void
clearParagraphStyle(int paragraph)
Resets the style of the given paragraph to the initial style.default void
clearStyle(int paragraph)
Resets the style of the given paragraph to the initial style.default void
clearStyle(int from, int to)
Resets the style of the given range to the initial style.default void
clearStyle(int paragraph, int from, int to)
Resets the style of the given range in the given paragraph to the initial style.PS
getInitialParagraphStyle()
Style used by default when no other style is provided.S
getInitialTextStyle()
Style used by default when no other style is provided.PS
getParagraphStyleForInsertionAt(int pos)
ReturnsgetInitialParagraphStyle()
ifgetUseInitialStyleForInsertion()
is true; otherwise, returns the paragraph style at the given position.S
getStyleAtPosition(int position)
Returns the style at the given position.S
getStyleAtPosition(int paragraph, int position)
Returns the style at the given position in the given paragraph.S
getStyleOfChar(int index)
Returns the style of the character with the given index.S
getStyleOfChar(int paragraph, int index)
Returns the style of the character with the given index in the given paragraph.IndexRange
getStyleRangeAtPosition(int position)
Returns the range of homogeneous style that includes the given position.IndexRange
getStyleRangeAtPosition(int paragraph, int position)
Returns the range of homogeneous style that includes the given position in the given paragraph.StyleSpans<S>
getStyleSpans(int paragraph)
Returns styles of the whole paragraph.StyleSpans<S>
getStyleSpans(int from, int to)
Returns the styles in the given character range.StyleSpans<S>
getStyleSpans(int paragraph, int from, int to)
Returns the styles in the given character range of the given paragraph.default StyleSpans<S>
getStyleSpans(int paragraph, IndexRange range)
Returns the styles in the given character range of the given paragraph.default StyleSpans<S>
getStyleSpans(IndexRange range)
Returns the styles in the given character range.S
getTextStyleForInsertionAt(int pos)
ReturnsgetInitialTextStyle()
ifgetUseInitialStyleForInsertion()
is true; otherwise, returns the style at the given position.default boolean
getUseInitialStyleForInsertion()
Indicates whether the initial style should also be used for plain text inserted into this text area.boolean
isPreserveStyle()
Indicates whether style should be preserved on undo/redo (and in the future copy/paste and text move).void
setParagraphStyle(int paragraph, PS paragraphStyle)
Sets style for the whole paragraph.void
setStyle(int paragraph, int from, int to, S style)
Sets style for the given range relative in the given paragraph.void
setStyle(int from, int to, S style)
Sets style for the given character range.void
setStyle(int paragraph, S style)
Sets style for the whole paragraph.void
setStyleSpans(int paragraph, int from, StyleSpans<? extends S> styleSpans)
Set multiple style ranges of a paragraph at once.void
setStyleSpans(int from, StyleSpans<? extends S> styleSpans)
Set multiple style ranges at once.default void
setUseInitialStyleForInsertion(boolean value)
Sets the value of the property useInitialStyleForInsertion.BooleanProperty
useInitialStyleForInsertionProperty()
-
-
-
Property Detail
-
useInitialStyleForInsertion
BooleanProperty useInitialStyleForInsertionProperty
-
-
Method Detail
-
getUseInitialStyleForInsertion
default boolean getUseInitialStyleForInsertion()
Indicates whether the initial style should also be used for plain text inserted into this text area. Whenfalse
, the style immediately preceding the insertion position is used. Default value isfalse
.
-
setUseInitialStyleForInsertion
default void setUseInitialStyleForInsertion(boolean value)
Sets the value of the property useInitialStyleForInsertion.- Property description:
-
useInitialStyleForInsertionProperty
BooleanProperty useInitialStyleForInsertionProperty()
-
getInitialTextStyle
S getInitialTextStyle()
Style used by default when no other style is provided.
-
getInitialParagraphStyle
PS getInitialParagraphStyle()
Style used by default when no other style is provided.
-
getTextStyleForInsertionAt
S getTextStyleForInsertionAt(int pos)
ReturnsgetInitialTextStyle()
ifgetUseInitialStyleForInsertion()
is true; otherwise, returns the style at the given position.
-
getParagraphStyleForInsertionAt
PS getParagraphStyleForInsertionAt(int pos)
ReturnsgetInitialParagraphStyle()
ifgetUseInitialStyleForInsertion()
is true; otherwise, returns the paragraph style at the given position.
-
isPreserveStyle
boolean isPreserveStyle()
Indicates whether style should be preserved on undo/redo (and in the future copy/paste and text move).
-
getStyleOfChar
S getStyleOfChar(int index)
Returns the style of the character with the given index. Ifindex
points to a line terminator character, the last style used in the paragraph terminated by that line terminator is returned.
-
getStyleAtPosition
S getStyleAtPosition(int position)
Returns the style at the given position. That is the style of the character immediately precedingposition
, except whenposition
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 togetStyleOfChar(p-1)
, except whenp
points to a paragraph boundary, in which case it is equivalent togetStyleOfChar(p)
.
-
getStyleRangeAtPosition
IndexRange getStyleRangeAtPosition(int position)
Returns the range of homogeneous style that includes the given position. Ifposition
points to a boundary between two styled ranges, then the range precedingposition
is returned. Ifposition
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).
-
getStyleSpans
StyleSpans<S> getStyleSpans(int from, int to)
Returns the styles in the given character range.
-
getStyleSpans
default StyleSpans<S> getStyleSpans(IndexRange range)
Returns the styles in the given character range.
-
getStyleOfChar
S getStyleOfChar(int paragraph, int index)
Returns the style of the character with the given index in the given paragraph. Ifindex
is beyond the end of the paragraph, the style at the end of line is returned. Ifindex
is negative, it is the same as if it was 0.
-
getStyleAtPosition
S getStyleAtPosition(int paragraph, int position)
Returns the style at the given position in the given paragraph. This is equivalent togetStyleOfChar(paragraph, position-1)
.
-
getStyleRangeAtPosition
IndexRange getStyleRangeAtPosition(int paragraph, int position)
Returns the range of homogeneous style that includes the given position in the given paragraph. Ifposition
points to a boundary between two styled ranges, then the range precedingposition
is returned. The returned IndexRange is relative to the paragraph.
-
getStyleSpans
StyleSpans<S> getStyleSpans(int paragraph)
Returns styles of the whole paragraph.
-
getStyleSpans
StyleSpans<S> getStyleSpans(int paragraph, int from, int to)
Returns the styles in the given character range of the given paragraph.
-
getStyleSpans
default StyleSpans<S> getStyleSpans(int paragraph, IndexRange range)
Returns the styles in the given character range of the given paragraph.
-
setStyle
void setStyle(int from, int to, S style)
Sets style for the given character range.
-
setStyle
void setStyle(int paragraph, S style)
Sets style for the whole paragraph.
-
setStyle
void setStyle(int paragraph, int from, int to, S style)
Sets style for the given range relative in the given paragraph.
-
setStyleSpans
void setStyleSpans(int from, StyleSpans<? extends S> styleSpans)
Set multiple style ranges at once. This is equivalent tofor(StyleSpan
but the actual implementation in<S>
span: styleSpans) { setStyle(from, from + span.getLength(), span.getStyle()); from += span.getLength(); }SimpleEditableStyledDocument
is more efficient.
-
setStyleSpans
void setStyleSpans(int paragraph, int from, StyleSpans<? extends S> styleSpans)
Set multiple style ranges of a paragraph at once. This is equivalent tofor(StyleSpan
but the actual implementation in<S>
span: styleSpans) { setStyle(paragraph, from, from + span.getLength(), span.getStyle()); from += span.getLength(); }SimpleEditableStyledDocument
is more efficient.
-
setParagraphStyle
void setParagraphStyle(int paragraph, PS paragraphStyle)
Sets style for the whole paragraph.
-
clearStyle
default void clearStyle(int from, int to)
Resets the style of the given range to the initial style.
-
clearStyle
default void clearStyle(int paragraph, int from, int to)
Resets the style of the given range in the given paragraph to the initial style.
-
clearStyle
default void clearStyle(int paragraph)
Resets the style of the given paragraph to the initial style.
-
clearParagraphStyle
default void clearParagraphStyle(int paragraph)
Resets the style of the given paragraph to the initial style.
-
-