Top Description Inners Fields Constructors Methods
org.fxmisc.richtext

pack-priv Class ParagraphText<PS, SEG, S>

extends TextFlowExt
Class Inheritance
Type Parameters
<PS>
paragraph style type
<SEG>
segment type
<S>
segment style type
Imports
java.util.Arrays, .Collection, .HashMap, .HashSet, .LinkedList, .List, .Objects, .Optional, java.util.function.BiConsumer, .BiFunction, .Consumer, .Function, .Supplier, .UnaryOperator, org.fxmisc.richtext.model.Paragraph, .StyledSegment, org.reactfx.util.Tuple2, .Tuples, org.reactfx.value.Val, javafx.beans.property.ObjectProperty, .SimpleObjectProperty, javafx.beans.value.ChangeListener, javafx.collections.FXCollections, .MapChangeListener, .ObservableMap, .ObservableSet, .SetChangeListener, javafx.geometry.Bounds, .Insets, javafx.scene.Node, javafx.scene.control.IndexRange, javafx.scene.paint.Color, .Paint, javafx.scene.shape.LineTo, .MoveTo, .Path, .PathElement, .StrokeLineCap, .StrokeType

The class responsible for rendering the segments in an paragraph. It also renders additional RichTextFX-specific CSS found in TextExt as well as the selection and caret shapes.

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
private static class
private static class
private static class

Field Summary

Modifier and TypeField and Description
private final ParagraphText.CustomCssShapeHelper<Paint>
private final ParagraphText.CustomCssShapeHelper<ParagraphText.BorderAttributes>
private final SetChangeListener<? super CaretNode>
private final ObservableSet<CaretNode>
private final ObjectProperty<Paint>
private Paragraph<PS, SEG, S>
private final MapChangeListener<? super Selection<PS, SEG, S>, ? super SelectionPath>
private final ObservableMap<Selection<PS, SEG, S>, SelectionPath>
private int
private final ParagraphText.CustomCssShapeHelper<ParagraphText.UnderlineAttributes>

Constructor Summary

AccessConstructor and Description
pack-priv
ParagraphText(Paragraph<PS, SEG, S> par, Function<StyledSegment<SEG, S>, Node> nodeFactory)

Method Summary

Modifier and TypeMethod and Description
public final ObservableSet<CaretNode>
private <T extends Node> void
private PathElement[]
createRectangle(double topLeftX, double topLeftY, double bottomRightX, double bottomRightY)

public int
public int
currentLineIndex(int position)

pack-priv void
public <T extends Node & Caret> Bounds
getCaretBounds(T caret)

public <T extends Node & Caret> Bounds
public <T extends Node & Caret> double
getCaretOffsetX(T caret)

private int
public int
public int
public Paragraph<PS, SEG, S>
public Bounds
getRangeBoundsOnScreen(int from, int to)

private PathElement[]
private PathElement[]
getRangeShapeSafely(int
the start position of the range shape
start
,
int
the end position of the range shape. If end == paragraph.length() + 1, the newline character will be included in the selection by selecting the rest of the line
end
)

Gets the range shape for the given positions within the text, including the newline character, if range defined by the start/end arguments include it.

public Optional<Bounds>
getSelectionBoundsOnScreen(Selection<PS, SEG, S> selection)

public ObjectProperty<Paint>
protected void
layoutChildren()

Overrides javafx.scene.text.TextFlow.layoutChildren.

Invoked during the layout pass to layout the children in this Parent.

public final ObservableMap<Selection<PS, SEG, S>, SelectionPath>
public String
toString()

Overrides javafx.scene.Node.toString.

Returns a string representation for the object.

private void
private void
private void
private void
private void
Inherited from org.fxmisc.richtext.TextFlowExt:
getCaretShapegetLineCountgetLineEndPositiongetLineOfCharactergetLineStartPositiongetRangeShapegetRangeShapegetUnderlineShapegetUnderlineShapegetUnderlineShapehithitLine

Field Detail

