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 theVirtualFlow
'sVirtualFlow.Gravity
value, and any remaining unused space counts as the "sky."
-
-
Field Summary
Fields Modifier and Type Field Description private CellListManager<T,C>
cellListManager
private org.reactfx.collection.MemoizationList<C>
cells
private TargetPosition
currentPosition
private int
firstVisibleIndex
private javafx.beans.property.ObjectProperty<VirtualFlow.Gravity>
gravity
private org.reactfx.Subscription
itemsSubscription
private int
lastVisibleIndex
private OrientationHelper
orientation
private CellPositioner<T,C>
positioner
private SizeTracker
sizeTracker
private TargetPosition
targetPosition
-
Constructor Summary
Constructors Constructor Description Navigator(CellListManager<T,C> cellListManager, CellPositioner<T,C> positioner, OrientationHelper orientation, javafx.beans.property.ObjectProperty<VirtualFlow.Gravity> gravity, SizeTracker sizeTracker)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private 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
getCurrentPosition()
int
getFirstVisibleIndex()
Get the index of the first visible cell (at the time of the last layout).int
getLastVisibleIndex()
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
layoutChildren()
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
visit(EndOffEnd targetPosition)
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
-
-
-
-
Field Detail
-
cellListManager
private final CellListManager<T,C extends Cell<T,?>> cellListManager
-
positioner
private final CellPositioner<T,C extends Cell<T,?>> positioner
-
orientation
private final OrientationHelper orientation
-
gravity
private final javafx.beans.property.ObjectProperty<VirtualFlow.Gravity> gravity
-
sizeTracker
private final SizeTracker sizeTracker
-
itemsSubscription
private final org.reactfx.Subscription itemsSubscription
-
currentPosition
private TargetPosition currentPosition
-
targetPosition
private TargetPosition targetPosition
-
firstVisibleIndex
private int firstVisibleIndex
-
lastVisibleIndex
private int lastVisibleIndex
-
-
Constructor Detail
-
Navigator
public Navigator(CellListManager<T,C> cellListManager, CellPositioner<T,C> positioner, OrientationHelper orientation, javafx.beans.property.ObjectProperty<VirtualFlow.Gravity> gravity, SizeTracker sizeTracker)
-
-
Method Detail
-
dispose
public void dispose()
-
layoutChildren
protected void layoutChildren()
- Overrides:
layoutChildren
in classjavafx.scene.Parent
-
setTargetPosition
public void setTargetPosition(TargetPosition targetPosition)
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
private TargetPosition getCurrentPosition()
-
itemsChanged
private void itemsChanged(org.reactfx.collection.QuasiListChange<?> ch)
-
showLengthRegion
void showLengthRegion(int itemIndex, double fromY, double toY)
-
visit
public void visit(StartOffStart targetPosition)
- Specified by:
visit
in interfaceTargetPositionVisitor
-
visit
public void visit(EndOffEnd targetPosition)
- Specified by:
visit
in interfaceTargetPositionVisitor
-
cropToNeighborhoodOf
private void cropToNeighborhoodOf(int itemIndex)
-
visit
public void visit(MinDistanceTo targetPosition)
- 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
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)
-
-