Module VirtualizedFX
Class VirtualGridSkin<T,C extends GridCell<T>>
java.lang.Object
javafx.scene.control.SkinBase<VirtualGrid<T,C>>
io.github.palexdev.virtualizedfx.grid.VirtualGridSkin<T,C>
- All Implemented Interfaces:
Skin<VirtualGrid<T,C>>
- Direct Known Subclasses:
PaginatedVirtualGridSkin
Default skin implementation for
VirtualGrid.
There is only one component which is the viewport. This is responsible for containing the currently visible cells
and scrolling "a little" to give the illusion of real scrolling, more info here: GridHelper.xPosBinding(),
GridHelper.yPosBinding(), GridState.layoutRows().
There are two approaches for the layout:
1) It can be managed manually and request it only when you think it's needed, this is the most performant
2) It can be left to the viewport, this is the most accurate. The performance difference should be negligible though. This skin uses this approach.
The viewport is also clipped to avoid content leaking out of it.
The actual positioning and resizing of the cells is done byGridHelper.layout(Node, double, double) though,
this allows the user to create custom implementations of the interface and set is as the grid's helper through
VirtualGrid.gridHelperSupplierProperty().
The position of the viewport is controlled through its translateX and translateY properties, two bindings are
created by the GridHelper to update the positions when needed (linked above).-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected doublecomputeMaxHeight(double width, double topInset, double rightInset, double bottomInset, double leftInset) protected doublecomputeMaxWidth(double height, double topInset, double rightInset, double bottomInset, double leftInset) protected doublecomputeMinHeight(double width, double topInset, double rightInset, double bottomInset, double leftInset) protected doublecomputeMinWidth(double height, double topInset, double rightInset, double bottomInset, double leftInset) voiddispose()protected voidonFactoryChanged(Function<T, C> newValue) The default implementation is responsible for resetting the viewport,GridManager.reset(), when the function used to build the cells has been changed.protected voidonGridChanged(io.github.palexdev.mfxcore.collections.ObservableGrid<T> oldValue, io.github.palexdev.mfxcore.collections.ObservableGrid<T> newValue) Tells the grid's components what to do when the items data structure changes.protected voidonHelperChanged(GridHelper newValue) The default implementation is responsible for re-binding the viewport's translateX and translateY properties to the bindings created by the newGridHelper.protected voidonItemsChanged(io.github.palexdev.mfxcore.collections.ObservableGrid.Change<T> change) The default implementation is responsible for telling theGridManagerto process the occurredObservableGrid.Changeand produce eventually a new state.protected voidonLayoutRequest(boolean newValue) The default implementation is responsible for callingParent.requestLayout()on the viewport when theVirtualGrid.needsViewportLayoutProperty()has been set to true.protected voidThe default implementation is responsible for updating the viewport's children when the state changes.Methods inherited from class javafx.scene.control.SkinBase
computeBaselineOffset, computePrefHeight, computePrefWidth, consumeMouseEvents, executeAccessibleAction, getChildren, getClassCssMetaData, getCssMetaData, getNode, getSkinnable, layoutChildren, layoutInArea, layoutInArea, layoutInArea, positionInArea, positionInArea, pseudoClassStateChanged, queryAccessibleAttribute, registerChangeListener, registerInvalidationListener, registerListChangeListener, snappedBottomInset, snappedLeftInset, snappedRightInset, snappedTopInset, snapPosition, snapPositionX, snapPositionY, snapSize, snapSizeX, snapSizeY, snapSpace, snapSpaceX, snapSpaceY, unregisterChangeListeners, unregisterInvalidationListeners, unregisterListChangeListeners
-
Field Details
-
viewport
-
manager
-
-
Constructor Details
-
VirtualGridSkin
-
-
Method Details
-
onItemsChanged
protected void onItemsChanged(io.github.palexdev.mfxcore.collections.ObservableGrid.Change<T> change) The default implementation is responsible for telling theGridManagerto process the occurredObservableGrid.Changeand produce eventually a new state.This also ensures after the change that the viewport's estimated size is correct by calling
GridHelper.computeEstimatedSize(). -
onGridChanged
protected void onGridChanged(io.github.palexdev.mfxcore.collections.ObservableGrid<T> oldValue, io.github.palexdev.mfxcore.collections.ObservableGrid<T> newValue) Tells the grid's components what to do when the items data structure changes. By default, this causes the removal of the itemsChanged listener from the old structure, which is then added to the new one. The estimated size is also recomputed and the viewport reset. -
onFactoryChanged
The default implementation is responsible for resetting the viewport,GridManager.reset(), when the function used to build the cells has been changed. Also makes sure to reset the last range properties ofGridManager.- Throws:
IllegalStateException- if the new function is null
-
onStateChanged
The default implementation is responsible for updating the viewport's children when the state changes. The new state though must have theGridState.haveCellsChanged()flag set to true for this to happen. The nodes are collected throughGridState.getNodes(). -
onHelperChanged
The default implementation is responsible for re-binding the viewport's translateX and translateY properties to the bindings created by the newGridHelper.- Throws:
IllegalStateException- if the new helper is null
-
onLayoutRequest
protected void onLayoutRequest(boolean newValue) The default implementation is responsible for callingParent.requestLayout()on the viewport when theVirtualGrid.needsViewportLayoutProperty()has been set to true. -
computeMinWidth
protected double computeMinWidth(double height, double topInset, double rightInset, double bottomInset, double leftInset) - Overrides:
computeMinWidthin classSkinBase<VirtualGrid<T,C extends GridCell<T>>>
-
computeMinHeight
protected double computeMinHeight(double width, double topInset, double rightInset, double bottomInset, double leftInset) - Overrides:
computeMinHeightin classSkinBase<VirtualGrid<T,C extends GridCell<T>>>
-
computeMaxWidth
protected double computeMaxWidth(double height, double topInset, double rightInset, double bottomInset, double leftInset) - Overrides:
computeMaxWidthin classSkinBase<VirtualGrid<T,C extends GridCell<T>>>
-
computeMaxHeight
protected double computeMaxHeight(double width, double topInset, double rightInset, double bottomInset, double leftInset) - Overrides:
computeMaxHeightin classSkinBase<VirtualGrid<T,C extends GridCell<T>>>
-
dispose
public void dispose()
-