Class VirtualFlowSkin<T,C extends Cell<T>>

java.lang.Object
javafx.scene.control.SkinBase<VirtualFlow<T,C>>
io.github.palexdev.virtualizedfx.flow.VirtualFlowSkin<T,C>
All Implemented Interfaces:
Skin<VirtualFlow<T,C>>
Direct Known Subclasses:
PaginatedVirtualFlowSkin

public class VirtualFlowSkin<T,C extends Cell<T>> extends SkinBase<VirtualFlow<T,C>>
Default skin implementation for VirtualFlow.

There is only one component which is the viewport. This is responsible for containing the currently visible cells and scrolling "a little" (more info in OrientationHelper).

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 by the OrientationHelper though, this allows you to create custom implementation of the interface and setting it through the VirtualFlow.orientationHelperFactoryProperty(), allowing to customize how cells are positioned and sized.

The position of the viewport is controlled through its translateX and translateY properties, two bindings are created by the OrientationHelper to update the positions when needed.
  • Constructor Details

    • VirtualFlowSkin

      public VirtualFlowSkin(VirtualFlow<T,C> virtualFlow)
  • Method Details

    • onListChanged

      protected void onListChanged(ObservableList<? extends T> oldList, ObservableList<? extends T> newList)
      Tells the flow's components what to do when the items list changes. By default, this causes the removal of the itemsChanged listener from the old list, which is then added to the new list. The estimated length is also recomputed and the viewport reset.
    • onItemsChanged

      protected void onItemsChanged(ListChangeListener.Change<? extends T> c)
      Tells the flow's components what to do when the items in the list change. By default, this causes the re-computation of the estimated length followed by the computation of the new flow' state
    • onFactoryChanged

      protected void onFactoryChanged()
      Tells the FlowManager to FlowManager.reset() the viewport, also resets the last range property of the FlowManager.
    • onStateChanged

      protected void onStateChanged(FlowState<T,C> oldValue, FlowState<T,C> newValue)
      The default implementation is responsible for updating the viewport's children when the state changes. The new state though must have the FlowState.haveCellsChanged() flag set to true for this to happen. The nodes are collected through FlowState.getNodes().
    • onOrientationChanged

      protected void onOrientationChanged(OrientationHelper oldValue, OrientationHelper newValue)
      The default implementation is responsible for re-binding the viewport's translateX and translateY properties to the bindings created by the new OrientationHelper.
      Throws:
      IllegalStateException - if the new helper is null
    • onLayoutRequest

      protected void onLayoutRequest(Boolean newValue)
      The default implementation is responsible for calling Parent.requestLayout() on the viewport when the VirtualFlow.needsViewportLayoutProperty() has been set to true.
    • computeMinWidth

      protected double computeMinWidth(double height, double topInset, double rightInset, double bottomInset, double leftInset)
      Overrides:
      computeMinWidth in class SkinBase<VirtualFlow<T,C extends Cell<T>>>
    • computeMinHeight

      protected double computeMinHeight(double width, double topInset, double rightInset, double bottomInset, double leftInset)
      Overrides:
      computeMinHeight in class SkinBase<VirtualFlow<T,C extends Cell<T>>>
    • dispose

      public void dispose()
      Specified by:
      dispose in interface Skin<T>
      Overrides:
      dispose in class SkinBase<VirtualFlow<T,C extends Cell<T>>>