Package org.fxmisc.flowless
Class Navigator<T,C extends Cell<T,?>>
java.lang.Object
javafx.scene.Node
javafx.scene.Parent
javafx.scene.layout.Region
org.fxmisc.flowless.Navigator<T,C>
- All Implemented Interfaces:
javafx.css.Styleable
,javafx.event.EventTarget
,TargetPositionVisitor
final class Navigator<T,C extends Cell<T,?>>
extends javafx.scene.layout.Region
implements TargetPositionVisitor
Responsible for laying out cells' nodes within the viewport based on a single anchor node. In a layout call,
this anchor node is positioned in the viewport before any other node and then nodes are positioned above and
below that anchor node sequentially. This sequential layout continues until the viewport's "top" and "bottom" edges
are reached or there are no other cells' nodes to render. In this latter case (when there is not enough content to
fill up the entire viewport), the displayed cells are repositioned towards the "ground," based on the
VirtualFlow
's VirtualFlow.Gravity
value, and any remaining unused space counts as the "sky."-
Property Summary
Properties inherited from class javafx.scene.layout.Region
background, border, cacheShape, centerShape, height, insets, maxHeight, maxWidth, minHeight, minWidth, opaqueInsets, padding, prefHeight, prefWidth, scaleShape, shape, snapToPixel, width
Properties inherited from class javafx.scene.Parent
needsLayout
Properties inherited from class javafx.scene.Node
accessibleHelp, accessibleRoleDescription, accessibleRole, accessibleText, blendMode, boundsInLocal, boundsInParent, cacheHint, cache, clip, cursor, depthTest, disabled, disable, effectiveNodeOrientation, effect, eventDispatcher, focused, focusTraversable, hover, id, inputMethodRequests, layoutBounds, layoutX, layoutY, localToParentTransform, localToSceneTransform, managed, mouseTransparent, nodeOrientation, onContextMenuRequested, onDragDetected, onDragDone, onDragDropped, onDragEntered, onDragExited, onDragOver, onInputMethodTextChanged, onKeyPressed, onKeyReleased, onKeyTyped, onMouseClicked, onMouseDragEntered, onMouseDragExited, onMouseDragged, onMouseDragOver, onMouseDragReleased, onMouseEntered, onMouseExited, onMouseMoved, onMousePressed, onMouseReleased, onRotate, onRotationFinished, onRotationStarted, onScrollFinished, onScroll, onScrollStarted, onSwipeDown, onSwipeLeft, onSwipeRight, onSwipeUp, onTouchMoved, onTouchPressed, onTouchReleased, onTouchStationary, onZoomFinished, onZoom, onZoomStarted, opacity, parent, pickOnBounds, pressed, rotate, rotationAxis, scaleX, scaleY, scaleZ, scene, style, translateX, translateY, translateZ, viewOrder, visible
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final CellListManager
<T, C> private final org.reactfx.collection.MemoizationList
<C> private TargetPosition
private int
private final javafx.beans.property.ObjectProperty
<VirtualFlow.Gravity> private final org.reactfx.Subscription
private int
private final OrientationHelper
private final CellPositioner
<T, C> private final SizeTracker
private TargetPosition
Fields inherited from class javafx.scene.layout.Region
USE_COMPUTED_SIZE, USE_PREF_SIZE
Fields inherited from class javafx.scene.Node
BASELINE_OFFSET_SAME_AS_HEIGHT
-
Constructor Summary
ConstructorsConstructorDescriptionNavigator
(CellListManager<T, C> cellListManager, CellPositioner<T, C> positioner, OrientationHelper orientation, javafx.beans.property.ObjectProperty<VirtualFlow.Gravity> gravity, SizeTracker sizeTracker) -
Method Summary
Modifier and TypeMethodDescriptionprivate void
cropToNeighborhoodOf
(int itemIndex) private void
cropToNeighborhoodOf
(int itemIndex, double additionalOffset) void
dispose()
private double
distanceFromGround
(int itemIndex) private double
distanceFromSky
(int itemIndex) private int
fillBackwardFrom
(int itemIndex) private int
fillBackwardFrom
(int itemIndex, double upTo) private int
fillBackwardFrom0
(int itemIndex) (package private) int
fillBackwardFrom0
(int itemIndex, double upTo) private int
fillForwardFrom
(int itemIndex) private int
fillForwardFrom
(int itemIndex, double upTo) private int
fillForwardFrom0
(int itemIndex) (package private) int
fillForwardFrom0
(int itemIndex, double upTo) private int
fillTowardsGroundFrom0
(int itemIndex) private int
fillTowardsGroundFrom0
(int itemIndex, double upTo) private int
fillTowardsSkyFrom0
(int itemIndex) private void
fillViewportFrom
(int itemIndex) Starting from the anchor cell's node, fills the viewport from the anchor to the "ground" and then from the anchor to the "sky".private TargetPosition
int
Get the index of the first visible cell (at the time of the last layout).int
Get the index of the last visible cell (at the time of the last layout).private void
itemsChanged
(org.reactfx.collection.QuasiListChange<?> ch) protected void
private void
placeEndOffEndMayCrop
(int itemIndex, double endOffEnd) private void
placeEndOffStartMayCrop
(int itemIndex, double endOffStart) private void
placeStartAtMayCrop
(int itemIndex, double startOffStart) private void
placeStartOffEndMayCrop
(int itemIndex, double startOffEnd) private void
placeToViewport
(int itemIndex, double fromY, double toY) private void
placeToViewport
(int itemIndex, Offset from, Offset to) void
scrollCurrentPositionBy
(double delta) Sets theTargetPosition
used to layout the anchor node to the current position scrolled bydelta
and re-lays out the viewportvoid
setTargetPosition
(TargetPosition targetPosition) Sets theTargetPosition
used to layout the anchor node and re-lays out the viewportprivate void
shiftCellsTowardsGround
(int groundCellIndex, int lastCellIndex, double amount) (package private) void
showLengthRegion
(int itemIndex, double fromY, double toY) void
void
visit
(MinDistanceTo targetPosition) void
visit
(StartOffStart targetPosition) Methods inherited from class javafx.scene.layout.Region
backgroundProperty, borderProperty, cacheShapeProperty, centerShapeProperty, computeMaxHeight, computeMaxWidth, computeMinHeight, computeMinWidth, computePrefHeight, computePrefWidth, getBackground, getBorder, getClassCssMetaData, getCssMetaData, getHeight, getInsets, getMaxHeight, getMaxWidth, getMinHeight, getMinWidth, getOpaqueInsets, getPadding, getPrefHeight, getPrefWidth, getShape, getUserAgentStylesheet, getWidth, heightProperty, 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, setHeight, setMaxHeight, setMaxSize, setMaxWidth, setMinHeight, setMinSize, setMinWidth, setOpaqueInsets, setPadding, setPrefHeight, setPrefSize, setPrefWidth, setScaleShape, setShape, setSnapToPixel, setWidth, shapeProperty, snappedBottomInset, snappedLeftInset, snappedRightInset, snappedTopInset, snapPosition, snapPositionX, snapPositionY, snapSize, snapSizeX, snapSizeY, snapSpace, snapSpaceX, snapSpaceY, snapToPixelProperty, widthProperty
Methods inherited from class javafx.scene.Parent
getBaselineOffset, getChildren, getChildrenUnmodifiable, getManagedChildren, getStylesheets, isNeedsLayout, layout, lookup, needsLayoutProperty, queryAccessibleAttribute, requestLayout, requestParentLayout, setNeedsLayout, updateBounds
Methods inherited from class javafx.scene.Node
accessibleHelpProperty, accessibleRoleDescriptionProperty, accessibleRoleProperty, accessibleTextProperty, addEventFilter, addEventHandler, applyCss, autosize, blendModeProperty, boundsInLocalProperty, boundsInParentProperty, buildEventDispatchChain, cacheHintProperty, cacheProperty, clipProperty, computeAreaInScreen, contains, contains, 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, getInitialCursor, getInitialFocusTraversable, 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, getViewOrder, hasProperties, hoverProperty, idProperty, 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, setViewOrder, setVisible, snapshot, snapshot, startDragAndDrop, startFullDrag, styleProperty, toBack, toFront, toString, translateXProperty, translateYProperty, translateZProperty, usesMirroring, viewOrderProperty, visibleProperty
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface javafx.css.Styleable
getStyleableNode
-
Field Details
-
cellListManager
-
cells
-
positioner
-
orientation
-
gravity
-
sizeTracker
-
itemsSubscription
private final org.reactfx.Subscription itemsSubscription -
currentPosition
-
targetPosition
-
firstVisibleIndex
private int firstVisibleIndex -
lastVisibleIndex
private int lastVisibleIndex
-
-
Constructor Details
-
Navigator
public Navigator(CellListManager<T, C> cellListManager, CellPositioner<T, C> positioner, OrientationHelper orientation, javafx.beans.property.ObjectProperty<VirtualFlow.Gravity> gravity, SizeTracker sizeTracker)
-
-
Method Details
-
dispose
public void dispose() -
layoutChildren
protected void layoutChildren()- Overrides:
layoutChildren
in classjavafx.scene.Parent
-
setTargetPosition
Sets theTargetPosition
used to layout the anchor node and re-lays out the viewport -
scrollCurrentPositionBy
public void scrollCurrentPositionBy(double delta) Sets theTargetPosition
used to layout the anchor node to the current position scrolled bydelta
and re-lays out the viewport -
getCurrentPosition
-
itemsChanged
private void itemsChanged(org.reactfx.collection.QuasiListChange<?> ch) -
showLengthRegion
void showLengthRegion(int itemIndex, double fromY, double toY) -
visit
- Specified by:
visit
in interfaceTargetPositionVisitor
-
visit
- Specified by:
visit
in interfaceTargetPositionVisitor
-
cropToNeighborhoodOf
private void cropToNeighborhoodOf(int itemIndex) -
visit
- Specified by:
visit
in interfaceTargetPositionVisitor
-
getFirstVisibleIndex
public int getFirstVisibleIndex()Get the index of the first visible cell (at the time of the last layout).- Returns:
- The index of the first visible cell
-
getLastVisibleIndex
public int getLastVisibleIndex()Get the index of the last visible cell (at the time of the last layout).- Returns:
- The index of the last visible cell
-
placeToViewport
-
placeToViewport
private void placeToViewport(int itemIndex, double fromY, double toY) -
placeStartAtMayCrop
private void placeStartAtMayCrop(int itemIndex, double startOffStart) -
placeStartOffEndMayCrop
private void placeStartOffEndMayCrop(int itemIndex, double startOffEnd) -
placeEndOffStartMayCrop
private void placeEndOffStartMayCrop(int itemIndex, double endOffStart) -
placeEndOffEndMayCrop
private void placeEndOffEndMayCrop(int itemIndex, double endOffEnd) -
cropToNeighborhoodOf
private void cropToNeighborhoodOf(int itemIndex, double additionalOffset) -
fillForwardFrom
private int fillForwardFrom(int itemIndex) -
fillForwardFrom0
private int fillForwardFrom0(int itemIndex) -
fillForwardFrom
private int fillForwardFrom(int itemIndex, double upTo) -
fillForwardFrom0
int fillForwardFrom0(int itemIndex, double upTo) -
fillBackwardFrom
private int fillBackwardFrom(int itemIndex) -
fillBackwardFrom0
private int fillBackwardFrom0(int itemIndex) -
fillBackwardFrom
private int fillBackwardFrom(int itemIndex, double upTo) -
fillBackwardFrom0
int fillBackwardFrom0(int itemIndex, double upTo) -
fillViewportFrom
private void fillViewportFrom(int itemIndex) Starting from the anchor cell's node, fills the viewport from the anchor to the "ground" and then from the anchor to the "sky".- Parameters:
itemIndex
- the index of the anchor cell
-
fillTowardsGroundFrom0
private int fillTowardsGroundFrom0(int itemIndex) -
fillTowardsGroundFrom0
private int fillTowardsGroundFrom0(int itemIndex, double upTo) -
fillTowardsSkyFrom0
private int fillTowardsSkyFrom0(int itemIndex) -
distanceFromGround
private double distanceFromGround(int itemIndex) -
distanceFromSky
private double distanceFromSky(int itemIndex) -
shiftCellsTowardsGround
private void shiftCellsTowardsGround(int groundCellIndex, int lastCellIndex, double amount)
-