Interface VFXGridHelper<T,C extends Cell<T>>

All Known Implementing Classes:
VFXGridHelper.DefaultHelper

public interface VFXGridHelper<T,C extends Cell<T>>
This interface is a utility API for VFXGrid, despite computations not depending on other properties (some VFXList values depend on the orientation), it's still a nice way to adhere to the encapsulation and separation of concerns principles. Has one concrete implementation: VFXGridHelper.DefaultHelper.
  • Property Summary

    Properties
    Type
    Property
    Description
    javafx.beans.property.ReadOnlyObjectProperty<io.github.palexdev.mfxcore.base.beans.range.NumberRange<Integer>>
    Specifies the range of columns that should be present in the viewport.
    javafx.beans.property.ReadOnlyObjectProperty<io.github.palexdev.mfxcore.base.beans.range.NumberRange<Integer>>
    Specifies the range of rows that should be present in the viewport.
    javafx.beans.property.ReadOnlyObjectProperty<io.github.palexdev.mfxcore.base.beans.Position>
    Cells are actually contained in a separate pane called 'viewport'.
    javafx.beans.property.ReadOnlyDoubleProperty
    Specifies the total number of pixels on the x-axis.
    javafx.beans.property.ReadOnlyDoubleProperty
    Specifies the total number of pixels on the y-axis.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Interface
    Description
    static class 
    Concrete implementation of VFXGridHelper, here the range of rows and columns to display, as well as the viewport position, the virtual max x and y properties are defined as follows:
  • Method Summary

    Modifier and Type
    Method
    Description
    default io.github.palexdev.mfxcore.base.beans.range.IntegerRange
     
    javafx.beans.property.ReadOnlyObjectProperty<io.github.palexdev.mfxcore.base.beans.range.NumberRange<Integer>>
    Specifies the range of columns that should be present in the viewport.
    default void
    Automatically called by VFXGrid when a helper is not needed anymore (changed).
    int
     
    int
     
     
    io.github.palexdev.mfxcore.base.beans.Size
     
    default io.github.palexdev.mfxcore.base.beans.Position
     
    default double
     
    default double
     
    default C
    indexToCell(int index)
    Converts the given index to a cell.
    default T
    indexToItem(int index)
    Converts the given index to an item (shortcut for getList().getItems().get(index)).
    default void
    Forces the VFXGrid.vPosProperty() and VFXGrid.hPosProperty() to be invalidated.
    default C
    itemToCell(T item)
    Converts the given item to a cell.
    int
     
    int
     
    void
    layout(int absRowIndex, int absColumnIndex, javafx.scene.Node node)
    Lays out the given node The row and column indexes are necessary to identify the position of a cell compared to the others (comes before/after, above/below).
    int
     
    double
     
    int
     
    double
     
    default io.github.palexdev.mfxcore.base.beans.range.IntegerRange
     
    javafx.beans.property.ReadOnlyObjectProperty<io.github.palexdev.mfxcore.base.beans.range.NumberRange<Integer>>
    Specifies the range of rows that should be present in the viewport.
    default void
    scrollToColumn(int column)
    Scrolls to the given column index by setting the VFXGrid.hPosProperty() to columnIndex * totalCellWidth.
    default void
    scrollToRow(int row)
    Scrolls to the given row index by setting the VFXGrid.vPosProperty() to rowIndex * totalCellHeight.
    default int
     
    int
     
    int
     
    javafx.beans.property.ReadOnlyObjectProperty<io.github.palexdev.mfxcore.base.beans.Position>
    Cells are actually contained in a separate pane called 'viewport'.
    javafx.beans.property.ReadOnlyDoubleProperty
    Specifies the total number of pixels on the x-axis.
    javafx.beans.property.ReadOnlyDoubleProperty
    Specifies the total number of pixels on the y-axis.
    default int
     
    int
     
    int
     
  • Property Details

    • columnsRange

      javafx.beans.property.ReadOnlyObjectProperty<io.github.palexdev.mfxcore.base.beans.range.NumberRange<Integer>> columnsRangeProperty
      Specifies the range of columns that should be present in the viewport. This also takes into account buffer columns, see visibleColumns() and totalColumns().
      See Also:
    • rowsRange

      javafx.beans.property.ReadOnlyObjectProperty<io.github.palexdev.mfxcore.base.beans.range.NumberRange<Integer>> rowsRangeProperty
      Specifies the range of rows that should be present in the viewport. This also takes into account buffer rows, see visibleRows() and totalRows().
      See Also:
    • virtualMaxX

      javafx.beans.property.ReadOnlyDoubleProperty virtualMaxXProperty
      Specifies the total number of pixels on the x-axis.
      See Also:
    • virtualMaxY

      javafx.beans.property.ReadOnlyDoubleProperty virtualMaxYProperty
      Specifies the total number of pixels on the y-axis.
      See Also:
    • viewportPosition

      javafx.beans.property.ReadOnlyObjectProperty<io.github.palexdev.mfxcore.base.beans.Position> viewportPositionProperty
      Cells are actually contained in a separate pane called 'viewport'. The scroll is applied on this pane.

      This property specifies the translation of the viewport, the calculation depends on the implementation.

      See Also:
  • Method Details

    • maxColumns

      int maxColumns()
      Returns:
      the maximum number of columns the grid can have. This value is essentially the same as VFXGrid.columnsNumProperty() but it's also taken into account the number of items (you can't have more columns than the number of items)
    • firstColumn

      int firstColumn()
      Returns:
      the index of the first visible column
    • lastColumn

      int lastColumn()
      Returns:
      the index of the last visible column
    • visibleColumns

      int visibleColumns()
      Returns:
      the number of columns visible in the viewport. Not necessarily the same as totalColumns()
    • totalColumns

      int totalColumns()
      Returns:
      the total number of columns in the viewport which doesn't include only the number of visible columns but also the number of buffer columns
    • columnsRangeProperty

      javafx.beans.property.ReadOnlyObjectProperty<io.github.palexdev.mfxcore.base.beans.range.NumberRange<Integer>> columnsRangeProperty()
      Specifies the range of columns that should be present in the viewport. This also takes into account buffer columns, see visibleColumns() and totalColumns().
      Returns:
      the columnsRange property
    • columnsRange

      default io.github.palexdev.mfxcore.base.beans.range.IntegerRange columnsRange()
      Returns:
      the range of columns that should be present in the viewport. This also takes into account buffer columns, see visibleColumns() and totalColumns()
    • maxRows

      int maxRows()
      Returns:
      the maximum number of rows the grid can have. This value depends on the number of items and the number of columns
    • firstRow

      int firstRow()
      Returns:
      the index of the first visible row
    • lastRow

      int lastRow()
      Returns:
      the index of the last visible row
    • visibleRows

      int visibleRows()
      Returns:
      the number of rows visible in the viewport. Not necessarily the same as totalRows()
    • totalRows

      int totalRows()
      Returns:
      the total number of rows in the viewport which doesn't include only the number of visible rows but also the number of buffer rows
    • rowsRangeProperty

      javafx.beans.property.ReadOnlyObjectProperty<io.github.palexdev.mfxcore.base.beans.range.NumberRange<Integer>> rowsRangeProperty()
      Specifies the range of rows that should be present in the viewport. This also takes into account buffer rows, see visibleRows() and totalRows().
      Returns:
      the rowsRange property
    • rowsRange

      default io.github.palexdev.mfxcore.base.beans.range.IntegerRange rowsRange()
      Returns:
      the range of rows that should be present in the viewport. This also takes into account buffer rows, see visibleRows() and totalRows().
    • maxHScroll

      double maxHScroll()
      Returns:
      the maximum amount of pixels the container can scroll on the horizontal direction
    • maxVScroll

      double maxVScroll()
      Returns:
      the maximum amount of pixels the container can scroll on the vertical direction
    • virtualMaxXProperty

      javafx.beans.property.ReadOnlyDoubleProperty virtualMaxXProperty()
      Specifies the total number of pixels on the x-axis.
      Returns:
      the virtualMaxX property
      See Also:
    • getVirtualMaxX

      default double getVirtualMaxX()
      Returns:
      the total number of pixels on the x-axis.
    • virtualMaxYProperty

      javafx.beans.property.ReadOnlyDoubleProperty virtualMaxYProperty()
      Specifies the total number of pixels on the y-axis.
      Returns:
      the virtualMaxY property
      See Also:
    • getVirtualMaxY

      default double getVirtualMaxY()
      Returns:
      the total number of pixels on the y-axis.
    • viewportPositionProperty

      javafx.beans.property.ReadOnlyObjectProperty<io.github.palexdev.mfxcore.base.beans.Position> viewportPositionProperty()
      Cells are actually contained in a separate pane called 'viewport'. The scroll is applied on this pane.

      This property specifies the translation of the viewport, the calculation depends on the implementation.

      Returns:
      the viewportPosition property
      See Also:
    • getViewportPosition

      default io.github.palexdev.mfxcore.base.beans.Position getViewportPosition()
      Returns:
      the position the viewport should be at in the container
    • layout

      void layout(int absRowIndex, int absColumnIndex, javafx.scene.Node node)
      Lays out the given node The row and column indexes are necessary to identify the position of a cell compared to the others (comes before/after, above/below).
      Parameters:
      absRowIndex - the absolute row index of the given node/cell, see VFXGridSkin.layout()
      absColumnIndex - the absolute column index of the given node/cell, see VFXGridSkin.layout()
    • getTotalCellSize

      io.github.palexdev.mfxcore.base.beans.Size getTotalCellSize()
      Returns:
      the total size of each cell, given by the VFXGrid.cellSizeProperty() summed to the horizontal and vertical spacing values
    • getGrid

      VFXGrid<T,C> getGrid()
      Returns:
      the VFXGrid instance associated to this helper
    • visibleCells

      default int visibleCells()
      Returns:
      the theoretical number of cells in the viewport. The value depends on the number of visible columns and rows, however, doesn't take into account the possibility of incomplete columns/rows. For a precise value, use totalCells() instead
    • totalCells

      default int totalCells()
      Returns:
      the precise number of cells present in the viewport at a given time. The value depends on the current range of rows and columns. Unfortunately, it's not very efficient as the count is computed by iterating over each row and column, but it's the only stable way I found to have a correct value.
    • scrollToRow

      default void scrollToRow(int row)
      Scrolls to the given row index by setting the VFXGrid.vPosProperty() to rowIndex * totalCellHeight.
    • scrollToColumn

      default void scrollToColumn(int column)
      Scrolls to the given column index by setting the VFXGrid.hPosProperty() to columnIndex * totalCellWidth.
    • invalidatePos

      default void invalidatePos()
      Forces the VFXGrid.vPosProperty() and VFXGrid.hPosProperty() to be invalidated. This is simply done by calling the respective setters with their current respective values. Those two properties will automatically call maxVScroll() and maxHScroll() to ensure the values are correct. This is automatically invoked by the VFXGridManager when needed.
    • indexToItem

      default T indexToItem(int index)
      Converts the given index to an item (shortcut for getList().getItems().get(index)).
    • indexToCell

      default C indexToCell(int index)
      Converts the given index to a cell. Uses itemToCell(Object).
    • itemToCell

      default C itemToCell(T item)
      Converts the given item to a cell. The result is either on of the cells cached in VFXCellsCache that is updated with the given item, or a totally new one created by the VFXList.cellFactoryProperty().
    • dispose

      default void dispose()
      Automatically called by VFXGrid when a helper is not needed anymore (changed). If the helper uses listeners/bindings that may lead to memory leaks, this is the right place to remove them.