Top Description Fields Constructors Methods
com.sun.jfx.incubator.scene.control.richtext

public Class VFlow

extends Pane
implements StyleResolver, Listener
Class Inheritance
All Implemented Interfaces
jfx.incubator.scene.control.richtext.model.StyledTextModel.Listener, jfx.incubator.scene.control.richtext.StyleResolver
Imports
java.util.List, java.util.function.Consumer, .Supplier, javafx.animation.Animation, .KeyFrame, .Timeline, javafx.application.Platform, javafx.beans.binding.BooleanBinding, javafx.beans.property.ReadOnlyObjectWrapper, .ReadOnlyProperty, .SimpleBooleanProperty, .SimpleDoubleProperty, javafx.event.EventType, javafx.geometry.Insets, .NodeOrientation, javafx.scene.Node, .Parent, javafx.scene.control.ScrollBar, javafx.scene.image.WritableImage, javafx.scene.input.MouseEvent, javafx.scene.layout.Pane, .Region, javafx.scene.shape.LineTo, .MoveTo, .Path, .PathElement, javafx.scene.text.Text, .TextFlow, javafx.util.Duration, com.sun.jfx.incubator.scene.control.richtext.util.RichUtils, jfx.incubator.scene.control.richtext.RichTextArea, .SideDecorator, .StyleResolver, .TextPos, jfx.incubator.scene.control.richtext.model.ContentChange, .ParagraphDirection, .RichParagraph, .StyleAttributeMap, .StyledSegment, .StyledTextModel, jfx.incubator.scene.control.richtext.skin.RichTextAreaSkin

Contains all the parts representing the visuals of the RichTextAreaSkin. Component hierarchy (all the way to the top):
  RichTextArea (Region) .rich-text-area
 *    └─ VFlow (Pane) .flow
 *        ├─ left gutter (ClippedPane) .left-side
 *        ├─ right gutter (ClippedPane) .right-side
 *        ├─ vertical ScrollBar
 *        ├─ horizontal ScrollBar
        └─ view port (ClippedPane) .vport
            └─ content (StackPane) .content
                ├─ caret (Path) .caret
                ├─ cells[]
                ├─ selection highlight (Path) .selection-highlight
                └─ caret line highlight (Path) .caret-line
 

Field Summary

Modifier and TypeField and Description
private CellArrangement
private final Timeline
private final Path
private final Path
private final SimpleBooleanProperty
private final FastCache<TextCell>
private final Pane
private double
private double
private double
private double
private static final VFlowCellContext
private final RichTextArea
private boolean
private boolean
private final ScrollBar
private boolean
private FastCache<Node>
private final ClippedPane
private double
private static final Text
private final SimpleDoubleProperty
private final ReadOnlyObjectWrapper<Origin>
private FastCache<Node>
private final ClippedPane
private double
private final Path
private final RichTextAreaSkin
private final SimpleBooleanProperty
private double
private double
private double
private final ClippedPane
private boolean
private final ScrollBar

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
protected CellArrangement
arrangement()

returns a non-null layout, laying out cells if necessary

protected void
private Origin
protected double
computePrefHeight(double width)

Overrides javafx.scene.layout.Region.computePrefHeight.

Computes the preferred height of this region for the given width; Region subclasses should override this method to return an appropriate value based on their content and layout strategy.

protected double
computePrefWidth(double height)

Overrides javafx.scene.layout.Region.computePrefWidth.

Computes the preferred width of this region for the given height.

private double
public final Insets

Returns:

the content padding
contentPadding
()

Returns control's content padding, always non-null.

private double
contentWidth()

returns the content width, including padding and horizontal guard, snapped

protected void
protected void
protected void
private TextCell
createTextCell(int index, RichParagraph par)

private Text
public void
private static double
fromScrollBarValue(double val, double visible, double max)

inverse of toScrollBarValue, returns the scroll bar value that takes into account visible amount

protected CaretInfo
getCaretInfo(TextPos p)

in vflow.content coordinates

public CaretInfo
getCaretInfo()

returns caret sizing info using vflow.content coordinates, or null

public TextCell
getCell(int modelIndex)

public Pane
private double
public final double
public final Origin
public final int
protected PathElement[]
public PathElement[]
getRangeShape(int line, int startOffset, int endOffset)

returns the shape if both ends are at the same line, in VFlow coordinates

protected PathElement[]
public TextPos
getTextPosLocal(double localX, double localY)

uses vflow.content cooridinates

public double
public void
public void
pack-priv void
handleHeightChange()

reacts to height changes

public void
handleHorizontalScroll()

handles user moving the horizontal scroll bar

public void
private void
public void
public void
public void
public void
handleVerticalScroll()

handles user moving the vertical scroll bar

