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.Gravityvalue, and any remaining unused space counts as the "sky."
-
-
Field Summary
Fields Modifier and Type Field Description private CellListManager<T,C>cellListManagerprivate org.reactfx.collection.MemoizationList<C>cellsprivate TargetPositioncurrentPositionprivate intfirstVisibleIndexprivate javafx.beans.property.ObjectProperty<VirtualFlow.Gravity>gravityprivate org.reactfx.SubscriptionitemsSubscriptionprivate intlastVisibleIndexprivate OrientationHelperorientationprivate CellPositioner<T,C>positionerprivate SizeTrackersizeTrackerprivate TargetPositiontargetPosition
-
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 voidcropToNeighborhoodOf(int itemIndex)private voidcropToNeighborhoodOf(int itemIndex, double additionalOffset)voiddispose()private doubledistanceFromGround(int itemIndex)private doubledistanceFromSky(int itemIndex)private intfillBackwardFrom(int itemIndex)private intfillBackwardFrom(int itemIndex, double upTo)private intfillBackwardFrom0(int itemIndex)(package private) intfillBackwardFrom0(int itemIndex, double upTo)private intfillForwardFrom(int itemIndex)private intfillForwardFrom(int itemIndex, double upTo)private intfillForwardFrom0(int itemIndex)(package private) intfillForwardFrom0(int itemIndex, double upTo)private intfillTowardsGroundFrom0(int itemIndex)private intfillTowardsGroundFrom0(int itemIndex, double upTo)private intfillTowardsSkyFrom0(int itemIndex)private voidfillViewportFrom(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 TargetPositiongetCurrentPosition()intgetFirstVisibleIndex()Get the index of the first visible cell (at the time of the last layout).intgetLastVisibleIndex()Get the index of the last visible cell (at the time of the last layout).private voiditemsChanged(org.reactfx.collection.QuasiListChange<?> ch)protected voidlayoutChildren()private voidplaceEndOffEndMayCrop(int itemIndex, double endOffEnd)private voidplaceEndOffStartMayCrop(int itemIndex, double endOffStart)private voidplaceStartAtMayCrop(int itemIndex, double startOffStart)private voidplaceStartOffEndMayCrop(int itemIndex, double startOffEnd)private voidplaceToViewport(int itemIndex, double fromY, double toY)private voidplaceToViewport(int itemIndex, Offset from, Offset to)voidscrollCurrentPositionBy(double delta)Sets theTargetPositionused to layout the anchor node to the current position scrolled bydeltaand re-lays out the viewportvoidsetTargetPosition(TargetPosition targetPosition)Sets theTargetPositionused to layout the anchor node and re-lays out the viewportprivate voidshiftCellsTowardsGround(int groundCellIndex, int lastCellIndex, double amount)(package private) voidshowLengthRegion(int itemIndex, double fromY, double toY)voidvisit(EndOffEnd targetPosition)voidvisit(MinDistanceTo targetPosition)voidvisit(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:
layoutChildrenin classjavafx.scene.Parent
-
setTargetPosition
public void setTargetPosition(TargetPosition targetPosition)
Sets theTargetPositionused to layout the anchor node and re-lays out the viewport
-
scrollCurrentPositionBy
public void scrollCurrentPositionBy(double delta)
Sets theTargetPositionused to layout the anchor node to the current position scrolled bydeltaand 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:
visitin interfaceTargetPositionVisitor
-
visit
public void visit(EndOffEnd targetPosition)
- Specified by:
visitin interfaceTargetPositionVisitor
-
cropToNeighborhoodOf
private void cropToNeighborhoodOf(int itemIndex)
-
visit
public void visit(MinDistanceTo targetPosition)
- Specified by:
visitin 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)
-
-