Top Description Inners Fields Constructors Methods
javafx.scene.control.skin

public Class VirtualFlow<T extends IndexedCell<T>>

extends Region
Class Inheritance
Type Parameters
<T>
The type of the item contained within the virtual flow cells
Imports
com.sun.javafx.scene.ParentHelper, com.sun.javafx.scene.control.Logging, .Properties, .VirtualScrollBar, com.sun.javafx.scene.control.skin.Utils, com.sun.javafx.scene.traversal.Algorithm, .Direction, .ParentTraversalEngine, .TraversalContext, javafx.animation.KeyFrame, .Timeline, javafx.beans.InvalidationListener, .Observable, javafx.beans.property.BooleanProperty, .BooleanPropertyBase, .DoubleProperty, .IntegerProperty, .ObjectProperty, .SimpleBooleanProperty, .SimpleDoubleProperty, .SimpleIntegerProperty, .SimpleObjectProperty, javafx.beans.value.ChangeListener, javafx.collections.ObservableList, javafx.event.EventDispatcher, .EventHandler, javafx.geometry.Orientation, javafx.scene.AccessibleRole, .Group, .Node, .Parent, .Scene, javafx.scene.control.Cell, .IndexedCell, .ScrollBar, javafx.scene.input.MouseEvent, .ScrollEvent, javafx.scene.layout.Region, .StackPane, javafx.scene.shape.Rectangle, javafx.util.Callback, .Duration, com.sun.javafx.logging.PlatformLogger, java.util.AbstractList, .ArrayList, .BitSet, .List

Implementation of a virtualized container using a cell based mechanism. This is used by the skin implementations for UI controls such as javafx.scene.control.ListView, javafx.scene.control.TreeView, javafx.scene.control.TableView, and javafx.scene.control.TreeTableView.
Since
9

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv static class
VirtualFlow.ArrayLinkedList<T>

A List-like implementation that is exceedingly efficient for the purposes of the VirtualFlow.

pack-priv static class
VirtualFlow.ClippedContainer

A simple extension to Region that ensures that anything wanting to flow outside of the bounds of the Region is clipped.

Field Summary

Modifier and TypeField and Description
pack-priv double
absoluteOffset

The offset in pixels between the top of the virtualFlow and the content it shows.

pack-priv T
accumCell

A special cell used to accumulate bounds, such that we reduce object churn.

pack-priv Group
accumCellParent

This group is used for holding the 'accumCell'.

private IntegerProperty
cellCount

Indicates the number of cells that should be in the flow.

private ObjectProperty<Callback<VirtualFlow<T>, T>>
pack-priv final VirtualFlow.ArrayLinkedList<T>
cells

The list of cells representing those cells which actually make up the current view.

private final Rectangle
pack-priv VirtualFlow.ClippedContainer
clipView

Control in which the cell's sheet is placed and forms the viewport.

pack-priv StackPane
corner

When both the horizontal and vertical scroll bars are visible, we have to 'fill in' the bottom right corner where the two scroll bars meet.

private static final int
DEFAULT_IMPROVEMENT

The default improvement for the estimation of the total size.

private final BitSet
pack-priv double
estimatedSize

An estimation of the total size (height for vertical, width for horizontal).

private DoubleProperty
fixedCellSize

For optimisation purposes, some use cases can trade dynamic cell length for speed - if fixedCellSize is greater than zero we'll use that rather than determine it by querying the cell itself.

private boolean
private static final double
private VirtualScrollBar
hbar

The scroll bar used for scrolling horizontally.

private boolean
private ArrayList<Double>
itemSizeCache

A list containing the cached version of the calculated size (height for vertical, width for horizontal) for a (fictive or real) cell for each element of the backing data.

pack-priv double
lastCellBreadth

The breadth of the first visible cell last time we laid out.

pack-priv int
lastCellCount

The number of "virtual" cells in the flow the last time it was laid out.

pack-priv double
lastCellLength

The length of the first visible cell last time we laid out.

pack-priv double
lastHeight

The height of the VirtualFlow the last time it was laid out.

pack-priv double
lastPosition