backgroundShapeHelperback to summary
private final ParagraphText.CustomCssShapeHelper<Paint> backgroundShapeHelper
borderShapeHelperback to summary
private final ParagraphText.CustomCssShapeHelper<ParagraphText.BorderAttributes> borderShapeHelper
caretNodeListenerback to summary
private final SetChangeListener<? super CaretNode> caretNodeListener
caretsback to summary
private final ObservableSet<CaretNode> carets
highlightTextFillback to summary
private final ObjectProperty<Paint> highlightTextFill
paragraphback to summary
private Paragraph<PS, SEG, S> paragraph
selectionPathListenerback to summary
private final MapChangeListener<? super Selection<PS, SEG, S>, ? super SelectionPath> selectionPathListener
selectionsback to summary
private final ObservableMap<Selection<PS, SEG, S>, SelectionPath> selections
selectionShapeStartIndexback to summary
private int selectionShapeStartIndex
underlineShapeHelperback to summary
private final ParagraphText.CustomCssShapeHelper<ParagraphText.UnderlineAttributes> underlineShapeHelper

Constructor Detail

ParagraphTextback to summary
pack-priv ParagraphText(Paragraph<PS, SEG, S> par, Function<StyledSegment<SEG, S>, Node> nodeFactory)

Method Detail

caretsPropertyback to summary
public final ObservableSet<CaretNode> caretsProperty()
checkWithinParagraphback to summary
private <T extends Node> void checkWithinParagraph(T shape)
createRectangleback to summary
private PathElement[] createRectangle(double topLeftX, double topLeftY, double bottomRightX, double bottomRightY)
currentLineIndexback to summary
public int currentLineIndex(Caret caret)
currentLineIndexback to summary
public int currentLineIndex(int position)
disposeback to summary
pack-priv void dispose()
getCaretBoundsback to summary
public <T extends Node & Caret> Bounds getCaretBounds(T caret)
getCaretBoundsOnScreenback to summary
public <T extends Node & Caret> Bounds getCaretBoundsOnScreen(T caret)
getCaretOffsetXback to summary
public <T extends Node & Caret> double getCaretOffsetX(T caret)
getClampedCaretPositionback to summary
private int getClampedCaretPosition(Caret caret)
getCurrentLineEndPositionback to summary
public int getCurrentLineEndPosition(Caret caret)
getCurrentLineStartPositionback to summary
public int getCurrentLineStartPosition(Caret caret)
getParagraphback to summary
public Paragraph<PS, SEG, S> getParagraph()
getRangeBoundsOnScreenback to summary
public Bounds getRangeBoundsOnScreen(int from, int to)
getRangeShapeSafelyback to summary
private PathElement[] getRangeShapeSafely(IndexRange range)
getRangeShapeSafelyback to summary
private PathElement[] getRangeShapeSafely(int start, int end)

Gets the range shape for the given positions within the text, including the newline character, if range defined by the start/end arguments include it.

Parameters
start:int

the start position of the range shape

end:int

the end position of the range shape. If end == paragraph.length() + 1, the newline character will be included in the selection by selecting the rest of the line

getSelectionBoundsOnScreenback to summary
public Optional<Bounds> getSelectionBoundsOnScreen(Selection<PS, SEG, S> selection)
highlightTextFillPropertyback to summary
public ObjectProperty<Paint> highlightTextFillProperty()
layoutChildrenback to summary
protected void layoutChildren()

Overrides javafx.scene.text.TextFlow.layoutChildren.

Doc from javafx.scene.Parent.layoutChildren.

Invoked during the layout pass to layout the children in this Parent. By default it will only set the size of managed, resizable content to their preferred sizes and does not do any node positioning.

Subclasses should override this function to layout content as needed.

Annotations
@Override
selectionsPropertyback to summary
public final ObservableMap<Selection<PS, SEG, S>, SelectionPath> selectionsProperty()
toStringback to summary
public String toString()

Overrides javafx.scene.Node.toString.

Doc from javafx.scene.Node.toString.

Returns a string representation for the object.

