Class VFXDefaultTableRow<T>

java.lang.Object
javafx.scene.Node
javafx.scene.Parent
javafx.scene.layout.Region
io.github.palexdev.virtualizedfx.table.VFXTableRow<T>
io.github.palexdev.virtualizedfx.table.defaults.VFXDefaultTableRow<T>
All Implemented Interfaces:
VFXStyleable, VFXCell<T>, javafx.css.Styleable, javafx.event.EventTarget

public class VFXDefaultTableRow<T> extends VFXTableRow<T>
Concrete and simple implementation of VFXTableRow. Nothing special here, just the default implementations of the abstract core APIs.
  • Property Summary

    Properties inherited from class io.github.palexdev.virtualizedfx.table.VFXTableRow

    index, item, table

    Properties inherited from class javafx.scene.layout.Region

    background, border, cacheShape, centerShape, height, insets, maxHeight, maxWidth, minHeight, minWidth, opaqueInsets, padding, prefHeight, prefWidth, scaleShape, shape, snapToPixel, width

    Properties inherited from class javafx.scene.Parent

    needsLayout

    Properties inherited from class javafx.scene.Node

    accessibleHelp, accessibleRoleDescription, accessibleRole, accessibleText, blendMode, boundsInLocal, boundsInParent, cacheHint, cache, clip, cursor, depthTest, disabled, disable, effectiveNodeOrientation, effect, eventDispatcher, focused, focusTraversable, focusVisible, focusWithin, hover, id, inputMethodRequests, layoutBounds, layoutX, layoutY, localToParentTransform, localToSceneTransform, managed, mouseTransparent, nodeOrientation, onContextMenuRequested, onDragDetected, onDragDone, onDragDropped, onDragEntered, onDragExited, onDragOver, onInputMethodTextChanged, onKeyPressed, onKeyReleased, onKeyTyped, onMouseClicked, onMouseDragEntered, onMouseDragExited, onMouseDragged, onMouseDragOver, onMouseDragReleased, onMouseEntered, onMouseExited, onMouseMoved, onMousePressed, onMouseReleased, onRotate, onRotationFinished, onRotationStarted, onScrollFinished, onScroll, onScrollStarted, onSwipeDown, onSwipeLeft, onSwipeRight, onSwipeUp, onTouchMoved, onTouchPressed, onTouchReleased, onTouchStationary, onZoomFinished, onZoom, onZoomStarted, opacity, parent, pickOnBounds, pressed, rotate, rotationAxis, scaleX, scaleY, scaleZ, scene, style, translateX, translateY, translateZ, viewOrder, visible
  • Field Summary

    Fields inherited from class io.github.palexdev.virtualizedfx.table.VFXTableRow

    cells, columnsRange

    Fields inherited from class javafx.scene.layout.Region

    USE_COMPUTED_SIZE, USE_PREF_SIZE

    Fields inherited from class javafx.scene.Node

    BASELINE_OFFSET_SAME_AS_HEIGHT
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected double
    getWidthOf(VFXTableColumn<T,?> column, boolean forceLayout)
    This method should be responsible for computing the ideal width of a cell given the corresponding column so that its content can be fully shown.
    protected boolean
    This method mainly exists to react to cell factory changes.
    protected void
    updateColumns(io.github.palexdev.mfxcore.base.beans.range.IntegerRange columnsRange, boolean columnsChanged)
    Implementations of this method should mainly react to two types of change in the table:
    void
    updateItem(T item)
    Responsible for both updating the row's item property and all of its cells' item property.

    Methods inherited from class javafx.scene.layout.Region

    backgroundProperty, borderProperty, cacheShapeProperty, centerShapeProperty, computeMaxHeight, computeMaxWidth, computeMinHeight, computeMinWidth, computePrefHeight, computePrefWidth, getBackground, getBorder, getClassCssMetaData, getCssMetaData, getHeight, getInsets, getMaxHeight, getMaxWidth, getMinHeight, getMinWidth, getOpaqueInsets, getPadding, getPrefHeight, getPrefWidth, getShape, getUserAgentStylesheet, getWidth, heightProperty, insetsProperty, isCacheShape, isCenterShape, isResizable, isScaleShape, isSnapToPixel, layoutInArea, layoutInArea, layoutInArea, layoutInArea, maxHeight, maxHeightProperty, maxWidth, maxWidthProperty, minHeight, minHeightProperty, minWidth, minWidthProperty, opaqueInsetsProperty, paddingProperty, positionInArea, positionInArea, prefHeight, prefHeightProperty, prefWidth, prefWidthProperty, resize, scaleShapeProperty, setBackground, setBorder, setCacheShape, setCenterShape, setHeight, setMaxHeight, setMaxSize, setMaxWidth, setMinHeight, setMinSize, setMinWidth, setOpaqueInsets, setPadding, setPrefHeight, setPrefSize, setPrefWidth, setScaleShape, setShape, setSnapToPixel, setWidth, shapeProperty, snappedBottomInset, snappedLeftInset, snappedRightInset, snappedTopInset, snapPosition, snapPositionX, snapPositionY, snapSize, snapSizeX, snapSizeY, snapSpace, snapSpaceX, snapSpaceY, snapToPixelProperty, widthProperty

    Methods inherited from class javafx.scene.Parent

    getBaselineOffset, getChildren, getChildrenUnmodifiable, getManagedChildren, getStylesheets, isNeedsLayout, layout, lookup, needsLayoutProperty, queryAccessibleAttribute, requestLayout, requestParentLayout, setNeedsLayout, updateBounds

    Methods inherited from class javafx.scene.Node

    accessibleHelpProperty, accessibleRoleDescriptionProperty, accessibleRoleProperty, accessibleTextProperty, addEventFilter, addEventHandler, applyCss, autosize, blendModeProperty, boundsInLocalProperty, boundsInParentProperty, buildEventDispatchChain, cacheHintProperty, cacheProperty, clipProperty, computeAreaInScreen, contains, contains, cursorProperty, depthTestProperty, disabledProperty, disableProperty, effectiveNodeOrientationProperty, effectProperty, eventDispatcherProperty, executeAccessibleAction, fireEvent, focusedProperty, focusTraversableProperty, focusVisibleProperty, focusWithinProperty, getAccessibleHelp, getAccessibleRole, getAccessibleRoleDescription, getAccessibleText, getBlendMode, getBoundsInLocal, getBoundsInParent, getCacheHint, getClip, getContentBias, getCursor, getDepthTest, getEffect, getEffectiveNodeOrientation, getEventDispatcher, getId, getInitialCursor, getInitialFocusTraversable, getInputMethodRequests, getLayoutBounds, getLayoutX, getLayoutY, getLocalToParentTransform, getLocalToSceneTransform, getNodeOrientation, getOnContextMenuRequested, getOnDragDetected, getOnDragDone, getOnDragDropped, getOnDragEntered, getOnDragExited, getOnDragOver, getOnInputMethodTextChanged, getOnKeyPressed, getOnKeyReleased, getOnKeyTyped, getOnMouseClicked, getOnMouseDragEntered, getOnMouseDragExited, getOnMouseDragged, getOnMouseDragOver, getOnMouseDragReleased, getOnMouseEntered, getOnMouseExited, getOnMouseMoved, getOnMousePressed, getOnMouseReleased, getOnRotate, getOnRotationFinished, getOnRotationStarted, getOnScroll, getOnScrollFinished, getOnScrollStarted, getOnSwipeDown, getOnSwipeLeft, getOnSwipeRight, getOnSwipeUp, getOnTouchMoved, getOnTouchPressed, getOnTouchReleased, getOnTouchStationary, getOnZoom, getOnZoomFinished, getOnZoomStarted, getOpacity, getParent, getProperties, getPseudoClassStates, getRotate, getRotationAxis, getScaleX, getScaleY, getScaleZ, getScene, getStyle, getStyleableParent, getStyleClass, getTransforms, getTranslateX, getTranslateY, getTranslateZ, getTypeSelector, getUserData, getViewOrder, hasProperties, hoverProperty, idProperty, inputMethodRequestsProperty, intersects, intersects, isCache, isDisable, isDisabled, isFocused, isFocusTraversable, isFocusVisible, isFocusWithin, isHover, isManaged, isMouseTransparent, isPickOnBounds, isPressed, isVisible, layoutBoundsProperty, layoutXProperty, layoutYProperty, localToParent, localToParent, localToParent, localToParent, localToParent, localToParentTransformProperty, localToScene, localToScene, localToScene, localToScene, localToScene, localToScene, localToScene, localToScene, localToScene, localToScene, localToSceneTransformProperty, localToScreen, localToScreen, localToScreen, localToScreen, localToScreen, lookupAll, managedProperty, mouseTransparentProperty, nodeOrientationProperty, notifyAccessibleAttributeChanged, onContextMenuRequestedProperty, onDragDetectedProperty, onDragDoneProperty, onDragDroppedProperty, onDragEnteredProperty, onDragExitedProperty, onDragOverProperty, onInputMethodTextChangedProperty, onKeyPressedProperty, onKeyReleasedProperty, onKeyTypedProperty, onMouseClickedProperty, onMouseDragEnteredProperty, onMouseDragExitedProperty, onMouseDraggedProperty, onMouseDragOverProperty, onMouseDragReleasedProperty, onMouseEnteredProperty, onMouseExitedProperty, onMouseMovedProperty, onMousePressedProperty, onMouseReleasedProperty, onRotateProperty, onRotationFinishedProperty, onRotationStartedProperty, onScrollFinishedProperty, onScrollProperty, onScrollStartedProperty, onSwipeDownProperty, onSwipeLeftProperty, onSwipeRightProperty, onSwipeUpProperty, onTouchMovedProperty, onTouchPressedProperty, onTouchReleasedProperty, onTouchStationaryProperty, onZoomFinishedProperty, onZoomProperty, onZoomStartedProperty, opacityProperty, parentProperty, parentToLocal, parentToLocal, parentToLocal, parentToLocal, parentToLocal, pickOnBoundsProperty, pressedProperty, pseudoClassStateChanged, relocate, removeEventFilter, removeEventHandler, requestFocus, resizeRelocate, rotateProperty, rotationAxisProperty, scaleXProperty, scaleYProperty, scaleZProperty, sceneProperty, sceneToLocal, sceneToLocal, sceneToLocal, sceneToLocal, sceneToLocal, sceneToLocal, sceneToLocal, sceneToLocal, screenToLocal, screenToLocal, screenToLocal, setAccessibleHelp, setAccessibleRole, setAccessibleRoleDescription, setAccessibleText, setBlendMode, setCache, setCacheHint, setClip, setCursor, setDepthTest, setDisable, setDisabled, setEffect, setEventDispatcher, setEventHandler, setFocused, setFocusTraversable, setHover, setId, setInputMethodRequests, setLayoutX, setLayoutY, setManaged, setMouseTransparent, setNodeOrientation, setOnContextMenuRequested, setOnDragDetected, setOnDragDone, setOnDragDropped, setOnDragEntered, setOnDragExited, setOnDragOver, setOnInputMethodTextChanged, setOnKeyPressed, setOnKeyReleased, setOnKeyTyped, setOnMouseClicked, setOnMouseDragEntered, setOnMouseDragExited, setOnMouseDragged, setOnMouseDragOver, setOnMouseDragReleased, setOnMouseEntered, setOnMouseExited, setOnMouseMoved, setOnMousePressed, setOnMouseReleased, setOnRotate, setOnRotationFinished, setOnRotationStarted, setOnScroll, setOnScrollFinished, setOnScrollStarted, setOnSwipeDown, setOnSwipeLeft, setOnSwipeRight, setOnSwipeUp, setOnTouchMoved, setOnTouchPressed, setOnTouchReleased, setOnTouchStationary, setOnZoom, setOnZoomFinished, setOnZoomStarted, setOpacity, setPickOnBounds, setPressed, setRotate, setRotationAxis, setScaleX, setScaleY, setScaleZ, setStyle, setTranslateX, setTranslateY, setTranslateZ, setUserData, setViewOrder, setVisible, snapshot, snapshot, startDragAndDrop, startFullDrag, styleProperty, toBack, toFront, toString, translateXProperty, translateYProperty, translateZProperty, usesMirroring, viewOrderProperty, visibleProperty

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait

    Methods inherited from interface javafx.css.Styleable

    getStyleableNode

    Methods inherited from interface io.github.palexdev.virtualizedfx.cells.base.VFXCell

    afterLayout, beforeLayout, onCache, onDeCache
  • Constructor Details

    • VFXDefaultTableRow

      public VFXDefaultTableRow(T item)
  • Method Details

    • updateColumns

      protected void updateColumns(io.github.palexdev.mfxcore.base.beans.range.IntegerRange columnsRange, boolean columnsChanged)
      Implementations of this method should mainly react to two types of change in the table:

      1) the visible columns changes, or more in general the state's columns range changes

      2) changes in the columns' list that may not necessarily change the range. In particular, this type of change is distinguished by the 'change' parameter set to true. In this case, the row's state should always be computed as there is no information on how the list changed, a 'better safe than sorry' approach.

      First and foremost, the algorithm will run only if: the given columns range is different from the current one, or if the columnsChanged flag is true (which means that the table's columns' list has changed).

      The computation for the new row's state is simple. First we create a new state map which is going to replace the current one, considered now as 'old'. For each column (index) in the new range, we attempt at removing the corresponding cell from the old map. Beware! The removal is done by column not index because the list changed and now columns may be at different positions!!

      If the retrieved cell is not null, then it means that the column is still present in the viewport and thus we can reuse its cell. We update the cell's index (only if columnsChanged is true), then put it in the new state map and continue to the next index.

      If the cell is null then it means that the column is not visible anymore (either because by scrolling is now outside the new range, or because it was removed). In this case we request a new cell from the column at which the loop is by calling VFXTableRow.getCell(int, VFXTableColumn, boolean) (we use the cache if possible) and put it in the new state map.

      At the end of the loop, this invokes VFXTableRow.saveAllCells() to cache all the remaining cells in the old map, then replace it with the new built map, update the columns range and if any cell has changed this also calls VFXTableRow.onCellsChanged().

      Specified by:
      updateColumns in class VFXTableRow<T>
    • replaceCells

      protected boolean replaceCells(VFXTableColumn<T,VFXTableCell<T>> column)
      This method mainly exists to react to cell factory changes. When a column changes its factory, there is no need to re-compute each rows' state, rather we can just replace the cells for that column with new ones. Implementations should have a proper algorithm for the sake of performance.

      Before detailing the internals, there is a special property of the row's state map that should be mentioned. Maps of such type (IndexBiMap) must deal with duplicates and for this reason they store the 'reverse mappings' in a collection. However, the IndexBiMap.RowsStateMap is a special case. You see, every cell is associated with one unique column index, but it's also true that every cell is also associated with one and one only column (the one that built it). So, the collection will contain at most one single element.

      First we remove the cells from the map by the given column using IndexBiMap.remove(Object). If it is not null then we cache it with VFXTableRow.saveCell(VFXTableColumn, VFXTableCell), and remove it from the children list.

      As for the new cell, we request a new one by calling VFXTableRow.getCell(int, VFXTableColumn, boolean) (we don't use the cache as the cells stored in it may be invalid if the cell factory changed). The cell is added to the state map, to the children list and finally sized and positioned by calling VFXTableHelper.layoutCell(int, VFXTableCell).

      Note that to get a new cell, and to lay out it, we need two different indexes. The index of the column is retrieved by using VFXTable.indexOf(VFXTableColumn) and it's needed to update the cell. The other index is an important piece information for the layout method to decide at which x position to put the cell. This index is also called the 'layout index' depends on the ColumnsLayoutMode and its 'absolute'. For the FIXED mode it is given by columnIndex - columnsRange.getMin(), while for the VARIABLE mode is the column's index itself (since all columns are added to the viewport, layout indexes go from 0 to the number of column).

      Specified by:
      replaceCells in class VFXTableRow<T>
      Returns:
      whether the substitution was done successfully
    • getWidthOf

      protected double getWidthOf(VFXTableColumn<T,?> column, boolean forceLayout)
      This method should be responsible for computing the ideal width of a cell given the corresponding column so that its content can be fully shown. This is important for the table's autosize feature to work properly!

      Extract a cell from the state map by the given column using IndexBiMap.RowsStateMap.getSingle(VFXTableColumn). If the cell is not null computes its width by calling Node.prefWidth(double). Before doing so, if the forceLayout flag is true, also calls Node.applyCss().

      If the width can't be computed or if anything goes wrong, returns -1.0.

      Specified by:
      getWidthOf in class VFXTableRow<T>
      Parameters:
      forceLayout - it may happen that this garbage that is JavaFX to still have an incomplete scene graph, meaning for example that skins are not still available for some controls/cells, which means that we could fail in computing any size. This may happen even if the table's layout has been already computed at least once. Internal checks try to identify such occasions and may pass 'true' to this method. What implementations could do to get a correct value is to force the cells to compute their layout (as well as all of their children) by invoking Node.applyCss(). Note, however, that this is going to be a costly operation at init, but it's pretty much the only way.
    • updateItem

      public void updateItem(T item)
      Responsible for both updating the row's item property and all of its cells' item property.
      Specified by:
      updateItem in interface VFXCell<T>
      Overrides:
      updateItem in class VFXTableRow<T>