public class VirtualFlow<T extends IndexedCell> extends Region
Modifier and Type | Class and Description |
---|---|
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 int |
cellCount
Indicates the number of cells that should be in the flow.
|
(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 Callback<VirtualFlow,T> |
createCell
Callback which is invoked whenever the VirtualFlow needs a new
IndexedCell.
|
private java.util.BitSet |
dirtyCells |
private double |
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 impl_processCSS for it.
|
private boolean |
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 double |
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) ObservableList<Node> |
sheetChildren |
private boolean |
sizeChanged |
private boolean |
tempVisibility |
private boolean |
touchDetected |
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.
|
USE_COMPUTED_SIZE, USE_PREF_SIZE
BASELINE_OFFSET_SAME_AS_HEIGHT
Constructor and Description |
---|
VirtualFlow() |
Modifier and Type | Method and Description |
---|---|
protected void |
addAllToPile() |
protected 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.
|
protected 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.
|
double |
adjustPixels(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.
|
private void |
adjustPositionToIndex(int index) |
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)
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)
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 void |
cull() |
private boolean |
doesCellContainFocus(Cell<?> c) |
private void |
fitCells()
Adjusts the cells location and size if necessary.
|
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.
|
protected double |
getCellBreadth(Cell cell)
Gets the breadth of a specific cell
|
protected double |
getCellBreadth(int index) |
int |
getCellCount() |
protected int |
getCellIndex(T cell)
Return the index for a given cell.
|
protected double |
getCellLength(int index)
Compute and return the length of the cell for the given index.
|
protected double |
getCellLength(T cell)
Gets the length of a specific cell
|
protected double |
getCellPosition(T cell)
Gets the layout position of the cell along the length axis
|
protected java.util.List<T> |
getCells() |
Callback<VirtualFlow,T> |
getCreateCell() |
T |
getFirstVisibleCell()
Locates and returns the first non-empty IndexedCell that is partially or
completely visible.
|
T |
getFirstVisibleCellWithinViewPort() |
protected VirtualScrollBar |
getHbar() |
T |
getLastVisibleCell()
Locates and returns the last non-empty IndexedCell that is currently
partially or completely visible.
|
T |
getLastVisibleCellWithinViewPort() |
(package private) double |
getMaxCellWidth(int rowsToCount) |
protected double |
getMaxPrefBreadth() |
double |
getPosition() |
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.
|
protected VirtualScrollBar |
getVbar() |
protected double |
getViewportBreadth() |
protected 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() |
boolean |
isVertical() |
protected void |
layoutChildren()
Invoked during the layout pass to layout the children in this
Parent . |
protected void |
positionCell(T cell,
double position) |
void |
rebuildCells() |
void |
reconfigureCells() |
void |
recreateCells() |
private void |
releaseAllPrivateCells() |
private void |
releaseCell(T cell)
After using the accum cell, it needs to be released!
|
void |
requestCellLayout() |
void |
requestLayout()
Overridden to implement somewhat more efficient support for layout.
|
protected void |
resizeCellSize(T cell) |
protected void |
scrollBarOn() |
void |
scrollTo(int index) |
void |
scrollToOffset(int offset) |
void |
setCellCount(int i) |
void |
setCellDirty(int index) |
protected void |
setCellIndex(T cell,
int index) |
void |
setCreateCell(Callback<VirtualFlow,T> cc) |
void |
setFixedCellSize(double value) |
protected void |
setHeight(double value) |
protected void |
setMaxPrefBreadth(double value) |
void |
setPannable(boolean value) |
void |
setPosition(double newPosition) |
void |
setVertical(boolean value) |
protected void |
setViewportBreadth(double value) |
(package private) void |
setViewportLength(double value) |
protected void |
setWidth(double value) |
void |
show(int index) |
void |
show(T cell)
Adjusts the cells such that the selected cell will be fully visible in
the viewport (but only just).
|
void |
showAsFirst(T firstCell)
Adjust the position of cells so that the specified cell
will be positioned at the start of the viewport.
|
void |
showAsLast(T lastCell)
Adjust the position of cells so that the specified cell
will be positioned at the end of the viewport.
|
protected void |
startSBReleasedAnimation() |
(package private) void |
updateHbar() |
private void |
updateScrollBarsAndCells(boolean recreate) |
private void |
updateViewportDimensions() |
BooleanProperty |
verticalProperty() |
backgroundProperty, borderProperty, cacheShapeProperty, centerShapeProperty, computeMaxHeight, computeMaxWidth, computeMinHeight, computeMinWidth, getBackground, getBorder, getClassCssMetaData, getCssMetaData, getHeight, getInsets, getMaxHeight, getMaxWidth, getMinHeight, getMinWidth, getOpaqueInsets, getPadding, getPrefHeight, getPrefWidth, getShape, getUserAgentStylesheet, getWidth, heightProperty, impl_computeContains, impl_computeGeomBounds, impl_computeLayoutBounds, impl_createPeer, impl_notifyLayoutBoundsChanged, impl_pickNodeLocal, impl_updatePeer, insetsProperty, isCacheShape, isCenterShape, isResizable, isScaleShape, isSnapToPixel, layoutInArea, layoutInArea, layoutInArea, layoutInArea, maxHeight, maxHeightProperty, maxWidth, maxWidthProperty, minHeight, minHeightProperty, minWidth, minWidthProperty, opaqueInsetsProperty, paddingProperty, positionInArea, positionInArea, prefHeight, prefHeightProperty, prefWidth, prefWidthProperty, resize, scaleShapeProperty, setBackground, setBorder, setCacheShape, setCenterShape, setMaxHeight, setMaxSize, setMaxWidth, setMinHeight, setMinSize, setMinWidth, setOpaqueInsets, setPadding, setPrefHeight, setPrefSize, setPrefWidth, setScaleShape, setShape, setSnapToPixel, shapeProperty, snappedBottomInset, snappedLeftInset, snappedRightInset, snappedTopInset, snapPosition, snapSize, snapSpace, snapToPixelProperty, widthProperty
getBaselineOffset, getChildren, getChildrenUnmodifiable, getImpl_traversalEngine, getManagedChildren, getStylesheets, impl_getAllParentStylesheets, impl_processCSS, impl_processMXNode, impl_traversalEngineProperty, isNeedsLayout, layout, lookup, needsLayoutProperty, queryAccessibleAttribute, requestParentLayout, setImpl_traversalEngine, setNeedsLayout, updateBounds
accessibleHelpProperty, accessibleRoleDescriptionProperty, accessibleRoleProperty, accessibleTextProperty, addEventFilter, addEventHandler, applyCss, autosize, blendModeProperty, boundsInLocalProperty, boundsInParentProperty, buildEventDispatchChain, cacheHintProperty, cacheProperty, clipProperty, computeAreaInScreen, contains, contains, containsBounds, cursorProperty, depthTestProperty, disabledProperty, disableProperty, effectiveNodeOrientationProperty, effectProperty, eventDispatcherProperty, executeAccessibleAction, fireEvent, focusedProperty, focusTraversableProperty, getAccessibleHelp, getAccessibleRole, getAccessibleRoleDescription, getAccessibleText, getBlendMode, getBoundsInLocal, getBoundsInParent, getCacheHint, getClip, getContentBias, getCursor, getDepthTest, getEffect, getEffectiveNodeOrientation, getEventDispatcher, getId, getInputMethodRequests, getLayoutBounds, getLayoutX, getLayoutY, getLocalToParentTransform, getLocalToSceneTransform, getNodeOrientation, getOnContextMenuRequested, getOnDragDetected, getOnDragDone, getOnDragDropped, getOnDragEntered, getOnDragExited, getOnDragOver, getOnInputMethodTextChanged, getOnKeyPressed, getOnKeyReleased, getOnKeyTyped, getOnMouseClicked, getOnMouseDragEntered, getOnMouseDragExited, getOnMouseDragged, getOnMouseDragOver, getOnMouseDragReleased, getOnMouseEntered, getOnMouseExited, getOnMouseMoved, getOnMousePressed, getOnMouseReleased, getOnRotate, getOnRotationFinished, getOnRotationStarted, getOnScroll, getOnScrollFinished, getOnScrollStarted, getOnSwipeDown, getOnSwipeLeft, getOnSwipeRight, getOnSwipeUp, getOnTouchMoved, getOnTouchPressed, getOnTouchReleased, getOnTouchStationary, getOnZoom, getOnZoomFinished, getOnZoomStarted, getOpacity, getParent, getProperties, getPseudoClassStates, getRotate, getRotationAxis, getScaleX, getScaleY, getScaleZ, getScene, getStyle, getStyleableParent, getStyleClass, getTransforms, getTranslateX, getTranslateY, getTranslateZ, getTypeSelector, getUserData, hasProperties, hoverProperty, idProperty, impl_clearDirty, impl_computeIntersects, impl_cssGetCursorInitialValue, impl_cssGetFocusTraversableInitialValue, impl_findStyles, impl_geomChanged, impl_getLeafTransform, impl_getMatchingStyles, impl_getPeer, impl_getPivotX, impl_getPivotY, impl_getPivotZ, impl_getStyleMap, impl_hasTransforms, impl_intersects, impl_intersectsBounds, impl_isDirty, impl_isDirtyEmpty, impl_isShowMnemonics, impl_isTreeVisible, impl_layoutBoundsChanged, impl_markDirty, impl_pickNode, impl_processCSS, impl_reapplyCSS, impl_setShowMnemonics, impl_setStyleMap, impl_showMnemonicsProperty, impl_syncPeer, impl_transformsChanged, impl_traverse, impl_treeVisibleProperty, inputMethodRequestsProperty, intersects, intersects, isCache, isDisable, isDisabled, isFocused, isFocusTraversable, isHover, isManaged, isMouseTransparent, isPickOnBounds, isPressed, isVisible, layoutBoundsProperty, layoutXProperty, layoutYProperty, localToParent, localToParent, localToParent, localToParent, localToParent, localToParentTransformProperty, localToScene, localToScene, localToScene, localToScene, localToScene, localToScene, localToScene, localToScene, localToScene, localToScene, localToSceneTransformProperty, localToScreen, localToScreen, localToScreen, localToScreen, localToScreen, lookupAll, managedProperty, mouseTransparentProperty, nodeOrientationProperty, notifyAccessibleAttributeChanged, onContextMenuRequestedProperty, onDragDetectedProperty, onDragDoneProperty, onDragDroppedProperty, onDragEnteredProperty, onDragExitedProperty, onDragOverProperty, onInputMethodTextChangedProperty, onKeyPressedProperty, onKeyReleasedProperty, onKeyTypedProperty, onMouseClickedProperty, onMouseDragEnteredProperty, onMouseDragExitedProperty, onMouseDraggedProperty, onMouseDragOverProperty, onMouseDragReleasedProperty, onMouseEnteredProperty, onMouseExitedProperty, onMouseMovedProperty, onMousePressedProperty, onMouseReleasedProperty, onRotateProperty, onRotationFinishedProperty, onRotationStartedProperty, onScrollFinishedProperty, onScrollProperty, onScrollStartedProperty, onSwipeDownProperty, onSwipeLeftProperty, onSwipeRightProperty, onSwipeUpProperty, onTouchMovedProperty, onTouchPressedProperty, onTouchReleasedProperty, onTouchStationaryProperty, onZoomFinishedProperty, onZoomProperty, onZoomStartedProperty, opacityProperty, parentProperty, parentToLocal, parentToLocal, parentToLocal, parentToLocal, parentToLocal, pickOnBoundsProperty, pressedProperty, pseudoClassStateChanged, relocate, removeEventFilter, removeEventHandler, requestFocus, resizeRelocate, rotateProperty, rotationAxisProperty, scaleXProperty, scaleYProperty, scaleZProperty, sceneProperty, sceneToLocal, sceneToLocal, sceneToLocal, sceneToLocal, sceneToLocal, sceneToLocal, sceneToLocal, sceneToLocal, screenToLocal, screenToLocal, screenToLocal, setAccessibleHelp, setAccessibleRole, setAccessibleRoleDescription, setAccessibleText, setBlendMode, setCache, setCacheHint, setClip, setCursor, setDepthTest, setDisable, setDisabled, setEffect, setEventDispatcher, setEventHandler, setFocused, setFocusTraversable, setHover, setId, setInputMethodRequests, setLayoutX, setLayoutY, setManaged, setMouseTransparent, setNodeOrientation, setOnContextMenuRequested, setOnDragDetected, setOnDragDone, setOnDragDropped, setOnDragEntered, setOnDragExited, setOnDragOver, setOnInputMethodTextChanged, setOnKeyPressed, setOnKeyReleased, setOnKeyTyped, setOnMouseClicked, setOnMouseDragEntered, setOnMouseDragExited, setOnMouseDragged, setOnMouseDragOver, setOnMouseDragReleased, setOnMouseEntered, setOnMouseExited, setOnMouseMoved, setOnMousePressed, setOnMouseReleased, setOnRotate, setOnRotationFinished, setOnRotationStarted, setOnScroll, setOnScrollFinished, setOnScrollStarted, setOnSwipeDown, setOnSwipeLeft, setOnSwipeRight, setOnSwipeUp, setOnTouchMoved, setOnTouchPressed, setOnTouchReleased, setOnTouchStationary, setOnZoom, setOnZoomFinished, setOnZoomStarted, setOpacity, setPickOnBounds, setPressed, setRotate, setRotationAxis, setScaleX, setScaleY, setScaleZ, setStyle, setTranslateX, setTranslateY, setTranslateZ, setUserData, setVisible, snapshot, snapshot, startDragAndDrop, startFullDrag, styleProperty, toBack, toFront, toString, translateXProperty, translateYProperty, translateZProperty, usesMirroring, visibleProperty
private static final int MIN_SCROLLING_LINES_PER_PAGE
private boolean touchDetected
private boolean mouseDown
private BooleanProperty vertical
private boolean pannable
private int cellCount
private double position
private double fixedCellSize
private boolean fixedCellSizeEnabled
private Callback<VirtualFlow,T extends IndexedCell> createCell
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
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 ObservableList<Node> sheetChildren
private VirtualScrollBar hbar
private VirtualScrollBar vbar
VirtualFlow.ClippedContainer clipView
StackPane corner
private double lastX
private double lastY
private boolean isPanning
private final java.util.List<T extends IndexedCell> privateCells
private static final java.lang.String NEW_CELL
private boolean needsReconfigureCells
private boolean needsRecreateCells
private boolean needsRebuildCells
private boolean needsCellsLayout
private boolean sizeChanged
private final java.util.BitSet dirtyCells
private static final double GOLDEN_RATIO_MULTIPLIER
Timeline sbTouchTimeline
KeyFrame sbTouchKF1
KeyFrame sbTouchKF2
private boolean needBreadthBar
private boolean needLengthBar
private boolean tempVisibility
public final void setVertical(boolean value)
public final boolean isVertical()
public final BooleanProperty verticalProperty()
public boolean isPannable()
public void setPannable(boolean value)
public int getCellCount()
public void setCellCount(int i)
public double getPosition()
public void setPosition(double newPosition)
public void setFixedCellSize(double value)
public Callback<VirtualFlow,T> getCreateCell()
public void setCreateCell(Callback<VirtualFlow,T> cc)
protected final void setMaxPrefBreadth(double value)
protected final double getMaxPrefBreadth()
protected final void setViewportBreadth(double value)
protected final double getViewportBreadth()
void setViewportLength(double value)
protected double getViewportLength()
protected java.util.List<T> getCells()
protected final VirtualScrollBar getHbar()
protected final VirtualScrollBar getVbar()
void updateHbar()
public void requestLayout()
requestLayout
in class Parent
protected void layoutChildren()
Parent
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.
layoutChildren
in class Parent
protected void addLeadingCells(int currentIndex, double startOffset)
protected boolean addTrailingCells(boolean fillEmptyCells)
private boolean computeBarVisiblity()
private void updateViewportDimensions()
private void initViewport()
private void updateScrollBarsAndCells(boolean recreate)
private void fitCells()
private void cull()
protected int getCellIndex(T cell)
public T getCell(int index)
private void releaseCell(T cell)
T getPrivateCell(int index)
private void releaseAllPrivateCells()
protected double getCellLength(int index)
protected double getCellBreadth(int index)
protected double getCellLength(T cell)
protected double getCellBreadth(Cell cell)
protected double getCellPosition(T cell)
protected void positionCell(T cell, double position)
protected void resizeCellSize(T cell)
protected void setCellIndex(T cell, int index)
protected T getAvailableCell(int prefIndex)
protected void addAllToPile()
private void addToPile(T cell)
private void cleanPile()
private boolean doesCellContainFocus(Cell<?> c)
public T getVisibleCell(int index)
public T getLastVisibleCell()
public T getFirstVisibleCell()
public T getLastVisibleCellWithinViewPort()
public T getFirstVisibleCellWithinViewPort()
public void showAsFirst(T firstCell)
public void showAsLast(T lastCell)
public void show(T cell)
public void show(int index)
public void scrollTo(int index)
public void scrollToOffset(int offset)
public double adjustPixels(double delta)
public void reconfigureCells()
public void recreateCells()
public void rebuildCells()
public void requestCellLayout()
public void setCellDirty(int index)
private double getPrefBreadth(double oppDimension)
private double getPrefLength()
protected double computePrefWidth(double height)
Region
computePrefWidth
in class Region
height
- the height that should be used if preferred width depends
on itprotected double computePrefHeight(double width)
Region
computePrefHeight
in class Region
width
- the width that should be used if preferred height depends
on itdouble 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)
protected void startSBReleasedAnimation()
protected void scrollBarOn()