Annotations
@Override
updateAllCaretShapesback to summary
private void updateAllCaretShapes()
updateAllSelectionShapesback to summary
private void updateAllSelectionShapes()
updateBackgroundShapesback to summary
private void updateBackgroundShapes()
updateSingleCaretback to summary
private void updateSingleCaret(CaretNode caretNode)
updateSingleSelectionback to summary
private void updateSingleSelection(SelectionPath path)
org.fxmisc.richtext back to summary

private Class ParagraphText.BorderAttributes

extends LineAttributesBase
Class Inheritance

Field Summary

Modifier and TypeField and Description
pack-priv final StrokeType
Inherited from org.fxmisc.richtext.ParagraphText.LineAttributesBase:
colordashArraywidth

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public boolean
equals(Object obj)

Overrides org.fxmisc.richtext.ParagraphText.LineAttributesBase.equals.

Indicates whether some other object is "equal to" this one.

public boolean
equalsFaster(ParagraphText.BorderAttributes attr)

Same as equals(Object) but no need to check the object for its class

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

Inherited from org.fxmisc.richtext.ParagraphText.LineAttributesBase:
equalsFastergetSubStringisNullValue

Field Detail

typeback to summary
pack-priv final StrokeType type

Constructor Detail

BorderAttributesback to summary
pack-priv BorderAttributes(TextExt text)

Method Detail

equalsback to summary
public boolean equals(Object obj)

Overrides org.fxmisc.richtext.ParagraphText.LineAttributesBase.equals.

Doc from java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

The equals method implements an equivalence relation on non-null object references:

  • It is reflexive: for any non-null reference value x, x.equals(x) should return true.
  • It is symmetric: for any non-null reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any non-null reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.
  • It is consistent: for any non-null reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the objects is modified.
  • For any non-null reference value x, x.equals(null) should return false.

An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.

Annotations
@Override
equalsFasterback to summary
public boolean equalsFaster(ParagraphText.BorderAttributes attr)

Same as equals(Object) but no need to check the object for its class

toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Annotations
@Override
org.fxmisc.richtext back to summary

private Class ParagraphText.CustomCssShapeHelper<T>

extends Object
Class Inheritance

Field Summary

Modifier and TypeField and Description
private final Consumer<Path>
private final Consumer<Collection<Path>>
private final BiConsumer<Path, Tuple2<T, IndexRange>>
private final Supplier<Path>
private final List<Tuple2<T, IndexRange>>
private final List<Path>

Constructor Summary

AccessConstructor and Description
pack-priv
CustomCssShapeHelper(Supplier<Path> createShape, BiConsumer<Path, Tuple2<T, IndexRange>> configureShape, Consumer<Path> addToChildren, Consumer<Collection<Path>> clearUnusedShapes)

Method Summary

Modifier and TypeMethod and Description
private void
updateSharedShapeRange(T value, int start, int end, BiFunction<T, T, Boolean> equals)

Calculates the range of a value (background color, underline, etc.) that is shared between multiple consecutive TextExt nodes

private void
updateSharedShapes()

Updates the shapes calculated in updateSharedShapeRange(Object, int, int, BiFunction) and configures them via configureShape.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

addToChildrenback to summary
private final Consumer<Path> addToChildren
clearUnusedShapesback to summary
private final Consumer<Collection<Path>> clearUnusedShapes
configureShapeback to summary
private final BiConsumer<Path, Tuple2<T, IndexRange>> configureShape
createShapeback to summary
private final Supplier<Path> createShape
rangesback to summary
private final List<Tuple2<T, IndexRange>> ranges
shapesback to summary
private final List<Path> shapes

Constructor Detail

CustomCssShapeHelperback to summary
pack-priv CustomCssShapeHelper(Supplier<Path> createShape, BiConsumer<Path, Tuple2<T, IndexRange>> configureShape, Consumer<Path> addToChildren, Consumer<Collection<Path>> clearUnusedShapes)

Method Detail

updateSharedShapeRangeback to summary
private void updateSharedShapeRange(T value, int start, int end, BiFunction<T, T, Boolean> equals)

Calculates the range of a value (background color, underline, etc.) that is shared between multiple consecutive TextExt nodes

updateSharedShapesback to summary
private void updateSharedShapes()

