Class VirtualFlow<T extends IndexedCell>

    • Property Detail

      • vertical

        public final BooleanProperty verticalProperty
        Indicates the primary direction of virtualization. If true, then the primary direction of virtualization is vertical, meaning that cells will stack vertically on top of each other. If false, then they will stack horizontally next to each other.
        See Also:
        isVertical(), setVertical(boolean)
      • cellCount

        public final IntegerProperty cellCountProperty
        Indicates the number of cells that should be in the flow. The user of the VirtualFlow must set this appropriately. When the cell count changes the VirtualFlow responds by updating the visuals. If the items backing the cells change, but the count has not changed, you must call the reconfigureCells() function to update the visuals.
        See Also:
        getCellCount(), setCellCount(int)
      • fixedCellSize

        public final DoubleProperty fixedCellSizeProperty
        For optimisation purposes, some use cases can trade dynamic cell length for speed - if fixedCellSize is greater than zero we'll use that rather than determine it by querying the cell itself.
        See Also:
        getFixedCellSize(), setFixedCellSize(double)
      • cellFactory

        public final ObjectProperty<Callback<VirtualFlow<T extends IndexedCell>,T extends IndexedCell>> cellFactoryProperty

        Setting a custom cell factory has the effect of deferring all cell creation, allowing for total customization of the cell. Internally, the VirtualFlow is responsible for reusing cells - all that is necessary is for the custom cell factory to return from this function a cell which might be usable for representing any item in the VirtualFlow.

        Refer to the Cell class documentation for more detail.

        See Also:
        getCellFactory(), setCellFactory(Callback)
    • Constructor Detail

      • VirtualFlow

        public VirtualFlow​()
        Creates a new VirtualFlow instance.
    • Method Detail

      • setVertical

        public final void setVertical​(boolean value)
        Sets the value of the property vertical.
        Property description:
        Indicates the primary direction of virtualization. If true, then the primary direction of virtualization is vertical, meaning that cells will stack vertically on top of each other. If false, then they will stack horizontally next to each other.
      • isVertical

        public final boolean isVertical​()
        Gets the value of the property vertical.
        Property description:
        Indicates the primary direction of virtualization. If true, then the primary direction of virtualization is vertical, meaning that cells will stack vertically on top of each other. If false, then they will stack horizontally next to each other.
      • verticalProperty

        public final BooleanProperty verticalProperty​()
        Indicates the primary direction of virtualization. If true, then the primary direction of virtualization is vertical, meaning that cells will stack vertically on top of each other. If false, then they will stack horizontally next to each other.
        See Also:
        isVertical(), setVertical(boolean)
      • isPannable

        public final boolean isPannable​()
        Gets the value of the property pannable.
        Property description:
        Indicates whether the VirtualFlow viewport is capable of being panned by the user (either via the mouse or touch events).
      • setPannable

        public final void setPannable​(boolean value)
        Sets the value of the property pannable.
        Property description:
        Indicates whether the VirtualFlow viewport is capable of being panned by the user (either via the mouse or touch events).
      • pannableProperty

        public final BooleanProperty pannableProperty​()
        Indicates whether the VirtualFlow viewport is capable of being panned by the user (either via the mouse or touch events).
        See Also:
        isPannable(), setPannable(boolean)
      • getCellCount

        public final int getCellCount​()
        Gets the value of the property cellCount.
        Property description:
        Indicates the number of cells that should be in the flow. The user of the VirtualFlow must set this appropriately. When the cell count changes the VirtualFlow responds by updating the visuals. If the items backing the cells change, but the count has not changed, you must call the reconfigureCells() function to update the visuals.
      • setCellCount

        public final void setCellCount​(int value)
        Sets the value of the property cellCount.
        Property description:
        Indicates the number of cells that should be in the flow. The user of the VirtualFlow must set this appropriately. When the cell count changes the VirtualFlow responds by updating the visuals. If the items backing the cells change, but the count has not changed, you must call the reconfigureCells() function to update the visuals.
      • cellCountProperty

        public final IntegerProperty cellCountProperty​()
        Indicates the number of cells that should be in the flow. The user of the VirtualFlow must set this appropriately. When the cell count changes the VirtualFlow responds by updating the visuals. If the items backing the cells change, but the count has not changed, you must call the reconfigureCells() function to update the visuals.
        See Also:
        getCellCount(), setCellCount(int)
      • getPosition

        public final double getPosition​()
        Gets the value of the property position.
        Property description:
        The position of the VirtualFlow within its list of cells. This is a value between 0 and 1.
      • setPosition

        public final void setPosition​(double value)
        Sets the value of the property position.
        Property description:
        The position of the VirtualFlow within its list of cells. This is a value between 0 and 1.
      • setFixedCellSize

        public final void setFixedCellSize​(double value)
        Sets the value of the property fixedCellSize.
        Property description:
        For optimisation purposes, some use cases can trade dynamic cell length for speed - if fixedCellSize is greater than zero we'll use that rather than determine it by querying the cell itself.
      • getFixedCellSize

        public final double getFixedCellSize​()
        Gets the value of the property fixedCellSize.
        Property description:
        For optimisation purposes, some use cases can trade dynamic cell length for speed - if fixedCellSize is greater than zero we'll use that rather than determine it by querying the cell itself.
      • fixedCellSizeProperty

        public final DoubleProperty fixedCellSizeProperty​()
        For optimisation purposes, some use cases can trade dynamic cell length for speed - if fixedCellSize is greater than zero we'll use that rather than determine it by querying the cell itself.
        See Also:
        getFixedCellSize(), setFixedCellSize(double)
      • setCellFactory

        public final void setCellFactory​(Callback<VirtualFlow<T>,T> value)
        Sets a new cell factory to use in the VirtualFlow. This forces all old cells to be thrown away, and new cells to be created with the new cell factory.
        Parameters:
        value - the new cell factory
      • getCellFactory

        public final Callback<VirtualFlow<T>,T> getCellFactory​()
        Returns the current cell factory.
        Returns:
        the current cell factory
      • cellFactoryProperty

        public final ObjectProperty<Callback<VirtualFlow<T>,T>> cellFactoryProperty​()

        Setting a custom cell factory has the effect of deferring all cell creation, allowing for total customization of the cell. Internally, the VirtualFlow is responsible for reusing cells - all that is necessary is for the custom cell factory to return from this function a cell which might be usable for representing any item in the VirtualFlow.

        Refer to the Cell class documentation for more detail.

        See Also:
        getCellFactory(), setCellFactory(Callback)
      • requestLayout

        public void requestLayout​()
        Overridden to implement somewhat more efficient support for layout. The VirtualFlow can generally be considered as being unmanaged, in that whenever the position changes, or other such things change, we need to perform a layout but there is no reason to notify the parent. However when things change which may impact the preferred size (such as vertical, createCell, and configCell) then we need to notify the parent.
        Overrides:
        requestLayout in class Parent
      • layoutChildren

        protected void layoutChildren​()
        Invoked during the layout pass to layout the children in this Parent. By default it will only set the size of managed, resizable content to their preferred sizes and does not do any node positioning.

        Subclasses should override this function to layout content as needed.

        Overrides:
        layoutChildren in class Parent
      • setWidth

        protected void setWidth​(double value)
        Sets the value of the property width.
        Overrides:
        setWidth in class Region
      • setHeight

        protected void setHeight​(double value)
        Sets the value of the property height.
        Overrides:
        setHeight in class Region
      • getAvailableCell

        protected T getAvailableCell​(int prefIndex)
        Get a cell which can be used in the layout. This function will reuse cells from the pile where possible, and will create new cells when necessary.
        Parameters:
        prefIndex - the preferred index
        Returns:
        the available cell
      • addAllToPile

        protected void addAllToPile​()
        This method will remove all cells from the VirtualFlow and remove them, adding them to the 'pile' (that is, a place from where cells can be used at a later date). This method is protected to allow subclasses to clean up appropriately.
      • getVisibleCell

        public T getVisibleCell​(int index)
        Gets a cell for the given index if the cell has been created and laid out. "Visible" is a bit of a misnomer, the cell might not be visible in the viewport (it may be clipped), but does distinguish between cells that have been created and are in use vs. those that are in the pile or not created.
        Parameters:
        index - the index
        Returns:
        the visible cell
      • getLastVisibleCell

        public T getLastVisibleCell​()
        Locates and returns the last non-empty IndexedCell that is currently partially or completely visible. This function may return null if there are no cells, or if the viewport length is 0.
        Returns:
        the last visible cell
      • getFirstVisibleCell

        public T getFirstVisibleCell​()
        Locates and returns the first non-empty IndexedCell that is partially or completely visible. This really only ever returns null if there are no cells or the viewport length is 0.
        Returns:
        the first visible cell
      • scrollToTop

        public void scrollToTop​(T firstCell)
        Adjust the position of cells so that the specified cell will be positioned at the start of the viewport. The given cell must already be "live".
        Parameters:
        firstCell - the first cell
      • scrollToBottom

        public void scrollToBottom​(T lastCell)
        Adjust the position of cells so that the specified cell will be positioned at the end of the viewport. The given cell must already be "live".
        Parameters:
        lastCell - the last cell
      • scrollTo

        public void scrollTo​(T cell)
        Adjusts the cells such that the selected cell will be fully visible in the viewport (but only just).
        Parameters:
        cell - the cell
      • scrollTo

        public void scrollTo​(int index)
        Adjusts the cells such that the cell in the given index will be fully visible in the viewport.
        Parameters:
        index - the index
      • scrollToTop

        public void scrollToTop​(int index)
        Adjusts the cells such that the cell in the given index will be fully visible in the viewport, and positioned at the very top of the viewport.
        Parameters:
        index - the index
      • scrollPixels

        public double scrollPixels​(double delta)
        Given a delta value representing a number of pixels, this method attempts to move the VirtualFlow in the given direction (positive is down/right, negative is up/left) the given number of pixels. It returns the number of pixels actually moved.
        Parameters:
        delta - the delta value
        Returns:
        the number of pixels actually moved
      • computePrefWidth

        protected double computePrefWidth​(double height)
        Computes the preferred width of this region for the given height. Region subclasses should override this method to return an appropriate value based on their content and layout strategy. If the subclass doesn't have a VERTICAL content bias, then the height parameter can be ignored.
        Overrides:
        computePrefWidth in class Region
        Parameters:
        height - the height that should be used if preferred width depends on it
        Returns:
        the computed preferred width for this region
      • computePrefHeight

        protected double computePrefHeight​(double width)
        Computes the preferred height of this region for the given width; Region subclasses should override this method to return an appropriate value based on their content and layout strategy. If the subclass doesn't have a HORIZONTAL content bias, then the width parameter can be ignored.
        Overrides:
        computePrefHeight in class Region
        Parameters:
        width - the width that should be used if preferred height depends on it
        Returns:
        the computed preferred height for this region
      • getCell

        public T getCell​(int index)
        Return a cell for the given index. This may be called for any cell, including beyond the range defined by cellCount, in which case an empty cell will be returned. The returned value should not be stored for any reason.
        Parameters:
        index - the index
        Returns:
        the cell
      • setCellIndex

        protected void setCellIndex​(T cell,
                                    int index)
        The VirtualFlow uses this method to set a cells index (rather than calling IndexedCell.updateIndex(int) directly), so it is a perfect place for subclasses to override if this if of interest.
        Parameters:
        cell - The cell whose index will be updated.
        index - The new index for the cell.
      • getCellIndex

        protected int getCellIndex​(T cell)
        Return the index for a given cell. This allows subclasses to customise how cell indices are retrieved.
        Parameters:
        cell - the cell
        Returns:
        the index