Class PaginatedVirtualFlow<T,C extends Cell<T>>
- All Implemented Interfaces:
VirtualScrollPane.Wrappable,Styleable,EventTarget,Skinnable
VirtualFlow to offer pagination features.
In addition to all inherited features this adds:
- The current displayed page, currentPageProperty()
- The max number of pages, maxPageProperty()
- The number of cells per page, cellsPerPageProperty(). Note that this is also
settable via CSS
Note that pages start from index 1.
This flow also has its own skin, which is basically the same asVirtualFlow but adapted to
resize the control depending on the cellsPerPageProperty().
Little tips and warnings:
Note that this is a naive implementation. Some things/components, like the FlowState class, have been
adapted to work with this, but if you are not careful you could easily break or mess things up.
For example: the correct way to scroll in this flow is to change the current page property, but nothing prevents you
from using methods such as VirtualFlow.setVPos(double) and VirtualFlow.setHPos(double).
To be more precise you can and must use them, but not both at the same time. What I mean is: if the orientation
is VERTICAL and your cells have variable width then you probably want to adjust the hPos. Same thing applies for
HORIZONTAL orientation but for vPos.
This flow is intended to use implementations of PaginatedHelper as utilities for the orientation. Again, nothing
prevents you from setting a VirtualFlow.orientationHelperFactoryProperty() that only implements OrientationHelper,
don't do that! In such case note also that goToPage(int) won't work and will end with an exception.
-
Property Summary
PropertiesTypePropertyDescriptionio.github.palexdev.mfxcore.base.properties.styleable.StyleableIntegerPropertySpecifies the number of cells to display per page.Specifies the current displayed page.Specifies the maximum number of pages, aka last page number.Properties inherited from class io.github.palexdev.virtualizedfx.flow.VirtualFlow
cellFactory, cellSize, clipBorderRadius, estimatedLength, fitToBreadth, hPos, items, lastRange, maxBreadth, needsViewportLayout, orientationHelperFactory, orientationHelper, orientation, state, vPosProperties inherited from class javafx.scene.control.Control
contextMenu, skin, tooltipProperties inherited from class javafx.scene.layout.Region
background, border, cacheShape, centerShape, height, insets, maxHeight, maxWidth, minHeight, minWidth, opaqueInsets, padding, prefHeight, prefWidth, scaleShape, shape, snapToPixel, widthProperties inherited from class javafx.scene.Parent
needsLayoutProperties 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, focusVisible, focusWithin, 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
Fields inherited from class javafx.scene.layout.Region
USE_COMPUTED_SIZE, USE_PREF_SIZEFields inherited from class javafx.scene.Node
BASELINE_OFFSET_SAME_AS_HEIGHT -
Constructor Summary
ConstructorsConstructorDescriptionPaginatedVirtualFlow(ObservableList<T> items, Function<T, C> cellFactory) PaginatedVirtualFlow(ObservableList<T> items, Function<T, C> cellFactory, Orientation orientation) -
Method Summary
Modifier and TypeMethodDescriptionprotected voidio.github.palexdev.mfxcore.base.properties.styleable.StyleableIntegerPropertySpecifies the number of cells to display per page.protected voidchangePage(int page) Gets the currentPaginatedHelperand callsPaginatedHelper.goToPage(int), but before doing so it ensures that the max page is correct by callingupdateMaxPage().protected Skin<?>Specifies the current displayed page.intGets the value of the property cellsPerPage.static List<CssMetaData<? extends Styleable,?>> protected List<CssMetaData<? extends Styleable,?>> intGets the value of the property currentPage.intGets the value of the property maxPage.io.github.palexdev.mfxcore.base.beans.range.IntegerRangegetRange()Returns the range of displayed items in the current page.Returns a map containing all the currently visible cells in the page.voidgoToPage(int page) Shortcut forsetCurrentPage(int).Specifies the maximum number of pages, aka last page number.voidSets thecurrentPageProperty()to 1.voidSets thecurrentPageProperty()tomaxPageProperty().voidsetCellsPerPage(int cellsPerPage) Sets the value of the property cellsPerPage.voidsetCurrentPage(int currentPage) Sets the value of the property currentPage.protected voidsetMaxPage(int maxPage) Sets the value of the property maxPage.voidResponsible for updatingmaxPageProperty()when needed.wrap()Wraps this in aVirtualScrollPaneMethods inherited from class io.github.palexdev.virtualizedfx.flow.VirtualFlow
cellFactoryProperty, cellSizeProperty, clipBorderRadiusProperty, estimatedLengthProperty, fitToBreadthProperty, getCellFactory, getCellSize, getClipBorderRadius, getEstimatedLength, getHPos, getIndexedCells, getItems, getLastRange, getMaxBreadth, getOrientation, getOrientationHelper, getOrientationHelperFactory, getState, getViewportManager, getVPos, hPosProperty, isFitToBreadth, isNeedsViewportLayout, itemsProperty, lastRangeProperty, maxBreadthProperty, needsViewportLayoutProperty, orientationHelperFactoryProperty, orientationHelperProperty, orientationProperty, requestViewportLayout, scrollBy, scrollToIndex, scrollToPixel, setCellFactory, setCellSize, setClipBorderRadius, setFitToBreadth, setHPos, setItems, setNeedsViewportLayout, setOrientation, setOrientationHelper, setOrientationHelperFactory, setVPos, stateProperty, vPosPropertyMethods inherited from class javafx.scene.control.Control
computeMaxHeight, computeMaxWidth, computeMinHeight, computeMinWidth, computePrefHeight, computePrefWidth, contextMenuProperty, executeAccessibleAction, getBaselineOffset, getContextMenu, getCssMetaData, getInitialFocusTraversable, getSkin, getTooltip, isResizable, layoutChildren, queryAccessibleAttribute, setContextMenu, setSkin, setTooltip, skinProperty, tooltipPropertyMethods inherited from class javafx.scene.layout.Region
backgroundProperty, borderProperty, cacheShapeProperty, centerShapeProperty, getBackground, getBorder, getHeight, getInsets, getMaxHeight, getMaxWidth, getMinHeight, getMinWidth, getOpaqueInsets, getPadding, getPrefHeight, getPrefWidth, getShape, getUserAgentStylesheet, getWidth, heightProperty, insetsProperty, isCacheShape, isCenterShape, 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, widthPropertyMethods inherited from class javafx.scene.Parent
getChildren, getChildrenUnmodifiable, getManagedChildren, getStylesheets, isNeedsLayout, layout, lookup, needsLayoutProperty, requestLayout, requestParentLayout, setNeedsLayout, updateBoundsMethods 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, fireEvent, focusedProperty, focusTraversableProperty, focusVisibleProperty, focusWithinProperty, getAccessibleHelp, getAccessibleRole, getAccessibleRoleDescription, getAccessibleText, getBlendMode, getBoundsInLocal, getBoundsInParent, getCacheHint, getClip, getContentBias, getCursor, getDepthTest, getEffect, getEffectiveNodeOrientation, getEventDispatcher, getId, getInitialCursor, 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, isFocusVisible, isFocusWithin, 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, visiblePropertyMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface javafx.css.Styleable
getStyleableNode
-
Property Details
-
cellsPerPage
public io.github.palexdev.mfxcore.base.properties.styleable.StyleableIntegerProperty cellsPerPagePropertySpecifies the number of cells to display per page. Note that this, combined withVirtualFlow.cellSizeProperty(), determines the size of the virtual flow.- See Also:
-
currentPage
Specifies the current displayed page.- See Also:
-
maxPage
Specifies the maximum number of pages, aka last page number.- See Also:
-
-
Constructor Details
-
PaginatedVirtualFlow
public PaginatedVirtualFlow() -
PaginatedVirtualFlow
-
PaginatedVirtualFlow
public PaginatedVirtualFlow(ObservableList<T> items, Function<T, C> cellFactory, Orientation orientation)
-
-
Method Details
-
goToPage
public void goToPage(int page) Shortcut forsetCurrentPage(int). When thecurrentPageProperty()is invalidatedchangePage(int)is automatically called -
changePage
protected void changePage(int page) Gets the currentPaginatedHelperand callsPaginatedHelper.goToPage(int), but before doing so it ensures that the max page is correct by callingupdateMaxPage(). -
updateMaxPage
public void updateMaxPage()Responsible for updatingmaxPageProperty()when needed.The value is given by
Math.ceil(nItems / cellsPerPage). -
getRange
public io.github.palexdev.mfxcore.base.beans.range.IntegerRange getRange()Returns the range of displayed items in the current page.It is preferable to use this instead of
In case the currentFlowState.getRange()as this range doesn't take into account the cells that have been hidden, seeFlowState.computePaginatedPositions().VirtualFlow.orientationHelperProperty()is null, returnsIntegerRange.of(-1). -
getVisibleCells
Returns a map containing all the currently visible cells in the page. It is preferable to use this withPaginatedVirtualFlowinstead ofVirtualFlow.getIndexedCells()because of thisFlowState.computePaginatedPositions(). In case the range is equal toIntegerRange.of(-1), returns an empty map. -
scrollToFirst
public void scrollToFirst()Sets thecurrentPageProperty()to 1.- Overrides:
scrollToFirstin classVirtualFlow<T,C extends Cell<T>>
-
scrollToLast
public void scrollToLast()Sets thecurrentPageProperty()tomaxPageProperty().- Overrides:
scrollToLastin classVirtualFlow<T,C extends Cell<T>>
-
cellSizeChanged
protected void cellSizeChanged()- Overrides:
cellSizeChangedin classVirtualFlow<T,C extends Cell<T>>
-
createDefaultSkin
- Overrides:
createDefaultSkinin classVirtualFlow<T,C extends Cell<T>>
-
getControlCssMetaData
- Overrides:
getControlCssMetaDatain classVirtualFlow<T,C extends Cell<T>>
-
wrap
Description copied from interface:VirtualScrollPane.WrappableWraps this in aVirtualScrollPane- Specified by:
wrapin interfaceVirtualScrollPane.Wrappable- Overrides:
wrapin classVirtualFlow<T,C extends Cell<T>>
-
getCellsPerPage
public int getCellsPerPage()Gets the value of the property cellsPerPage.- Property description:
- Specifies the number of cells to display per page.
Note that this, combined with
VirtualFlow.cellSizeProperty(), determines the size of the virtual flow.
-
cellsPerPageProperty
public io.github.palexdev.mfxcore.base.properties.styleable.StyleableIntegerProperty cellsPerPageProperty()Specifies the number of cells to display per page. Note that this, combined withVirtualFlow.cellSizeProperty(), determines the size of the virtual flow.- See Also:
-
setCellsPerPage
public void setCellsPerPage(int cellsPerPage) Sets the value of the property cellsPerPage.- Property description:
- Specifies the number of cells to display per page.
Note that this, combined with
VirtualFlow.cellSizeProperty(), determines the size of the virtual flow.
-
getClassCssMetaData
-
getCurrentPage
public int getCurrentPage()Gets the value of the property currentPage.- Property description:
- Specifies the current displayed page.
-
currentPageProperty
Specifies the current displayed page.- See Also:
-
setCurrentPage
public void setCurrentPage(int currentPage) Sets the value of the property currentPage.- Property description:
- Specifies the current displayed page.
-
getMaxPage
public int getMaxPage()Gets the value of the property maxPage.- Property description:
- Specifies the maximum number of pages, aka last page number.
-
maxPageProperty
Specifies the maximum number of pages, aka last page number.- See Also:
-
setMaxPage
protected void setMaxPage(int maxPage) Sets the value of the property maxPage.- Property description:
- Specifies the maximum number of pages, aka last page number.
-