Interface VFXContainer<T>

All Known Subinterfaces:
VFXPaginated<T>
All Known Implementing Classes:
VFXGrid, VFXList, VFXPaginatedList, VFXTable

public interface VFXContainer<T>
Defines the common API for every virtualized container offered by VirtualizedFX.
  • Property Summary

    Properties
    Type
    Property
    Description
    io.github.palexdev.mfxcore.base.properties.styleable.StyleableObjectProperty<BufferSize>
    Specifies the number of extra cells to add to the container; they act as a buffer, allowing scroll to be smoother.
    default javafx.beans.property.ReadOnlyBooleanProperty
    Specifies whether the data set is empty.
    javafx.beans.property.DoubleProperty
    Specifies the container's horizontal position.
    javafx.beans.property.ListProperty<T>
    Specifies the ObservableList used to store the items.
    javafx.beans.property.ReadOnlyDoubleProperty
    Specifies the maximum possible value for hPosProperty()
    javafx.beans.property.ReadOnlyDoubleProperty
    Specifies the maximum possible value for vPosProperty().
    default javafx.beans.property.ReadOnlyIntegerProperty
    Specifies the number of items in the data structure.
    javafx.beans.property.ReadOnlyDoubleProperty
     
    javafx.beans.property.ReadOnlyDoubleProperty
     
    javafx.beans.property.DoubleProperty
    Specifies the container's vertical position.
  • Method Summary

    Modifier and Type
    Method
    Description
    io.github.palexdev.mfxcore.base.properties.styleable.StyleableObjectProperty<BufferSize>
    Specifies the number of extra cells to add to the container; they act as a buffer, allowing scroll to be smoother.
     
    default javafx.beans.property.ReadOnlyBooleanProperty
    Specifies whether the data set is empty.
    default BufferSize
    Gets the value of the bufferSize property.
    default double
    Gets the value of the hPos property.
    default javafx.collections.ObservableList<T>
    Gets the value of the items property.
    default double
    Gets the value of the maxHScroll property.
    default double
    Gets the value of the maxVScroll property.
    default double
    Gets the value of the virtualMaxX property.
    default double
    Gets the value of the virtualMaxY property.
    default double
    Gets the value of the vPos property.
    javafx.beans.property.DoubleProperty
    Specifies the container's horizontal position.
    default boolean
    Gets the value of the empty property.
    javafx.beans.property.ListProperty<T>
    Specifies the ObservableList used to store the items.
    javafx.beans.property.ReadOnlyDoubleProperty
    Specifies the maximum possible value for hPosProperty()
    javafx.beans.property.ReadOnlyDoubleProperty
    Specifies the maximum possible value for vPosProperty().
    default void
    Sets the value of the bufferSize property.
    default void
    setHPos(double hPos)
    Sets the value of the hPos property.
    default void
    setItems(javafx.collections.ObservableList<T> items)
    Sets the value of the items property.
    default void
    setVPos(double vPos)
    Sets the value of the vPos property.
    default int
     
    default javafx.beans.property.ReadOnlyIntegerProperty
    Specifies the number of items in the data structure.
    void
    update(int... indexes)
    This method should be used by implementations to "manually" update the container.
    javafx.beans.property.ReadOnlyDoubleProperty
     
    javafx.beans.property.ReadOnlyDoubleProperty
     
    javafx.beans.property.DoubleProperty
    Specifies the container's vertical position.
  • Property Details

    • items

      javafx.beans.property.ListProperty<T> itemsProperty
      Specifies the ObservableList used to store the items.

      We use a ListProperty because it offers many commodities such as both the size and emptiness of the list as observable properties, as well as the possibility of adding an InvalidationListener that will both inform about changes of the property and in the list.

      See Also:
    • size

      default javafx.beans.property.ReadOnlyIntegerProperty sizeProperty
      Specifies the number of items in the data structure.
      See Also:
    • empty

      default javafx.beans.property.ReadOnlyBooleanProperty emptyProperty
      Specifies whether the data set is empty.
      See Also:
    • virtualMaxX

      javafx.beans.property.ReadOnlyDoubleProperty virtualMaxXProperty
      See Also:
    • virtualMaxY

      javafx.beans.property.ReadOnlyDoubleProperty virtualMaxYProperty
      See Also:
    • maxVScroll

      javafx.beans.property.ReadOnlyDoubleProperty maxVScrollProperty
      Specifies the maximum possible value for vPosProperty().
      See Also:
    • maxHScroll

      javafx.beans.property.ReadOnlyDoubleProperty maxHScrollProperty
      Specifies the maximum possible value for hPosProperty()
      See Also:
    • vPos

      javafx.beans.property.DoubleProperty vPosProperty
      Specifies the container's vertical position.
      See Also:
    • hPos

      javafx.beans.property.DoubleProperty hPosProperty
      Specifies the container's horizontal position.
      See Also:
    • bufferSize

      io.github.palexdev.mfxcore.base.properties.styleable.StyleableObjectProperty<BufferSize> bufferSizeProperty
      Specifies the number of extra cells to add to the container; they act as a buffer, allowing scroll to be smoother. To avoid edge cases due to the users abusing the system, this is done by using an enumerator which allows up to three buffer cells.
      See Also:
  • Method Details

    • update

      void update(int... indexes)
      This method should be used by implementations to "manually" update the container.

      This can be useful when working with models that do not use JavaFX properties.

      Note: the indexes var-arg parameter can be used to specify which cells need to be updated. An empty array should update all of them.

      More details: some cells may use an update mechanism which relies on property invalidation. Follow this example to better understand what I mean:

      
      // Let's say I have a User class with 'firstName' and 'lastName' fields (we also have both getters and setters)
      // Now, let's assume I have a UserCell class used by the VFXContainer to display User objects (in a label for example)
      // This is a part of its implementation...
      public class UserCell extends Label implements VFXCell<User> {
          private final ObjectProperty<User> item = new SimpleObjectProperty<>() {
              @Overridden
              protected void invalidated() {
                  update();
              }
          };
      
          protected void update() {
              // This will update the cell's text based on the current item
          }
      }
      
      // Remember, the 'invalidated()' method is called only when the reference changes, because internally it does not
      // check for equality but for identity
      
      // Now let's say I want to change a User's 'lastName' field like this...
      container.getItems().get(i).setLastName("NewLastName");
      
      // Question: how can we tell the cell to force the update?
      // There are two possible ways...
      // 1) For the invalidation to occur, we first set the item property to 'null', and then back to the old value
      // 2) We use an event-based mechanism to tell cells to force update themselves. This solution requires cells to
      // subscribe to such events to support "manual" updates
      
      // Solution 2 is more flexible, see VFXContainerEvent class
      
      
      See Also:
    • getItems

      default javafx.collections.ObservableList<T> getItems()
      Gets the value of the items property.
      Property description:
      Specifies the ObservableList used to store the items.

      We use a ListProperty because it offers many commodities such as both the size and emptiness of the list as observable properties, as well as the possibility of adding an InvalidationListener that will both inform about changes of the property and in the list.

      Returns:
      the value of the items property
      See Also:
    • itemsProperty

      javafx.beans.property.ListProperty<T> itemsProperty()
      Specifies the ObservableList used to store the items.

      We use a ListProperty because it offers many commodities such as both the size and emptiness of the list as observable properties, as well as the possibility of adding an InvalidationListener that will both inform about changes of the property and in the list.

      Returns:
      the items property
      See Also:
    • setItems

      default void setItems(javafx.collections.ObservableList<T> items)
      Sets the value of the items property.
      Property description:
      Specifies the ObservableList used to store the items.

      We use a ListProperty because it offers many commodities such as both the size and emptiness of the list as observable properties, as well as the possibility of adding an InvalidationListener that will both inform about changes of the property and in the list.

      Parameters:
      items - the value for the items property
      See Also:
    • size

      default int size()
    • sizeProperty

      default javafx.beans.property.ReadOnlyIntegerProperty sizeProperty()
      Specifies the number of items in the data structure.
      Returns:
      the size property
    • isEmpty

      default boolean isEmpty()
      Gets the value of the empty property.
      Property description:
      Specifies whether the data set is empty.
      Returns:
      the value of the empty property
      See Also:
    • emptyProperty

      default javafx.beans.property.ReadOnlyBooleanProperty emptyProperty()
      Specifies whether the data set is empty.
      Returns:
      the empty property
      See Also:
    • getVirtualMaxX

      default double getVirtualMaxX()
      Gets the value of the virtualMaxX property.
      Property description:
      Returns:
      the value of the virtualMaxX property
      See Also:
    • virtualMaxXProperty

      javafx.beans.property.ReadOnlyDoubleProperty virtualMaxXProperty()
      Returns:
      the virtualMaxX property
      See Also:
    • getVirtualMaxY

      default double getVirtualMaxY()
      Gets the value of the virtualMaxY property.
      Property description:
      Returns:
      the value of the virtualMaxY property
      See Also:
    • virtualMaxYProperty

      javafx.beans.property.ReadOnlyDoubleProperty virtualMaxYProperty()
      Returns:
      the virtualMaxY property
      See Also:
    • getMaxVScroll

      default double getMaxVScroll()
      Gets the value of the maxVScroll property.
      Property description:
      Specifies the maximum possible value for vPosProperty().
      Returns:
      the value of the maxVScroll property
      See Also:
    • maxVScrollProperty

      javafx.beans.property.ReadOnlyDoubleProperty maxVScrollProperty()
      Specifies the maximum possible value for vPosProperty().
      Returns:
      the maxVScroll property
      See Also:
    • getMaxHScroll

      default double getMaxHScroll()
      Gets the value of the maxHScroll property.
      Property description:
      Specifies the maximum possible value for hPosProperty()
      Returns:
      the value of the maxHScroll property
      See Also:
    • maxHScrollProperty

      javafx.beans.property.ReadOnlyDoubleProperty maxHScrollProperty()
      Specifies the maximum possible value for hPosProperty()
      Returns:
      the maxHScroll property
      See Also:
    • getVPos

      default double getVPos()
      Gets the value of the vPos property.
      Property description:
      Specifies the container's vertical position.
      Returns:
      the value of the vPos property
      See Also:
    • vPosProperty

      javafx.beans.property.DoubleProperty vPosProperty()
      Specifies the container's vertical position.
      Returns:
      the vPos property
      See Also:
    • setVPos

      default void setVPos(double vPos)
      Sets the value of the vPos property.
      Property description:
      Specifies the container's vertical position.
      Parameters:
      vPos - the value for the vPos property
      See Also:
    • getHPos

      default double getHPos()
      Gets the value of the hPos property.
      Property description:
      Specifies the container's horizontal position.
      Returns:
      the value of the hPos property
      See Also:
    • hPosProperty

      javafx.beans.property.DoubleProperty hPosProperty()
      Specifies the container's horizontal position.
      Returns:
      the hPos property
      See Also:
    • setHPos

      default void setHPos(double hPos)
      Sets the value of the hPos property.
      Property description:
      Specifies the container's horizontal position.
      Parameters:
      hPos - the value for the hPos property
      See Also:
    • getBufferSize

      default BufferSize getBufferSize()
      Gets the value of the bufferSize property.
      Property description:
      Specifies the number of extra cells to add to the container; they act as a buffer, allowing scroll to be smoother. To avoid edge cases due to the users abusing the system, this is done by using an enumerator which allows up to three buffer cells.
      Returns:
      the value of the bufferSize property
      See Also:
    • bufferSizeProperty

      io.github.palexdev.mfxcore.base.properties.styleable.StyleableObjectProperty<BufferSize> bufferSizeProperty()
      Specifies the number of extra cells to add to the container; they act as a buffer, allowing scroll to be smoother. To avoid edge cases due to the users abusing the system, this is done by using an enumerator which allows up to three buffer cells.
      Returns:
      the bufferSize property
      See Also:
    • setBufferSize

      default void setBufferSize(BufferSize bufferSize)
      Sets the value of the bufferSize property.
      Property description:
      Specifies the number of extra cells to add to the container; they act as a buffer, allowing scroll to be smoother. To avoid edge cases due to the users abusing the system, this is done by using an enumerator which allows up to three buffer cells.
      Parameters:
      bufferSize - the value for the bufferSize property
      See Also:
    • context

      VFXContext<T> context()
      Returns:
      the VFXContext object which carries the virtualized container's instance and additional external services that may be needed/used by the cells.