Top Description Inners Fields Constructors Methods
org.jabref.htmltonode.internal

public final Class HighlightTextFlow

extends TextFlow
Class Inheritance
Imports
java.util.ArrayList, .List, javafx.scene.Cursor, .Group, .Node, javafx.scene.paint.Color, .Paint, javafx.scene.shape.Path, .PathElement, javafx.scene.text.Text, .TextFlow

A TextFlow that can paint real background rectangles behind character ranges — used for <mark>/background-color runs (JabRef's search-hit highlighting) and for the text selection driven by TextSelection.

The backgrounds live in unmanaged, mouse-transparent Groups that are the first children, so they render behind the text and are ignored by the flow's text layout. Shapes are recomputed from TextFlow#rangeShape after every layout pass.

Character indices are relative to the flow's text layout: each Text child contributes its text length, every other managed child (e.g. an embedded image) counts as one character.

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static record

Field Summary

Modifier and TypeField and Description
private final Group
private final List<HighlightTextFlow.HighlightRange>
private static final Paint
SELECTION_FILL

Fallback selection color; the stylesheet overrides it via .html-selection

private int
private final Group
private int

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
addHighlight(int start, int end, Paint fill)

public int
charLength()

Returns: the total character length of this flow's text layout

public void
protected void
layoutChildren()

Overrides javafx.scene.text.TextFlow.layoutChildren.

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

private void
public void
setSelectionRange(int start, int end)

Marks [start, end) as selected (replacing any previous selection of this flow).

public String
textInRange(int start, int end)

Extracts the text of [start, end); non-text children (images) contribute nothing.

Inherited from javafx.scene.text.TextFlow:
caretShapecomputeMinHeightcomputePrefHeightcomputePrefWidthgetBaselineOffsetgetCaretShapegetClassCssMetaDatagetContentBiasgetCssMetaDatagetHitInfogetLayoutInfogetLineSpacinggetRangeShapegetStrikeThroughShapegetTabSizegetTabStopPolicygetTextAlignmentgetUnderlineShapehitTestlineSpacingPropertyqueryAccessibleAttributerangeShaperequestLayoutsetLineSpacingsetTabSizesetTabStopPolicysetTextAlignmentsetWidthtabSizePropertytabStopPolicyPropertytextAlignmentPropertyunderlineShapeusesMirroring

Field Detail

highlightLayerback to summary
private final Group highlightLayer
rangesback to summary
private final List<HighlightTextFlow.HighlightRange> ranges
SELECTION_FILLback to summary
private static final Paint SELECTION_FILL

Fallback selection color; the stylesheet overrides it via .html-selection

selectionEndback to summary
private int selectionEnd
selectionLayerback to summary
private final Group selectionLayer
selectionStartback to summary
private int selectionStart

Constructor Detail

HighlightTextFlowback to summary
public HighlightTextFlow()

Method Detail

addHighlightback to summary
public void addHighlight(int start, int end, Paint fill)
charLengthback to summary
public int charLength()
Returns:int

the total character length of this flow's text layout

clearSelectionRangeback to summary
public void clearSelectionRange()
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
layoutRangeLayerback to summary
private void layoutRangeLayer(Group layer, List<HighlightTextFlow.HighlightRange> layerRanges)
setSelectionRangeback to summary
public void setSelectionRange(int start, int end)

Marks [start, end) as selected (replacing any previous selection of this flow).

textInRangeback to summary
public String textInRange(int start, int end)

Extracts the text of [start, end); non-text children (images) contribute nothing.

org.jabref.htmltonode.internal back to summary

private final Record HighlightTextFlow.HighlightRange

extends Record
Class Inheritance
Record Components
start:int 
end:int 
fill:Paint 

Field Summary

Modifier and TypeField and Description
private final int
end

Record Component accessed by end().

private final Paint
fill

Record Component accessed by fill().

private final int
start

Record Component accessed by start().

Constructor Summary

AccessConstructor and Description
private
HighlightRange(int start, int end, Paint fill)

Method Summary

Modifier and TypeMethod and Description
public int
end()

Record Component getter of end.

public final boolean
equals(Object o)

Implements abstract java.lang.Record.equals.

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

public Paint
fill()

Record Component getter of fill.

public final int
hashCode()

Implements abstract java.lang.Record.hashCode.

Returns a hash code value for the record.

public int
start()

Record Component getter of start.

public final String
toString()

Implements abstract java.lang.Record.toString.

Returns a string representation of the record.

Field Detail

endback to summary
private final int end

Record Component accessed by end().

fillback to summary
private final Paint fill

Record Component accessed by fill().

startback to summary
private final int start

Record Component accessed by start().

Constructor Detail

HighlightRangeback to summary
private HighlightRange(int start, int end, Paint fill)

Method Detail

endback to summary
public int end()

Record Component getter of end.

equalsback to summary
public final boolean equals(Object o)

Implements abstract java.lang.Record.equals.

Doc from java.lang.Record.equals.

Indicates whether some other object is "equal to" this one. In addition to the general contract of Object.equals, record classes must further obey the invariant that when a record instance is "copied" by passing the result of the record component accessor methods to the canonical constructor, as follows:

    R copy = new R(r.c1(), r.c2(), ..., r.cn());
then it must be the case that r.equals(copy).
fillback to summary
public Paint fill()

Record Component getter of fill.

hashCodeback to summary
public final int hashCode()

Implements abstract java.lang.Record.hashCode.

Doc from java.lang.Record.hashCode.

Returns a hash code value for the record. Obeys the general contract of Object.hashCode. For records, hashing behavior is constrained by the refined contract of Record.equals, so that any two records created from the same components must have the same hash code.

startback to summary
public int start()

Record Component getter of start.

toStringback to summary
public final String toString()

Implements abstract java.lang.Record.toString.

Doc from java.lang.Record.toString.

Returns a string representation of the record. In accordance with the general contract of Object#toString(), the toString method returns a string that "textually represents" this record. The result should be a concise but informative representation that is easy for a person to read.

In addition to this general contract, record classes must further participate in the invariant that any two records which are equal must produce equal strings. This invariant is necessarily relaxed in the rare case where corresponding equal component values might fail to produce equal strings for themselves.