The position last time we laid out.

pack-priv boolean
lastVertical

We remember the last value for vertical the last time we laid out the flow.

pack-priv double
lastWidth

The width of the VirtualFlow the last time it was laid out.

private double
private double
private double
maxPrefBreadth

The maximum preferred size in the non-virtual direction.

private static final int
MIN_SCROLLING_LINES_PER_PAGE

Scroll events may request to scroll about a number of "lines".

private boolean
private boolean
private boolean
private boolean
private boolean
private boolean
private boolean
private static final String
NEW_CELL

Indicates that this is a newly created cell and we need call processCSS for it.

private BooleanProperty
pannable

Indicates whether the VirtualFlow viewport is capable of being panned by the user (either via the mouse or touch events).

pack-priv final VirtualFlow.ArrayLinkedList<T>
pile

A structure containing cells that can be reused later.

private DoubleProperty
position

The position of the VirtualFlow within its list of cells.

private final List<T>
private boolean
pack-priv KeyFrame
pack-priv KeyFrame
pack-priv Timeline
pack-priv final Group
sheet

The group which holds the cells.

pack-priv final ObservableList<Node>
private boolean
private boolean
private boolean
private boolean
private VirtualScrollBar
vbar

The scroll bar used to scrolling vertically.

private BooleanProperty
vertical

Indicates the primary direction of virtualization.

private double
viewportBreadth

The breadth of the viewport portion of the VirtualFlow as computed during the layout pass.

private double
viewportLength

The length of the viewport portion of the VirtualFlow as computed during the layout pass.

Inherited from javafx.scene.layout.Region:
USE_COMPUTED_SIZEUSE_PREF_SIZE

Constructor Summary

AccessConstructor and Description
public
VirtualFlow()

Creates a new VirtualFlow instance.

Method Summary

Modifier and TypeMethod and Description
protected void
addAllToPile()

This method will remove all cells from the VirtualFlow and remove them, adding them to the 'pile' (that is, a place from where cells can be used at a later date).

pack-priv void
addLeadingCells(int currentIndex, double startOffset)

Adds all the cells prior to and including the given currentIndex, until no more can be added without falling off the flow.

private void
addToPile(T cell)

Puts the given cell onto the pile.

pack-priv boolean
addTrailingCells(boolean fillEmptyCells)

Adds all the trailing cells that come after the last index in the cells ObservableList.

pack-priv void
adjustAbsoluteOffset()

Keep the position constant and adjust the absoluteOffset to match the (new) position.

private double

Returns:

the actual number of pixels that have been applied
adjustByPixelAmount
(double numPixels)

Adjust the position based on a delta of pixels.

pack-priv void
adjustPosition()

Keep the absoluteOffset constant and adjust the position to match the (new) absoluteOffset.

private void
public final IntegerProperty
public final ObjectProperty<Callback<VirtualFlow<T>, T>>

Returns:

the cell factory property
cellFactoryProperty
()

Setting a custom cell factory has the effect of deferring all cell creation, allowing for total customization of the cell.

private void
private boolean
computeBarVisiblity()

Returns: true if bar visibility changed

private double
computeBaseOffset(int index)

pack-priv int
computeCurrentIndex()

Compute the index of the first visible cell This has package access ONLY FOR TESTING.

private int
computeCurrentIndex(int currentCellCount)

private double
computeOffsetForCell(int itemIndex)

Given an item index, this function will compute and return the viewport offset from the beginning of the specified item.

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
computeViewportOffset(double position)

Given a position value between 0 and 1, compute and return the viewport offset from the "current" cell associated with that position value.

private double
computeViewportOffset(double position, int localCellCount)

private void
cull()

private boolean
private void
fitCells()

Adjusts the cells location and size if necessary.

public final DoubleProperty
protected T

Returns:

the available cell
getAvailableCell
(int
the preferred index
prefIndex
)

Get a cell which can be used in the layout.

public T

Returns:

the cell
getCell
(int
the index
index
)

Return a cell for the given index.

pack-priv double
getCellBreadth(int index)

pack-priv double
getCellBreadth(T cell)

