Class VFXListState<T,C extends VFXCell<T>>

java.lang.Object
io.github.palexdev.virtualizedfx.list.VFXListState<T,C>

public class VFXListState<T,C extends VFXCell<T>> extends Object
Immutable object to represent the state of a VFXList in a specific moment in time. In other words, each and every state is given by a unique combination of the list's properties (in terms of values).

The state carries three important information:

1) The range of items to display from the VFXList.itemsProperty()

2) The cells that are currently in the viewport

3) A flag that indicates whether cells have changed since last state

Note that the data structure used to store the cells is particular, see IndexBiMap.StateMap.
See Also:
  • Field Details

    • INVALID

      public static final VFXListState INVALID
      Special instance of VFXListState used to indicate that no cells can be present in the viewport at a certain time. The reasons can be many, for example, no cell factory, invalid range, width/height <= 0, etc...

      This and isEmpty() are two total different things!!

  • Constructor Details

    • VFXListState

      public VFXListState(VFXList<T,C> list, io.github.palexdev.mfxcore.base.beans.range.IntegerRange range)
  • Method Details

    • addCell

      protected void addCell(int index, C cell)
      Retrieves the item at the given index from VFXList.itemsProperty() and delegates to addCell(int, Object, VFXCell).
      See Also:
    • addCell

      protected void addCell(int index, T item, C cell)
      Adds the given cell to the IndexBiMap.StateMap of this state object.
      See Also:
    • removeCell

      protected C removeCell(int index)
      Removes a cell from the IndexBiMap.StateMap for the given index. If the cell is not found, the next attempt is to remove it by the item at the given index in the VFXList.itemsProperty().
    • removeCell

      protected C removeCell(T item)
      Removes a cell from the IndexBiMap.StateMap for the given item.
    • dispose

      protected void dispose()
      Disposes this state object by: caching all the cells (VFXCellsCache.cache(Collection)), and then clearing the IndexBiMap.StateMap by calling IndexBiMap.clear().
      See Also:
    • getList

      public VFXList<T,C> getList()
      Returns:
      the VFXList instance this state is associated to
    • getRange

      public io.github.palexdev.mfxcore.base.beans.range.IntegerRange getRange()
      Returns:
      the range of items to display
    • getCells

      protected IndexBiMap.StateMap<T,C> getCells()
      Returns:
      the map containing the cells
      See Also:
    • getCellsByIndex

      protected SequencedMap<Integer,C> getCellsByIndex()
      Returns:
      the map containing the cells by their index
    • getCellsByItem

      protected List<Map.Entry<T,C>> getCellsByItem()
      Returns:
      the list containing the cells by their item, as entries because of possible duplicates
      See Also:
    • getCellsByIndexUnmodifiable

      public SequencedMap<Integer,C> getCellsByIndexUnmodifiable()
      Returns:
      the map containing the cells by their index, unmodifiable
    • getCellsByItemUnmodifiable

      public List<Map.Entry<T,C>> getCellsByItemUnmodifiable()
      Returns:
      the list containing the cells by their item, as entries because of possible duplicates, unmodifiable
      See Also:
    • getNodes

      public List<javafx.scene.Node> getNodes()
      Returns:
      converts the cells' map to a list of nodes by calling VFXCell.toNode() on each cell
    • size

      public int size()
      Returns:
      the number of cells in the IndexBiMap.StateMap
    • isEmpty

      public boolean isEmpty()
      Returns:
      whether the IndexBiMap.StateMap is empty
      See Also:
    • haveCellsChanged

      public boolean haveCellsChanged()
      Returns:
      whether the cells have changed since the last state. This is used to indicate if more or less cells are present in this state compared to the old one. Used by the default skin to check whether the viewport has to update its children or not.
      See Also:
    • setCellsChanged

      protected void setCellsChanged(boolean cellsChanged)
      See Also: