public class VirtualFlow<T extends IndexedCell>
extends Region
javafx.scene.control.ListView
, javafx.scene.control.TreeView
,
javafx.scene.control.TableView
, and javafx.scene.control.TreeTableView
.Type | Property and Description |
---|---|
IntegerProperty |
cellCount
Indicates the number of cells that should be in the flow.
|
<any> |
cellFactory
Setting a custom cell factory has the effect of deferring all cell
creation, allowing for total customization of the cell.
|
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.
|
BooleanProperty |
pannable
Indicates whether the VirtualFlow viewport is capable of being panned
by the user (either via the mouse or touch events).
|
DoubleProperty |
position
The position of the VirtualFlow within its list of cells.
|
BooleanProperty |
vertical
Indicates the primary direction of virtualization.
|
Modifier and Type | Class and Description |
---|---|
(package private) static class |
VirtualFlow.ArrayLinkedList<T>
A List-like implementation that is exceedingly efficient for the purposes
of the VirtualFlow.
|
(package private) 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.
|
Modifier and Type | Field and Description |
---|---|
(package private) T |
accumCell
A special cell used to accumulate bounds, such that we reduce object
churn.
|
(package private) 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 <any> |
cellFactory |
(package private) VirtualFlow.ArrayLinkedList<T> |
cells
The list of cells representing those cells which actually make up the
current view.
|
(package private) VirtualFlow.ClippedContainer |
clipView
Control in which the cell's sheet is placed and forms the viewport.
|
(package private) 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 java.util.BitSet |
dirtyCells |
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 |
fixedCellSizeEnabled |
private static double |
GOLDEN_RATIO_MULTIPLIER |
private VirtualScrollBar |
hbar
The scroll bar used for scrolling horizontally.
|
private boolean |
isPanning |
(package private) double |
lastCellBreadth
The breadth of the first visible cell last time we laid out.
|
(package private) int |
lastCellCount
The number of "virtual" cells in the flow the last time it was laid out.
|
(package private) double |
lastCellLength
The length of the first visible cell last time we laid out.
|
(package private) double |
lastHeight
The height of the VirtualFlow the last time it was laid out.
|
(package private) double |
lastPosition
The position last time we laid out.
|
(package private) boolean |
lastVertical
We remember the last value for vertical the last time we laid out the
flow.
|
(package private) double |
lastWidth
The width of the VirtualFlow the last time it was laid out.
|
private double |
lastX |
private double |
lastY |
private double |
maxPrefBreadth
The maximum preferred size in the non-virtual direction.
|
private static int |
MIN_SCROLLING_LINES_PER_PAGE
Scroll events may request to scroll about a number of "lines".
|
private boolean |
mouseDown |
private boolean |
needBreadthBar |
private boolean |
needLengthBar |
private boolean |
needsCellsLayout |
private boolean |
needsRebuildCells |
private boolean |
needsReconfigureCells |
private boolean |
needsRecreateCells |
private static java.lang.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).
|
(package private) 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 java.util.List<T> |
privateCells |
(package private) KeyFrame |
sbTouchKF1 |
(package private) KeyFrame |
sbTouchKF2 |
(package private) Timeline |
sbTouchTimeline |
(package private) Group |
sheet
The group which holds the cells.
|
(package private) <any> |
sheetChildren |
private boolean |
sizeChanged |
private boolean |
tempVisibility |
private boolean |
touchDetected
*
Private fields *
*
|
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.
|
Constructor and Description |
---|
VirtualFlow()
Creates a new VirtualFlow instance.
|
Modifier and Type | Method 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).
|
(package private) 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.
|
(package private) boolean |
addTrailingCells(boolean fillEmptyCells)
Adds all the trailing cells that come after the last index in
the cells ObservableList.
|
private void |
adjustByPixelAmount(double numPixels)
Adjust the position based on a delta of pixels.
|
private void |
adjustPositionToIndex(int index) |
IntegerProperty |
cellCountProperty()
Indicates the number of cells that should be in the flow.
|
<any> |
cellFactoryProperty()
Setting a custom cell factory has the effect of deferring all cell
creation, allowing for total customization of the cell.
|
private void |
cleanPile() |
private boolean |
computeBarVisiblity() |
private int |
computeCurrentIndex() |
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) |
protected double |
computePrefWidth(double 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 void |
cull() |
private boolean |
doesCellContainFocus(<any> c) |
private void |
fitCells()
Adjusts the cells location and size if necessary.
|
DoubleProperty |
fixedCellSizeProperty()
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.
|
protected T |
getAvailableCell(int prefIndex)
Get a cell which can be used in the layout.
|
T |
getCell(int index)
Return a cell for the given index.
|
(package private) double |
getCellBreadth(Cell cell)
Gets the breadth of a specific cell
|
(package private) double |
getCellBreadth(int index) |
int |
getCellCount()
Gets the value of the property cellCount.
|
<any> |
getCellFactory()
Returns the current cell factory.
|
protected int |
getCellIndex(T cell)
Return the index for a given cell.
|
(package private) double |
getCellLength(int index)
Compute and return the length of the cell for the given index.
|
(package private) double |
getCellLength(T cell)
Gets the length of a specific cell
|
(package private) double |
getCellPosition(T cell)
Gets the layout position of the cell along the length axis
|
private java.util.List<T> |
getCells() |
T |
getFirstVisibleCell()
Locates and returns the first non-empty IndexedCell that is partially or
completely visible.
|
(package private) T |
getFirstVisibleCellWithinViewPort() |
double |
getFixedCellSize()
Gets the value of the property fixedCellSize.
|
(package private) VirtualScrollBar |
getHbar()
*
Private implementation *
*
|
T |
getLastVisibleCell()
Locates and returns the last non-empty IndexedCell that is currently
partially or completely visible.
|
(package private) T |
getLastVisibleCellWithinViewPort() |
(package private) double |
getMaxCellWidth(int rowsToCount) |
(package private) double |
getMaxPrefBreadth() |
double |
getPosition()
Gets the value of the property position.
|
private double |
getPrefBreadth(double oppDimension) |
private double |
getPrefLength() |
(package private) T |
getPrivateCell(int index)
This method is an experts-only method - if the requested index is not
already an existing visible cell, it will create a cell for the
given index and insert it into the sheet.
|
(package private) VirtualScrollBar |
getVbar() |
private double |
getViewportBreadth() |
(package private) double |
getViewportLength() |
T |
getVisibleCell(int index)
Gets a cell for the given index if the cell has been created and laid out.
|
private void |
initViewport() |
boolean |
isPannable()
Gets the value of the property pannable.
|
boolean |
isVertical()
Gets the value of the property vertical.
|
protected void |
layoutChildren() |
BooleanProperty |
pannableProperty()
Indicates whether the VirtualFlow viewport is capable of being panned
by the user (either via the mouse or touch events).
|
private void |
positionCell(T cell,
double position) |
DoubleProperty |
positionProperty()
The position of the VirtualFlow within its list of cells.
|
(package private) void |
rebuildCells() |
(package private) void |
reconfigureCells() |
(package private) void |
recreateCells() |
private void |
releaseAllPrivateCells() |
private void |
releaseCell(T cell)
After using the accum cell, it needs to be released!
|
(package private) void |
requestCellLayout() |
void |
requestLayout()
Overridden to implement somewhat more efficient support for layout.
|
private void |
resizeCellSize(T cell) |
private void |
scrollBarOn() |
double |
scrollPixels(double 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.
|
void |
scrollTo(int index)
Adjusts the cells such that the cell in the given index will be fully visible in
the viewport.
|
void |
scrollTo(T cell)
Adjusts the cells such that the selected cell will be fully visible in
the viewport (but only just).
|
void |
scrollToBottom(T lastCell)
Adjust the position of cells so that the specified cell
will be positioned at the end of the viewport.
|
void |
scrollToTop(int 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.
|
void |
scrollToTop(T firstCell)
Adjust the position of cells so that the specified cell
will be positioned at the start of the viewport.
|
void |
setCellCount(int value)
Sets the value of the property cellCount.
|
(package private) void |
setCellDirty(int index) |
void |
setCellFactory(<any> value)
Sets a new cell factory to use in the VirtualFlow.
|
protected void |
setCellIndex(T cell,
int 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. |
void |
setFixedCellSize(double value)
Sets the value of the property fixedCellSize.
|
protected void |
setHeight(double value) |
private void |
setMaxPrefBreadth(double value) |
void |
setPannable(boolean value)
Sets the value of the property pannable.
|
void |
setPosition(double value)
Sets the value of the property position.
|
void |
setVertical(boolean value)
Sets the value of the property vertical.
|
private void |
setViewportBreadth(double value) |
(package private) void |
setViewportLength(double value) |
protected void |
setWidth(double value) |
private void |
startSBReleasedAnimation() |
(package private) void |
updateHbar() |
private void |
updateScrollBarsAndCells(boolean recreate) |
private void |
updateViewportDimensions() |
BooleanProperty |
verticalProperty()
Indicates the primary direction of virtualization.
|
public final BooleanProperty verticalProperty
isVertical()
,
setVertical(boolean)
public final BooleanProperty pannableProperty
isPannable()
,
setPannable(boolean)
public final IntegerProperty cellCountProperty
getCellCount()
,
setCellCount(int)
public final DoubleProperty positionProperty
getPosition()
,
setPosition(double)
public final DoubleProperty fixedCellSizeProperty
getFixedCellSize()
,
setFixedCellSize(double)
public final <any> cellFactoryProperty
Setting a custom cell factory has the effect of deferring all cell creation, allowing for total customization of the cell. Internally, the VirtualFlow is responsible for reusing cells - all that is necessary is for the custom cell factory to return from this function a cell which might be usable for representing any item in the VirtualFlow.
Refer to the Cell
class documentation for more detail.
getCellFactory()
,
#setCellFactory()
private static final int MIN_SCROLLING_LINES_PER_PAGE
private static final java.lang.String NEW_CELL
private static final double GOLDEN_RATIO_MULTIPLIER
private boolean touchDetected
private boolean mouseDown
double lastWidth
double lastHeight
int lastCellCount
boolean lastVertical
double lastPosition
double lastCellBreadth
double lastCellLength
final VirtualFlow.ArrayLinkedList<T extends IndexedCell> cells
This is package private ONLY FOR TESTING
final VirtualFlow.ArrayLinkedList<T extends IndexedCell> pile
This is package private ONLY FOR TESTING
T extends IndexedCell accumCell
Group accumCellParent
final Group sheet
final <any> sheetChildren
private VirtualScrollBar hbar
private VirtualScrollBar vbar
VirtualFlow.ClippedContainer clipView
StackPane corner
private double lastX
private double lastY
private boolean isPanning
private boolean fixedCellSizeEnabled
private boolean needsReconfigureCells
private boolean needsRecreateCells
private boolean needsRebuildCells
private boolean needsCellsLayout
private boolean sizeChanged
private final java.util.BitSet dirtyCells
Timeline sbTouchTimeline
KeyFrame sbTouchKF1
KeyFrame sbTouchKF2
private boolean needBreadthBar
private boolean needLengthBar
private boolean tempVisibility
private BooleanProperty vertical
private BooleanProperty pannable
private IntegerProperty cellCount
private DoubleProperty position
private DoubleProperty fixedCellSize
private <any> cellFactory
private double maxPrefBreadth
In general, this is the largest preferred size in the non-virtual direction that we have ever encountered. We don't reduce this size unless instructed to do so, so as to reduce the amount of scroll bar jitter. The access on this variable is package ONLY FOR TESTING.
private double viewportBreadth
private double viewportLength
private final java.util.List<T extends IndexedCell> privateCells
public final void setVertical(boolean value)
public final boolean isVertical()
public final BooleanProperty verticalProperty()
isVertical()
,
setVertical(boolean)
public final boolean isPannable()
public final void setPannable(boolean value)
public final BooleanProperty pannableProperty()
isPannable()
,
setPannable(boolean)
public final int getCellCount()
public final void setCellCount(int value)
public final IntegerProperty cellCountProperty()
getCellCount()
,
setCellCount(int)
public final double getPosition()
public final void setPosition(double value)
public final DoubleProperty positionProperty()
getPosition()
,
setPosition(double)
public final void setFixedCellSize(double value)
public final double getFixedCellSize()
public final DoubleProperty fixedCellSizeProperty()
getFixedCellSize()
,
setFixedCellSize(double)
public final void setCellFactory(<any> value)
value
- the new cell factorypublic final <any> getCellFactory()
public final <any> cellFactoryProperty()
Setting a custom cell factory has the effect of deferring all cell creation, allowing for total customization of the cell. Internally, the VirtualFlow is responsible for reusing cells - all that is necessary is for the custom cell factory to return from this function a cell which might be usable for representing any item in the VirtualFlow.
Refer to the Cell
class documentation for more detail.
getCellFactory()
,
#setCellFactory()
public void requestLayout()
protected void layoutChildren()
protected void setWidth(double value)
protected void setHeight(double value)
protected T getAvailableCell(int prefIndex)
prefIndex
- the preferred indexprotected void addAllToPile()
public T getVisibleCell(int index)
index
- the indexpublic T getLastVisibleCell()
public T getFirstVisibleCell()
public void scrollToTop(T firstCell)
firstCell
- the first cellpublic void scrollToBottom(T lastCell)
lastCell
- the last cellpublic void scrollTo(T cell)
cell
- the cellpublic void scrollTo(int index)
index
- the indexpublic void scrollToTop(int index)
index
- the indexpublic double scrollPixels(double delta)
delta
- the delta valueprotected double computePrefWidth(double height)
protected double computePrefHeight(double width)
public T getCell(int index)
index
- the indexprotected void setCellIndex(T cell, int index)
IndexedCell#updateIndex(int)
directly), so it is a perfect place
for subclasses to override if this if of interest.cell
- The cell whose index will be updated.index
- The new index for the cell.protected int getCellIndex(T cell)
cell
- the cellfinal VirtualScrollBar getHbar()
final VirtualScrollBar getVbar()
private final void setMaxPrefBreadth(double value)
final double getMaxPrefBreadth()
private final void setViewportBreadth(double value)
private final double getViewportBreadth()
void setViewportLength(double value)
double getViewportLength()
double getCellLength(int index)
double getCellBreadth(int index)
double getCellLength(T cell)
double getCellBreadth(Cell cell)
double getCellPosition(T cell)
private void positionCell(T cell, double position)
private void resizeCellSize(T cell)
private java.util.List<T> getCells()
T getLastVisibleCellWithinViewPort()
T getFirstVisibleCellWithinViewPort()
void addLeadingCells(int currentIndex, double startOffset)
boolean addTrailingCells(boolean fillEmptyCells)
void reconfigureCells()
void recreateCells()
void rebuildCells()
void requestCellLayout()
void setCellDirty(int index)
private void startSBReleasedAnimation()
private void scrollBarOn()
void updateHbar()
private boolean computeBarVisiblity()
private void updateViewportDimensions()
private void initViewport()
private void updateScrollBarsAndCells(boolean recreate)
private void fitCells()
private void cull()
private void releaseCell(T cell)
T getPrivateCell(int index)
private void releaseAllPrivateCells()
private void addToPile(T cell)
private void cleanPile()
private boolean doesCellContainFocus(<any> c)
private double getPrefBreadth(double oppDimension)
private double getPrefLength()
double getMaxCellWidth(int rowsToCount)
private double computeViewportOffset(double position)
private void adjustPositionToIndex(int index)
private void adjustByPixelAmount(double numPixels)
private int computeCurrentIndex()
private double computeOffsetForCell(int itemIndex)