Updates the shapes calculated in updateSharedShapeRange(Object, int, int, BiFunction) and configures them via configureShape.

org.fxmisc.richtext back to summary

private Class ParagraphText.LineAttributesBase

extends Object
Class Inheritance
Known Direct Subclasses
org.fxmisc.richtext.ParagraphText.BorderAttributes, org.fxmisc.richtext.ParagraphText.UnderlineAttributes

Field Summary

Modifier and TypeField and Description
pack-priv final Paint
pack-priv final Double[]
pack-priv final double

Constructor Summary

AccessConstructor and Description
pack-priv
LineAttributesBase(Paint color, Number width, ObjectProperty<Number[]> dashArrayProp)

Java Quirk!

Method Summary

Modifier and TypeMethod and Description
public boolean
equals(Object obj)

Overrides java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

public boolean
equalsFaster(ParagraphText.LineAttributesBase attr)

Same as equals(Object) but no need to check the object for its class

protected final String
public final boolean
Inherited from java.lang.Object:
clonefinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

colorback to summary
pack-priv final Paint color
dashArrayback to summary
pack-priv final Double[] dashArray
widthback to summary
pack-priv final double width

Constructor Detail

LineAttributesBaseback to summary
pack-priv LineAttributesBase(Paint color, Number width, ObjectProperty<Number[]> dashArrayProp)

Java Quirk! Using t.get[border/underline]DashArray() throws a ClassCastException "Double cannot be cast to Number". However, using t.getDashArrayProperty().get() works without issue

Method Detail

equalsback to summary
public boolean equals(Object obj)

Overrides java.lang.Object.equals.

Doc from java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

The equals method implements an equivalence relation on non-null object references:

  • It is reflexive: for any non-null reference value x, x.equals(x) should return true.
  • It is symmetric: for any non-null reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any non-null reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.
  • It is consistent: for any non-null reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the objects is modified.
  • For any non-null reference value x, x.equals(null) should return false.

An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.

Annotations
@Override
equalsFasterback to summary
public boolean equalsFaster(ParagraphText.LineAttributesBase attr)

Same as equals(Object) but no need to check the object for its class

getSubStringback to summary
protected final String getSubString()
isNullValueback to summary
public final boolean isNullValue()
org.fxmisc.richtext back to summary

private Class ParagraphText.UnderlineAttributes

extends LineAttributesBase
Class Inheritance

Field Summary

Modifier and TypeField and Description
pack-priv final StrokeLineCap
pack-priv final double
pack-priv final double
pack-priv final double
Inherited from org.fxmisc.richtext.ParagraphText.LineAttributesBase:
colordashArraywidth

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public boolean
equals(Object obj)

Overrides org.fxmisc.richtext.ParagraphText.LineAttributesBase.equals.

Indicates whether some other object is "equal to" this one.

public boolean
equalsFaster(ParagraphText.UnderlineAttributes attr)

Same as equals(Object) but no need to check the object for its class

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

Inherited from org.fxmisc.richtext.ParagraphText.LineAttributesBase:
equalsFastergetSubStringisNullValue

Field Detail

capback to summary
pack-priv final StrokeLineCap cap
doubleGapback to summary
pack-priv final double doubleGap
offsetback to summary
pack-priv final double offset
waveRadiusback to summary
pack-priv final double waveRadius

Constructor Detail

UnderlineAttributesback to summary
pack-priv UnderlineAttributes(TextExt text)

Method Detail

equalsback to summary
public boolean equals(Object obj)

Overrides org.fxmisc.richtext.ParagraphText.LineAttributesBase.equals.

Doc from java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

The equals method implements an equivalence relation on non-null object references:

  • It is reflexive: for any non-null reference value x, x.equals(x) should return true.
  • It is symmetric: for any non-null reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any non-null reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.
  • It is consistent: for any non-null reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the objects is modified.
  • For any non-null reference value x, x.equals(null) should return false.

An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.

Annotations
@Override
equalsFasterback to summary
public boolean equalsFaster(ParagraphText.UnderlineAttributes attr)

Same as equals(Object) but no need to check the object for its class

toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Annotations
@Override