private void
pack-priv void
handleWidthChange()

reacts to width changes

public void
public void
public boolean
protected void
layoutCells()

Recomputes sliding window and lays out scrollbars, left/right sides, and viewport.

protected void
layoutChildren()

Overrides javafx.scene.Parent.layoutChildren.

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

public double
private static Text
public TextPos
moveHorizontally(boolean start, int caretIndex, int caretOffset)

public TextPos

Returns:

the new text position, or null if no movement should occur
moveVertically
(int
the current caret index
caretIndex
,
double
the target x coordinate
x
,
double
the target y coordinate
y
,
boolean
direction of the movement relative to the caret
down
)

Computes the new TextPos for the target coordinates.

public void
onContentChange(ContentChange ch)

Implements jfx.incubator.scene.control.richtext.model.StyledTextModel.Listener.onContentChange.

Informs the listener that the model content has changed.

public final ReadOnlyProperty<Origin>
originProperty()

Location of the top left corner.

public void
public void
private TextCell
prepareCell(int modelIndex, double maxWidth)

protected void
public void
requestControlLayout(boolean
if true, clears the cell cache
clearCache
)

Requests full layout with optional clearing of the cached cells.

public void
requestLayout()

Overrides javafx.scene.Parent.requestLayout.

Requests a layout pass to be performed before the next scene is rendered.

public StyleAttributeMap
resolveStyles(StyleAttributeMap attrs)

Implements jfx.incubator.scene.control.richtext.StyleResolver.resolveStyles.

Resolves CSS styles (when present) to the individual attributes declared in StyleAttributeMap.

public void
public void
public void
scrollHorizontalPixels(double delta)

private void
scrollHorizontalToVisible(double x)

x in vflow.content coordinate

public void
scrollToVisible(double x, double y)

scrolls to visible area, using vflow.content coordinates

public void
scrollVerticalFraction(double fractionOfHeight)

public void
scrollVerticalPixels(double delta)

scroll by a number of pixels, delta must not exceed the view height in absolute terms

public void
setCaretVisible(boolean on)

private final void
setOffsetX(double x)

private void
private void
public WritableImage
snapshot(Node n)

Implements jfx.incubator.scene.control.richtext.StyleResolver.snapshot.

Creates a snapshot of the specified Node to be exported or copied as an image.

public int
private static double
toScrollBarValue(double val, double visible, double max)

javafx ScrollBar is weird in that the value has a range between [min,max] regardless of visible amount.

public void
protected void
updateHorizontalScrollBar()

updates HSB in response to change in width, layout, or offsetX

private void
private FastCache<Node>
protected void
updateVerticalScrollBar()

updates VSB in response to change in height, layout, or offsetY

Inherited from javafx.scene.layout.Pane:
getChildren

Field Detail

arrangementback to summary
private CellArrangement arrangement
caretAnimationback to summary
private final Timeline caretAnimation
caretLineHighlightback to summary
private final Path caretLineHighlight
caretPathback to summary
private final Path caretPath
caretVisibleback to summary
private final SimpleBooleanProperty caretVisible
cellCacheback to summary
private final FastCache<TextCell> cellCache
contentback to summary
private final Pane content
contentPaddingBottomback to summary
private double contentPaddingBottom
contentPaddingLeftback to summary
private double contentPaddingLeft
contentPaddingRightback to summary
private double contentPaddingRight
contentPaddingTopback to summary
private double contentPaddingTop
contextback to summary
private static final VFlowCellContext context
controlback to summary
private final RichTextArea control
dirtyback to summary
private boolean dirty
handleScrollEventsback to summary
private boolean handleScrollEvents
hscrollback to summary
private final ScrollBar hscroll
inReflowback to summary
private boolean inReflow
leftCacheback to summary
private FastCache<Node> leftCache
leftGutterback to summary
private final ClippedPane leftGutter
leftSideback to summary
private double leftSide
measurerback to summary
private static final Text measurer
offsetXback to summary
private final SimpleDoubleProperty offsetX
originback to summary
private final ReadOnlyObjectWrapper<Origin> origin
rightCacheback to summary
private FastCache<Node> rightCache
rightGutterback to summary
private final ClippedPane rightGutter
rightSideback to summary
private double rightSide
selectionHighlightback to summary
private final Path selectionHighlight
skinback to summary
private final RichTextAreaSkin skin
unwrappedContentWidthback to summary
private double unwrappedContentWidth
viewPortHeightback to summary
private double viewPortHeight
viewPortWidthback to summary
private double viewPortWidth
vportback to summary
private final ClippedPane vport
vsbPressedback to summary
private boolean vsbPressed
vscrollback to summary
private final ScrollBar vscroll

Constructor Detail

VFlowback to summary
public VFlow(RichTextAreaSkin skin, ScrollBar vsb, ScrollBar hsb)

