Class SimpleTableCell<T,E>
- Type Parameters:
T- the type of items in the tableE- the type of property extracted from the T objects
- All Implemented Interfaces:
Cell<T>,MappingTableCell<T,,E> TableCell<T>,Styleable,EventTarget
- Direct Known Subclasses:
UpdatingTableCell
MappingTableCell. This is intended to be used with models that do not
use JavaFX's properties.
Extends HBox and has a Label to represent the item as text.
If the item change, the cell cannot automatically detect it, but you can use VirtualTable.updateTable(boolean)
to programmatically update it.
This implementation has the following properties:
- Holds the column this cell is relative to, columnProperty()
- Holds the row containing this cell, rowProperty()
- Holds the item visualized by the cell, itemProperty()
- Holds the column index this cell is relative to, indexProperty()
Function called "extractor" that does exactly this.
// Lets suppose this cell will represent the name of a User
// The extractor function will look like this...
user -> user.getName();
This also specifies a way to convert the extracted value to a String that will be used as the cell's text,
StringConverter. By default, this is set to use Objects.toString(Object).
The cells text is updated by the invalidate() method.
TableColumn.inViewportProperty() when
the VirtualTable.columnsLayoutModeProperty() is set to ColumnsLayoutMode.VARIABLE. If the column is not
visible (therefore this cell is not visible either) it hides itself automatically.-
Property Summary
PropertiesTypePropertyDescriptionReadOnlyObjectProperty<TableColumn<T,? extends TableCell<T>>> Holds the reference to theTableColumnthis cells is associated to.Specifies the index of the column this cell is associated to.Specifies the item represented by this cell.Specifies theTableRowwhich contains this cell.Properties inherited from class javafx.scene.layout.HBox
alignment, fillHeight, spacingProperties inherited from class javafx.scene.layout.Region
background, border, cacheShape, centerShape, height, insets, maxHeight, maxWidth, minHeight, minWidth, opaqueInsets, padding, prefHeight, prefWidth, scaleShape, shape, snapToPixel, widthProperties inherited from class javafx.scene.Parent
needsLayoutProperties 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
FieldsFields inherited from class javafx.scene.layout.Region
USE_COMPUTED_SIZE, USE_PREF_SIZEFields inherited from class javafx.scene.Node
BASELINE_OFFSET_SAME_AS_HEIGHT -
Constructor Summary
ConstructorsConstructorDescriptionSimpleTableCell(T item, Function<T, E> extractor) SimpleTableCell(T item, Function<T, E> extractor, StringConverter<E> converter) -
Method Summary
Modifier and TypeMethodDescriptionReadOnlyObjectProperty<TableColumn<T,? extends TableCell<T>>> Holds the reference to theTableColumnthis cells is associated to.TableColumn<T,? extends TableCell<T>> Gets the value of thecolumnproperty.intgetIndex()Gets the value of theindexproperty.getItem()Gets the value of theitemproperty.getNode()Returns the cell's node.getRow()Gets the value of therowproperty.Specifies the index of the column this cell is associated to.protected voidinit()voidThis is a way for cells to specify the behavior for when any of its properties are updated.Specifies the item represented by this cell.Specifies theTableRowwhich contains this cell.protected voidsetColumn(TableColumn<T, ? extends TableCell<T>> column) Sets the value of thecolumnproperty.voidsetConverter(StringConverter<E> converter) Sets theStringConverterused to convert an extracted value E to a stringvoidsetExtractor(Function<T, E> extractor) Sets the function used to extract a property E from an item TvoidsetIndex(int index) Sets the value of theindexproperty.voidSets the value of theitemproperty.protected voidsetRow(DefaultTableRow<T> row) Sets the value of therowproperty.voidupdateColumn(TableColumn<T, ? extends TableCell<T>> column) This is a way for cells to obtain and perhaps hold the reference of the column it is associated to.voidupdateIndex(int index) Automatically called by the virtualized control.voidupdateItem(T item) Automatically called by the virtualized control.voidupdateRow(int rIndex, DefaultTableRow<T> row) This is a way for cells to obtain and perhaps hold the reference of the row which contains the cell.Methods inherited from class javafx.scene.layout.HBox
alignmentProperty, clearConstraints, computeMinHeight, computeMinWidth, computePrefHeight, computePrefWidth, fillHeightProperty, getAlignment, getBaselineOffset, getClassCssMetaData, getContentBias, getCssMetaData, getHgrow, getMargin, getSpacing, isFillHeight, layoutChildren, requestLayout, setAlignment, setFillHeight, setHgrow, setMargin, setSpacing, spacingPropertyMethods inherited from class javafx.scene.layout.Pane
getChildrenMethods inherited from class javafx.scene.layout.Region
backgroundProperty, borderProperty, cacheShapeProperty, centerShapeProperty, computeMaxHeight, computeMaxWidth, getBackground, getBorder, 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, widthPropertyMethods inherited from class javafx.scene.Parent
getChildrenUnmodifiable, getManagedChildren, getStylesheets, isNeedsLayout, layout, lookup, needsLayoutProperty, queryAccessibleAttribute, requestParentLayout, setNeedsLayout, updateBoundsMethods 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, 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, visiblePropertyMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface io.github.palexdev.virtualizedfx.cell.Cell
afterLayout, beforeLayout, disposeMethods inherited from interface io.github.palexdev.virtualizedfx.cell.MappingTableCell
setConverterMethods inherited from interface javafx.css.Styleable
getStyleableNode
-
Property Details
-
column
Holds the reference to theTableColumnthis cells is associated to. -
row
Specifies theTableRowwhich contains this cell.- See Also:
-
item
Specifies the item represented by this cell.- See Also:
-
index
Specifies the index of the column this cell is associated to.- See Also:
-
-
Field Details
-
label
-
-
Constructor Details
-
SimpleTableCell
-
SimpleTableCell
-
-
Method Details
-
init
protected void init() -
getNode
Description copied from interface:CellReturns the cell's node. The ideal way to implement a cell would be to extend a JavaFX's pane/region and override this method to return "this". -
updateItem
Description copied from interface:CellAutomatically called by the virtualized control.This method must be implemented to correctly update the Cell's content on scroll.
Note: if the Cell's content is a Node this method should also re-set the Cell's children because (quoting from JavaFX doc) 'A node may occur at most once anywhere in the scene graph' and it's possible that a Node may be removed from a Cell to be the content of another Cell.
- Specified by:
updateItemin interfaceCell<T>
-
updateIndex
public void updateIndex(int index) Description copied from interface:CellAutomatically called by the virtualized control.Cells are dumb, they have no logic, no state. This method allow cells implementations to keep track of a cell's index.
Default implementation is empty.
- Specified by:
updateIndexin interfaceCell<T>
-
updateColumn
Description copied from interface:TableCellThis is a way for cells to obtain and perhaps hold the reference of the column it is associated to.- Specified by:
updateColumnin interfaceTableCell<T>
-
updateRow
Description copied from interface:TableCellThis is a way for cells to obtain and perhaps hold the reference of the row which contains the cell. The given rIndex is the index of the given row. Note that the row may be the same for different calls, but the rIndex may differ. -
invalidate
public void invalidate()This is a way for cells to specify the behavior for when any of its properties are updated. By default this is only invoked afterupdateItem(Object)has also been called. This is responsible for extracting the value E from the currentitemProperty(), converting it to aStringwith the specifiedStringConverterand then updating the label's text- Specified by:
invalidatein interfaceTableCell<T>
-
getColumn
Gets the value of thecolumnproperty.- Property description:
- Holds the reference to the
TableColumnthis cells is associated to. - Returns:
- the value of the
columnproperty - See Also:
-
columnProperty
Holds the reference to theTableColumnthis cells is associated to.- Returns:
- the
columnproperty - See Also:
-
setColumn
Sets the value of thecolumnproperty.- Property description:
- Holds the reference to the
TableColumnthis cells is associated to. - Parameters:
column- the value for thecolumnproperty- See Also:
-
getRow
Gets the value of therowproperty.- Property description:
- Specifies the
TableRowwhich contains this cell. - Returns:
- the value of the
rowproperty - See Also:
-
rowProperty
Specifies theTableRowwhich contains this cell.- Returns:
- the
rowproperty - See Also:
-
setRow
Sets the value of therowproperty.- Property description:
- Specifies the
TableRowwhich contains this cell. - Parameters:
row- the value for therowproperty- See Also:
-
getItem
Gets the value of theitemproperty.- Property description:
- Specifies the item represented by this cell.
- Returns:
- the value of the
itemproperty - See Also:
-
itemProperty
Specifies the item represented by this cell.- Returns:
- the
itemproperty - See Also:
-
setItem
Sets the value of theitemproperty.- Property description:
- Specifies the item represented by this cell.
- Parameters:
item- the value for theitemproperty- See Also:
-
getIndex
public int getIndex()Gets the value of theindexproperty.- Property description:
- Specifies the index of the column this cell is associated to.
- Returns:
- the value of the
indexproperty - See Also:
-
indexProperty
Specifies the index of the column this cell is associated to.- Returns:
- the
indexproperty - See Also:
-
setIndex
public void setIndex(int index) Sets the value of theindexproperty.- Property description:
- Specifies the index of the column this cell is associated to.
- Parameters:
index- the value for theindexproperty- See Also:
-
getExtractor
- Specified by:
getExtractorin interfaceMappingTableCell<T,E> - Returns:
- the function used to extract a property E from an item T
-
setExtractor
Description copied from interface:MappingTableCellSets the function used to extract a property E from an item T- Specified by:
setExtractorin interfaceMappingTableCell<T,E>
-
getConverter
- Specified by:
getConverterin interfaceMappingTableCell<T,E> - Returns:
- the
StringConverterused to convert an extracted value E to a string
-
setConverter
Description copied from interface:MappingTableCellSets theStringConverterused to convert an extracted value E to a string- Specified by:
setConverterin interfaceMappingTableCell<T,E>
-