Interface VFXCell<T>

Type Parameters:
T - the type of item to display
All Known Subinterfaces:
VFXMappingTableCell<T,E>, VFXTableCell<T>
All Known Implementing Classes:
VFXCellBase, VFXDefaultTableRow, VFXObservingTableCell, VFXSimpleCell, VFXSimpleTableCell, VFXTableRow

public interface VFXCell<T>
Public, base API for all cells used by any virtualized container. All cells need these three main capabilities:

- A way to convert themselves to a Node, can be implemented in various ways see toNode()

- A way to keep track of its index

- A way to keep track of the displayed item

Aside from these core functionalities, the API also offers other hooks:

- Virtualized containers that make use of a cache (to avoid creating new cells every time one is needed) should make use of onCache() and onDeCache(). Implementations can track cache/de-cache operations by overriding these methods

- When cells are not needed anymore, dispose() should be called (automatically handled by the framework don't worry). Here implementations can specify operations to do before the cell is GCd.

  • Method Summary

    Modifier and Type
    Method
    Description
    default void
    The system automatically calls this after the cell is laid out.
    default void
    The system automatically calls this before the cell is laid out.
    default void
    Automatically called by the framework when the cell is not needed anymore.
    default void
    Virtualized containers that make use of a cache to store unneeded cells that may be required again in a second time should call this when adding the cell to the cache.
    default void
    Called when a cell is created and associated with a VFXContainer.
    default void
    Virtualized containers that make use of a cache to store unneeded cells that may be required again in a second time should call this when removing the cell from the cache.
    Converts the cell to a Node.
    void
    updateIndex(int index)
    Automatically called by the framework when the cell needs to update its index.
    void
    updateItem(T item)
    Automatically called by the framework when the cell needs to update its item.
  • Method Details

    • toNode

      Node toNode()
      Converts the cell to a Node.

      Implementations can check these examples:

       
       // Example 1
       public class SimpleCell<T> extends Label implements VFXCell<T> {
           ...
           ...
      
           @Override
           public Node toNode() {
               return this;
           }
       }
      
       // Example 2
       public class SimpleCell<T> implements VFXCell<T> {
           private final Label label = ...;
           ...
           ...
      
           @Override
           public Node toNode() {
               return label;
           }
       }
       
       
    • updateIndex

      void updateIndex(int index)
      Automatically called by the framework when the cell needs to update its index.

      Note though, that there is no 100% guarantee the new given index is different from the current one. If you have some operations happen when the index changes, for performance reasons, I recommend you to first ensure the new index really is different.

      See VFXCellBase and read how this is handled.

    • updateItem

      void updateItem(T item)
      Automatically called by the framework when the cell needs to update its item.

      Note though, that there is no 100% guarantee the new given item is different from the current one. If you have some operations happen when the item changes, for performance reasons, I recommend you to first ensure the new item really is different.

      See VFXCellBase and read how this is handled.

    • beforeLayout

      default void beforeLayout()
      The system automatically calls this before the cell is laid out.
    • afterLayout

      default void afterLayout()
      The system automatically calls this after the cell is laid out.
    • onCreated

      default void onCreated(VFXContext<T> context)
      Called when a cell is created and associated with a VFXContainer. This method provides the cell with a reference to its container, along with additional services that the cell may use to extend its functionalities.

      It's up to the implementation to decide how to use it.

      Note: This method should only be called by the container that created this cell. Calling it with a different or incorrect container instance may lead to inconsistent behavior or errors.
      See Also:
    • onCache

      default void onCache()
      Virtualized containers that make use of a cache to store unneeded cells that may be required again in a second time should call this when adding the cell to the cache.

      Users can intercept/hook to this operation by overriding this method.

    • onDeCache

      default void onDeCache()
      Virtualized containers that make use of a cache to store unneeded cells that may be required again in a second time should call this when removing the cell from the cache.

      Users can intercept/hook to this operation by overriding this method.

    • dispose

      default void dispose()
      Automatically called by the framework when the cell is not needed anymore. The user can override this to perform some operations before the cell is GCd.