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

All Superinterfaces:
VFXContainerHelper<T,VFXGrid<T,C>>
All Known Implementing Classes:
VFXGridHelper.DefaultHelper

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

      void layout(int rowLayoutIndex, int columnLayoutIndex, VFXCell<T> cell)
      Lays out the given cell. The row and column layout indexes are necessary to identify the position of a cell among the others (comes before/after, above/below).
      See Also:
    • 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
    • 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.
    • 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 VFXGrid.getCellFactory().