Method Detail

arrangementback to summary
protected CellArrangement arrangement()

returns a non-null layout, laying out cells if necessary

checkForExcessiveWhitespaceAtTheEndback to summary
protected void checkForExcessiveWhitespaceAtTheEnd()
computeNewOriginback to summary
private Origin computeNewOrigin(ContentChange ch)
computePrefHeightback to summary
protected double computePrefHeight(double width)

Overrides javafx.scene.layout.Region.computePrefHeight.

Doc from javafx.scene.layout.Region.computePrefHeight.

Computes the preferred height of this region for the given width; Region subclasses should override this method to return an appropriate value based on their content and layout strategy. If the subclass doesn't have a HORIZONTAL content bias, then the width parameter can be ignored.

Annotations
@Override
computePrefWidthback to summary
protected double computePrefWidth(double height)

Overrides javafx.scene.layout.Region.computePrefWidth.

Doc from javafx.scene.layout.Region.computePrefWidth.

Computes the preferred width of this region for the given height. Region subclasses should override this method to return an appropriate value based on their content and layout strategy. If the subclass doesn't have a VERTICAL content bias, then the height parameter can be ignored.

Annotations
@Override
computeSideWidthback to summary
private double computeSideWidth(SideDecorator d)
contentPaddingback to summary
public final Insets contentPadding()

Returns control's content padding, always non-null.

Returns:Insets

the content padding

contentWidthback to summary
private double contentWidth()

returns the content width, including padding and horizontal guard, snapped

createCaretPathback to summary
protected void createCaretPath(FxPathBuilder b, TextPos p)
createCurrentLineHighlightback to summary
protected void createCurrentLineHighlight(FxPathBuilder b, TextPos caret)
createSelectionHighlightback to summary
protected void createSelectionHighlight(FxPathBuilder b, TextPos start, TextPos end)
createTextCellback to summary
private TextCell createTextCell(int index, RichParagraph par)
createTextNodeback to summary
private Text createTextNode(String text, StyleAttributeMap attrs)
disposeback to summary
public void dispose()
fromScrollBarValueback to summary
private static double fromScrollBarValue(double val, double visible, double max)

inverse of toScrollBarValue, returns the scroll bar value that takes into account visible amount

getCaretInfoback to summary
protected CaretInfo getCaretInfo(TextPos p)

in vflow.content coordinates

getCaretInfoback to summary
public CaretInfo getCaretInfo()

returns caret sizing info using vflow.content coordinates, or null

getCellback to summary
public TextCell getCell(int modelIndex)
getContentPaneback to summary
public Pane getContentPane()
getLineSpacingback to summary
private double getLineSpacing(Region r)
getOffsetXback to summary
public final double getOffsetX()
getOriginback to summary
public final Origin getOrigin()
getParagraphCountback to summary
public final int getParagraphCount()
getRangeBottomback to summary
protected PathElement[] getRangeBottom()
getRangeShapeback to summary
public PathElement[] getRangeShape(int line, int startOffset, int endOffset)

returns the shape if both ends are at the same line, in VFlow coordinates

getRangeTopback to summary
protected PathElement[] getRangeTop()
getTextPosLocalback to summary
public TextPos getTextPosLocal(double localX, double localY)

uses vflow.content cooridinates

getViewPortHeightback to summary
public double getViewPortHeight()
handleContentPaddingback to summary
public void handleContentPadding()
handleDecoratorChangeback to summary
public void handleDecoratorChange()
handleHeightChangeback to summary
pack-priv void handleHeightChange()

reacts to height changes

handleHorizontalScrollback to summary
public void handleHorizontalScroll()

handles user moving the horizontal scroll bar

handleModelChangeback to summary
public void handleModelChange()
handleOriginChangeback to summary
private void handleOriginChange()
handleSelectionChangeback to summary
public void handleSelectionChange()
handleUseContentHeightback to summary
public void handleUseContentHeight()
handleUseContentWidthback to summary
public void handleUseContentWidth()
handleVerticalScrollback to summary
public void handleVerticalScroll()

handles user moving the vertical scroll bar

handleVScrollMouseEventback to summary
private void handleVScrollMouseEvent(MouseEvent ev)
handleWidthChangeback to summary
pack-priv void handleWidthChange()

reacts to width changes

handleWrapTextback to summary
public void handleWrapText()
invalidateLayoutback to summary
public void invalidateLayout()
isCaretVisibleback to summary
public boolean isCaretVisible()
layoutCellsback to summary
protected void layoutCells()

Recomputes sliding window and lays out scrollbars, left/right sides, and viewport. This process might be repeated if one of the scroll bars changes its visibility as a result. (up to 4 times worst case)

layoutChildrenback to summary
protected void layoutChildren()

Overrides javafx.scene.Parent.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
leftPaddingback to summary
public double leftPadding()
makeMeasurerback to summary
private static Text makeMeasurer()
moveHorizontallyback to summary
public TextPos moveHorizontally(boolean start, int caretIndex, int caretOffset)
moveVerticallyback to summary
public TextPos moveVertically(int caretIndex, double x, double y, boolean down)

Computes the new TextPos for the target coordinates. This method takes into account the geometry of text as determined by the layout, thus taking into account line spacing and paragraph padding and borders.

Parameters
caretIndex:int

the current caret index

x:double

the target x coordinate

y:double

the target y coordinate

down:boolean

direction of the movement relative to the caret

Returns:TextPos

the new text position, or null if no movement should occur

onContentChangeback to summary
public void onContentChange(ContentChange ch)

Implements jfx.incubator.scene.control.richtext.model.StyledTextModel.Listener.onContentChange.

Doc from jfx.incubator.scene.control.richtext.model.StyledTextModel.Listener.onContentChange.

Informs the listener that the model content has changed.

Annotations
@Override
originPropertyback to summary
public final ReadOnlyProperty<Origin> originProperty()

Location of the top left corner.

pageDownback to summary
public void pageDown()
pageUpback to summary
public void pageUp()
prepareCellback to summary
private TextCell prepareCell(int modelIndex, double maxWidth)
removeCaretAndSelectionback to summary
protected void removeCaretAndSelection()
requestControlLayoutback to summary
public void requestControlLayout(boolean clearCache)

Requests full layout with optional clearing of the cached cells.

Parameters
clearCache:boolean

if true, clears the cell cache

requestLayoutback to summary
public void requestLayout()

Overrides javafx.scene.Parent.requestLayout.

Doc from javafx.scene.Parent.requestLayout.

Requests a layout pass to be performed before the next scene is rendered. This is batched up asynchronously to happen once per "pulse", or frame of animation.

If this parent is either a layout root or unmanaged, then it will be added directly to the scene's dirty layout list, otherwise requestParentLayout will be invoked.

Annotations
@Override
resolveStylesback to summary
public StyleAttributeMap resolveStyles(StyleAttributeMap attrs)

Implements jfx.incubator.scene.control.richtext.StyleResolver.resolveStyles.

Doc from jfx.incubator.scene.control.richtext.StyleResolver.resolveStyles.

Resolves CSS styles (when present) to the individual attributes declared in StyleAttributeMap.

Annotations
@Override
scrollCaretToVisibleback to summary
public void scrollCaretToVisible()
scrollHorizontalFractionback to summary
public void scrollHorizontalFraction(double delta)
scrollHorizontalPixelsback to summary
public void scrollHorizontalPixels(double delta)
scrollHorizontalToVisibleback to summary
private void scrollHorizontalToVisible(double x)

x in vflow.content coordinate

scrollToVisibleback to summary
public void scrollToVisible(double x, double y)

scrolls to visible area, using vflow.content coordinates

scrollVerticalFractionback to summary
public void scrollVerticalFraction(double fractionOfHeight)
scrollVerticalPixelsback to summary
public void scrollVerticalPixels(double delta)

scroll by a number of pixels, delta must not exceed the view height in absolute terms

setCaretVisibleback to summary
public void setCaretVisible(boolean on)
setOffsetXback to summary
private final void setOffsetX(double x)
setOriginback to summary
private void setOrigin(Origin or)
setUnwrappedContentWidthback to summary
private void setUnwrappedContentWidth(double w)
snapshotback to summary
public WritableImage snapshot(Node n)

Implements jfx.incubator.scene.control.richtext.StyleResolver.snapshot.

Doc from jfx.incubator.scene.control.richtext.StyleResolver.snapshot.

Creates a snapshot of the specified Node to be exported or copied as an image.

Annotations
@Override
topCellIndexback to summary
public int topCellIndex()
toScrollBarValueback to summary
private static double toScrollBarValue(double val, double visible, double max)

javafx ScrollBar is weird in that the value has a range between [min,max] regardless of visible amount. this method generates the value ScrollBar expects by renormalizing it to a [min,max-visible] range, assuming min == 0.

updateCaretAndSelectionback to summary
public void updateCaretAndSelection()
updateHorizontalScrollBarback to summary
protected void updateHorizontalScrollBar()

updates HSB in response to change in width, layout, or offsetX

updatePrefWidthback to summary
private void updatePrefWidth()
updateSideCacheback to summary
private FastCache<Node> updateSideCache(SideDecorator decorator, FastCache<Node> cache)
updateVerticalScrollBarback to summary
protected void updateVerticalScrollBar()

updates VSB in response to change in height, layout, or offsetY