Class VFXTableState<T>

java.lang.Object
io.github.palexdev.virtualizedfx.table.VFXTableState<T>
All Implemented Interfaces:
Cloneable

public class VFXTableState<T> extends Object implements Cloneable
Immutable object to represent the state of a VFXTable is a specific moment in time. In other words every state is given by a unique combination of the table's properties (in terms of values).

The state carries six important pieces of information:

1) The range of rows to display

2) The range of columns to display

3) The rows that are currently in the viewport

4) A flag that indicates whether rows have changed since the last state (either the rows map or range)

5) A flag that indicates whether columns have changed since the last state (the range)

6) A flag that indicates whether this state is a clone of a previous state

Global state and "sub-state"

The table component is a bit different from others. Cells are not placed directly in the viewport but are wrapped in rows as also explained here VFXTable. Because of this, the state class keeps track of how many and which rows/items are to be displayed in the viewport. However, there is absolutely no information regarding the cells. This important piece of data is stored in each row; they also have a particular type of IndexBiMap to keep track of how many cells and which columns are to be displayed in the viewport.

I like to refer to this class as the global state mainly for two reasons: 1) this is what the table's subsystems use to work, 2) Even if cells' infos are not directly available here, this keeps track of the rows, which means that we can indeed get them.

Clones

As already said above, the state class has a special flag which indicates whether an instance was produced by cloning another state object (with clone()).

Q: Why?

A: This mechanism is mainly a consequence of the above explanation about global and sub-states. There may be changes in the table that do not need to produce a new VFXTableState (e.g., a column changing its cell factory). Still, I wanted the system to inform users that a change did indeed happen. Creating a new state from scratch would have been a waste of performance. So, I decided to implement the clone() method to pass every variable from one state to a new one without any alteration. This way, the VFXTable.stateProperty() would trigger a change event because instances would be different.

The only issue with such mechanism is that in most cases a clone state can be used, we don't want the table's skin to do anything (no layout should be needed). This can be done by checking the flag with isClone().

See Also:
  • Field Details

    • INVALID

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

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

  • Constructor Details

    • VFXTableState

      public VFXTableState(VFXTable<T> table, io.github.palexdev.mfxcore.base.beans.range.IntegerRange rowsRange, io.github.palexdev.mfxcore.base.beans.range.IntegerRange columnsRange)
    • VFXTableState

      protected VFXTableState(VFXTable<T> table, io.github.palexdev.mfxcore.base.beans.range.IntegerRange rowsRange, io.github.palexdev.mfxcore.base.beans.range.IntegerRange columnsRange, IndexBiMap.StateMap<T,VFXTableRow<T>> rows)
  • Method Details