Class ViewportLayoutRequest<T>

java.lang.Object
io.github.palexdev.virtualizedfx.table.ViewportLayoutRequest<T>

public class ViewportLayoutRequest<T> extends Object
A layout request is a signal to a virtualized container to tell its viewport to compute the layout. Every virtualized container has such mechanism, but most of the time the request is a simple boolean flag.

In the case of the table, however, the request is a class because we want to optimize the layout computation as much as possible in both ColumnsLayoutMode.

We may want to do such optimizations mainly in two cases:

1) In ColumnsLayoutMode.FIXED if the table becomes bigger than all the columns' widths summed, then we want the last column to take all the available space. In such case, we want to lay out just the last column, and all the cells related to it, no need to re-size and re-position everything.

2) The same logic applies to ColumnsLayoutMode.VARIABLE for the last column as well as for any other column. If a column, say in the middle, changes its size, then we want to re-compute the layout only from the column that changed to the end. And this is a great optimization indeed!

Also, this class can also be used as a callback, because you can query the wasDone() flag to check whether the request lead to layout computation or not (there may be conditions that prevent it!)

Since we are using a class in this case, there are two special values to avoid creating objects every time:

1) NULL is used as both the initial value and the 'reset' value. The default table's skin sets the request property to this special value as soon as the layout methods complete their work. Also, this way we avoid potential NullPointerExceptions.

2) EMPTY is simply used to request a full layout. Statistically speaking, there are going to be many more cases when we want to perform a full layout than a partial one. After all, a partial layout is possible pretty much only in the above-mentioned cases.

See Also:
  • Field Details

  • Constructor Details

    • ViewportLayoutRequest

      public ViewportLayoutRequest(VFXTableColumn<T,?> column)
  • Method Details

    • isValid

      public boolean isValid()
      Returns:
      whether this instance is not equal to the special object NULL.
    • isPartial

      public boolean isPartial()
      Returns:
      whether the column instance passed to this request is not null.
    • column

      public VFXTableColumn<T,?> column()
      Returns:
      the column's instance that will serve as an indicator for a partial layout computation
    • wasDone

      public boolean wasDone()
      Returns:
      whether it was possible to fulfill the layout request
    • setWasDone

      protected ViewportLayoutRequest<T> setWasDone(boolean wasDone)