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 Details

  • 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 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

      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(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 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 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

      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

      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

      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

      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

      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

      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: