Class VFXListState<T,C extends VFXCell<T>>
java.lang.Object
io.github.palexdev.virtualizedfx.list.VFXListState<T,C>
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, seeIndexBiMap.StateMap.- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final VFXListStateSpecial instance ofVFXListStateused to indicate that no cells can be present in the viewport at a certain time. -
Constructor Summary
ConstructorsConstructorDescriptionVFXListState(VFXList<T, C> list, io.github.palexdev.mfxcore.base.beans.range.IntegerRange range) -
Method Summary
Modifier and TypeMethodDescriptionprotected voidRetrieves the item at the given index fromVFXList.itemsProperty()and delegates toaddCell(int, Object, VFXCell).protected voidAdds the given cell to theIndexBiMap.StateMapof this state object.protected voiddispose()Disposes this state object by: caching all the cells (VFXCellsCache.cache(Collection)), and then clearing theIndexBiMap.StateMapby callingIndexBiMap.clear().protected IndexBiMap.StateMap<T, C> getCells()protected SequencedMap<Integer, C> getList()List<javafx.scene.Node> getNodes()io.github.palexdev.mfxcore.base.beans.range.IntegerRangegetRange()booleanbooleanisEmpty()protected CremoveCell(int index) Removes a cell from theIndexBiMap.StateMapfor the given index.protected CremoveCell(T item) Removes a cell from theIndexBiMap.StateMapfor the given item.protected voidsetCellsChanged(boolean cellsChanged) intsize()
-
Field Details
-
INVALID
Special instance ofVFXListStateused 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
-
-
Method Details
-
addCell
Retrieves the item at the given index fromVFXList.itemsProperty()and delegates toaddCell(int, Object, VFXCell).- See Also:
-
addCell
Adds the given cell to theIndexBiMap.StateMapof this state object.- See Also:
-
removeCell
Removes a cell from theIndexBiMap.StateMapfor the given index. If the cell is not found, the next attempt is to remove it by the item at the given index in theVFXList.itemsProperty(). -
removeCell
Removes a cell from theIndexBiMap.StateMapfor the given item. -
dispose
protected void dispose()Disposes this state object by: caching all the cells (VFXCellsCache.cache(Collection)), and then clearing theIndexBiMap.StateMapby callingIndexBiMap.clear().- See Also:
-
getList
-
getRange
public io.github.palexdev.mfxcore.base.beans.range.IntegerRange getRange()- Returns:
- the range of items to display
-
getCells
- Returns:
- the map containing the cells
- See Also:
-
getCellsByIndex
- Returns:
- the map containing the cells by their index
-
getCellsByItem
-
getCellsByIndexUnmodifiable
- Returns:
- the map containing the cells by their index, unmodifiable
-
getCellsByItemUnmodifiable
-
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.StateMapis 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:
-