Gets the breadth of a specific cell

public final int
public final Callback<VirtualFlow<T>, T>

Returns:

the current cell factory
getCellFactory
()

Returns the current cell factory.

protected int

Returns:

the index
getCellIndex
(T
the cell
cell
)

Return the index for a given cell.

pack-priv double
getCellLength(int index)

Compute and return the length of the cell for the given index.

pack-priv double
getCellLength(T cell)

Gets the length of a specific cell

pack-priv double
getCellPosition(T cell)

Gets the layout position of the cell along the length axis

protected List<T>

Returns:

the cells displayed in the current viewport
getCells
()

Returns the list of cells displayed in the current viewport.

pack-priv double
getCellSize(int idx)

pack-priv void
getCellSizesInExpectedViewport(int
the index of the cell that should be positioned at the top of the viewport in the next layout cycle.
index
)

Make sure the sizes of the cells that are likely to be visible are known.

public T

Returns:

the first visible cell
getFirstVisibleCell
()

Locates and returns the first non-empty IndexedCell that is partially or completely visible.

protected T

Returns:

first visible cell whose bounds are entirely within the viewport
getFirstVisibleCellWithinViewport
()

Returns the first visible cell whose bounds are entirely within the viewport.

public final double
protected final ScrollBar

Returns:

the scroll bar used for scrolling horizontally
getHbar
()

Returns the scroll bar used for scrolling horizontally.

public T

Returns:

the last visible cell
getLastVisibleCell
()

Locates and returns the last non-empty IndexedCell that is currently partially or completely visible.

protected T

Returns:

last visible cell whose bounds are entirely within the viewport
getLastVisibleCellWithinViewport
()

Returns the last visible cell whose bounds are entirely within the viewport.

pack-priv double
getMaxCellWidth(int rowsToCount)

pack-priv final double
pack-priv double

Returns:

the size of the element; or 1 in case there are no cells yet
getOrCreateCellSize
(int idx)

Get the size of the considered element.

private double
getOrCreateCellSize(int idx, boolean create)

public final double
private double
getPrefBreadth(double oppDimension)

private double
protected T

Returns:

a cell for the given index inserted in the VirtualFlow container
getPrivateCell
(int
the cell index
index
)

Creates and returns a new cell for the given index.

protected final ScrollBar

Returns:

the scroll bar used for scrolling vertically
getVbar
()

Returns the scroll bar used for scrolling vertically.

pack-priv final double
public double

Returns:

the viewport length in pixels
getViewportLength
()

Returns the length of the viewport portion of the VirtualFlow as computed during the layout pass.

public T

Returns:

the visible cell
getVisibleCell
(int
the index
index
)

Gets a cell for the given index if the cell has been created and laid out.

private void
public final boolean
public final boolean
protected void
layoutChildren()

Overrides javafx.scene.Parent.layoutChildren.

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

public final BooleanProperty
private void
positionCell(T cell, double position)

public final DoubleProperty
protected void
rebuildCells()

Informs the VirtualFlow that a layout pass should be done, and cell contents have changed.

private void
private void
recalculateAndImproveEstimatedSize(int improve, int oldIndex, double oldOffset)

Recalculate the estimated size.

private void
recalculateEstimatedSize()

Recalculate the estimated size for this list based on what we have in the cache.

protected void
reconfigureCells()

Informs the VirtualFlow that a layout pass should be done, and the cell contents have not changed.

protected void
recreateCells()

Informs the VirtualFlow that a layout pass should be done, and that the cell factory has changed.

private void
private void
releaseCell(T cell)

After using the accum cell, it needs to be released!

protected void
requestCellLayout()

Informs the VirtualFlow that a layout pass should be done and only the cell layout will be requested.

public void
requestLayout()

Overrides javafx.scene.Parent.requestLayout.

Overridden to implement somewhat more efficient support for layout.

private void
resetIndex(VirtualFlow.ArrayLinkedList<T>
the cells
cells
)

Resets the index to -1 to all cells.

private void
protected void
resizeCell(T
the cell to resize
cell
)

