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 theTableColumn
this cells is associated to.Specifies the index of the column this cell is associated to.Specifies the item represented by this cell.Specifies theTableRow
which contains this cell.Properties inherited from class javafx.scene.layout.HBox
alignment, fillHeight, spacing
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
FieldsFields 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
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 theTableColumn
this cells is associated to.TableColumn<T,
? extends TableCell<T>> Gets the value of thecolumn
property.int
getIndex()
Gets the value of theindex
property.getItem()
Gets the value of theitem
property.getNode()
Returns the cell's node.getRow()
Gets the value of therow
property.Specifies the index of the column this cell is associated to.protected void
init()
void
This 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 theTableRow
which contains this cell.protected void
setColumn
(TableColumn<T, ? extends TableCell<T>> column) Sets the value of thecolumn
property.void
setConverter
(StringConverter<E> converter) Sets theStringConverter
used to convert an extracted value E to a stringvoid
setExtractor
(Function<T, E> extractor) Sets the function used to extract a property E from an item Tvoid
setIndex
(int index) Sets the value of theindex
property.void
Sets the value of theitem
property.protected void
setRow
(DefaultTableRow<T> row) Sets the value of therow
property.void
updateColumn
(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.void
updateIndex
(int index) Automatically called by the virtualized control.void
updateItem
(T item) Automatically called by the virtualized control.void
updateRow
(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, spacingProperty
Methods inherited from class javafx.scene.layout.Pane
getChildren
Methods 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, widthProperty
Methods inherited from class javafx.scene.Parent
getChildrenUnmodifiable, getManagedChildren, getStylesheets, isNeedsLayout, layout, lookup, needsLayoutProperty, queryAccessibleAttribute, 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, 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 io.github.palexdev.virtualizedfx.cell.Cell
afterLayout, beforeLayout, dispose
Methods inherited from interface io.github.palexdev.virtualizedfx.cell.MappingTableCell
setConverter
Methods inherited from interface javafx.css.Styleable
getStyleableNode
-
Property Details
-
column
Holds the reference to theTableColumn
this cells is associated to. -
row
Specifies theTableRow
which 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:Cell
Returns 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:Cell
Automatically 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:
updateItem
in interfaceCell<T>
-
updateIndex
public void updateIndex(int index) Description copied from interface:Cell
Automatically 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:
updateIndex
in interfaceCell<T>
-
updateColumn
Description copied from interface:TableCell
This is a way for cells to obtain and perhaps hold the reference of the column it is associated to.- Specified by:
updateColumn
in interfaceTableCell<T>
-
updateRow
Description copied from interface:TableCell
This 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 aString
with the specifiedStringConverter
and then updating the label's text- Specified by:
invalidate
in interfaceTableCell<T>
-
getColumn
Gets the value of thecolumn
property.- Property description:
- Holds the reference to the
TableColumn
this cells is associated to. - Returns:
- the value of the
column
property - See Also:
-
columnProperty
Holds the reference to theTableColumn
this cells is associated to.- Returns:
- the
column
property - See Also:
-
setColumn
Sets the value of thecolumn
property.- Property description:
- Holds the reference to the
TableColumn
this cells is associated to. - Parameters:
column
- the value for thecolumn
property- See Also:
-
getRow
Gets the value of therow
property.- Property description:
- Specifies the
TableRow
which contains this cell. - Returns:
- the value of the
row
property - See Also:
-
rowProperty
Specifies theTableRow
which contains this cell.- Returns:
- the
row
property - See Also:
-
setRow
Sets the value of therow
property.- Property description:
- Specifies the
TableRow
which contains this cell. - Parameters:
row
- the value for therow
property- See Also:
-
getItem
Gets the value of theitem
property.- Property description:
- Specifies the item represented by this cell.
- Returns:
- the value of the
item
property - See Also:
-
itemProperty
Specifies the item represented by this cell.- Returns:
- the
item
property - See Also:
-
setItem
Sets the value of theitem
property.- Property description:
- Specifies the item represented by this cell.
- Parameters:
item
- the value for theitem
property- See Also:
-
getIndex
public int getIndex()Gets the value of theindex
property.- Property description:
- Specifies the index of the column this cell is associated to.
- Returns:
- the value of the
index
property - See Also:
-
indexProperty
Specifies the index of the column this cell is associated to.- Returns:
- the
index
property - See Also:
-
setIndex
public void setIndex(int index) Sets the value of theindex
property.- Property description:
- Specifies the index of the column this cell is associated to.
- Parameters:
index
- the value for theindex
property- See Also:
-
getExtractor
- Specified by:
getExtractor
in interfaceMappingTableCell<T,
E> - Returns:
- the function used to extract a property E from an item T
-
setExtractor
Description copied from interface:MappingTableCell
Sets the function used to extract a property E from an item T- Specified by:
setExtractor
in interfaceMappingTableCell<T,
E>
-
getConverter
- Specified by:
getConverter
in interfaceMappingTableCell<T,
E> - Returns:
- the
StringConverter
used to convert an extracted value E to a string
-
setConverter
Description copied from interface:MappingTableCell
Sets theStringConverter
used to convert an extracted value E to a string- Specified by:
setConverter
in interfaceMappingTableCell<T,
E>
-