Resizes the given cell.

private void
public double

Returns:

the number of pixels actually moved
scrollPixels
(final double
the delta value
delta
)

Given a delta value representing a number of pixels, this method attempts to move the VirtualFlow in the given direction (positive is down/right, negative is up/left) the given number of pixels.

public void
scrollTo(T
the cell
cell
)

Adjusts the cells such that the selected cell will be fully visible in the viewport (but only just).

public void
scrollTo(int
the index
index
)

Adjusts the cells such that the cell in the given index will be fully visible in the viewport.

public void
scrollToBottom(T
the last cell
lastCell
)

Adjust the position of cells so that the specified cell will be positioned at the end of the viewport.

public void
scrollToTop(T
the first cell
firstCell
)

Adjust the position of cells so that the specified cell will be positioned at the start of the viewport.

public void
scrollToTop(int
the index
index
)

Adjusts the cells such that the cell in the given index will be fully visible in the viewport, and positioned at the very top of the viewport.

public final void
setCellCount(int value)

pack-priv void
setCellDirty(int index)

public final void
setCellFactory(Callback<VirtualFlow<T>, T>
the new cell factory
value
)

Sets a new cell factory to use in the VirtualFlow.

protected void
setCellIndex(T
The cell whose index will be updated.
cell
,
int
The new index for the cell.
index
)

The VirtualFlow uses this method to set a cells index (rather than calling IndexedCell#updateIndex(int) directly), so it is a perfect place for subclasses to override if this if of interest.

private void
setClipLayoutX(double x)

private void
setClipLayoutY(double y)

public final void
setFixedCellSize(final double value)

protected void
private final void
setMaxPrefBreadth(double value)

public final void
setPannable(boolean value)

public final void
setPosition(double value)

pack-priv void
setSuppressBreadthBar(boolean suppress)

Suppresses the breadth bar from appearing.

public final void
setVertical(boolean value)

private final void
setViewportBreadth(double value)

pack-priv void
setViewportLength(double value)

protected void
private void
shiftDown()

In case we are not rendering the first cell AND there is empty room after the last cell, the cells need to be shifted down to fill the empty area.

private void
private boolean
tryScrollOneCell(int targetIndex, boolean downOrRight)

pack-priv void
updateCellSize(T
the cell which size has to be calculated
cell
)

Update the size of a specific cell.

pack-priv void
private void
updateScrollBarsAndCells(boolean recreate)

private void
public final BooleanProperty
Inherited from javafx.scene.layout.Region:
backgroundPropertyborderPropertycacheShapePropertycenterShapePropertycomputeMaxHeightcomputeMaxWidthcomputeMinHeightcomputeMinWidthgetBackgroundgetBordergetClassCssMetaDatagetCssMetaDatagetHeightgetInsetsgetMaxHeightgetMaxWidthgetMinHeightgetMinWidthgetOpaqueInsetsgetPaddinggetPrefHeightgetPrefWidthgetShapegetUserAgentStylesheetgetWidthheightPropertyinsetsPropertyisCacheShapeisCenterShapeisResizableisScaleShapeisSnapToPixellayoutInArealayoutInArealayoutInArealayoutInAreamaxHeightmaxHeightPropertymaxWidthmaxWidthPropertyminHeightminHeightPropertyminWidthminWidthPropertyopaqueInsetsPropertypaddingPropertypositionInAreapositionInAreaprefHeightprefHeightPropertyprefWidthprefWidthPropertyresizescaleShapePropertysetBackgroundsetBordersetCacheShapesetCenterShapesetMaxHeightsetMaxSizesetMaxWidthsetMinHeightsetMinSizesetMinWidthsetOpaqueInsetssetPaddingsetPrefHeightsetPrefSizesetPrefWidthsetScaleShapesetShapesetSnapToPixelshapePropertysnappedBottomInsetsnappedLeftInsetsnappedRightInsetsnappedTopInsetsnapPositionsnapPositionXsnapPositionYsnapSizesnapSizeXsnapSizeYsnapSpacesnapSpaceXsnapSpaceYsnapToPixelPropertywidthProperty