Class VFXCellBase<T>
- All Implemented Interfaces:
io.github.palexdev.mfxcore.behavior.WithBehavior, io.github.palexdev.mfxcore.controls.MFXSkinnable, io.github.palexdev.mfxcore.controls.MFXStyleable, VFXCell<T>, javafx.css.Styleable, javafx.event.EventTarget, javafx.scene.control.Skinnable
- Direct Known Subclasses:
VFXSimpleCell, VFXSimpleTableCell
This abstract class is a good starting point to implement concrete, usable cells.
Unusually, this enforces the structuring of cells as specified by the MVC pattern. In fact, this extends
MFXControl, expects behaviors of type CellBaseBehavior and doesn't come with a default skin.
The idea is to make the skin implementation responsible for how data is represented (a String, a Node, processing, etc.).
A downside of such approach is that for some reason, users are a bit reluctant in making or customizing skins, however,
I can assure you it's no big deal at all. Also, never forget that VirtualizedFX containers do not
enforce the usage of VFXCellBase or any of its implementations, if you are more comfortable using a simpler
cell system you are free do it.
The default style class is 'cell-base'.
A word on performance As also stated in the javadocs ofupdateIndex(int) and updateItem(Object), to simplify the internal
management of cells, there is no 100% guarantee that updates are called with a different index/item from what the cell
currently has. For this reason, here's how you should implement the 'rendering' operations:
You probably want to execute some operations when the index or item change by listening to the respective properties,
indexProperty() and itemProperty(). This means that your operations will run only and only if the
property fires an invalidation/change event. In this base class the updateIndex(int) and updateItem(Object)
methods are implemented naively, because we work on generic items, we don't know the model, which means that they
update the respective properties without any check.
- For the indexProperty() it's tricky: the JVM caches Integers
between -128 and 127, which means that the '==' operator only works in that range; for larger datasets, you may want to
override the updateIndex(int) method to actually check for equality.
For the itemProperty() it's the same concept. If you know the model, you may want to perform some equality
check in the updateItem(Object) method to avoid useless updates. For example, if in your dataset there are two
Person objects with the same attributes but different references you may want to update the property (so that the
reference is correct) but not perform any operation that strictly depends on the attributes (if a label displays the attributes,
there's no need to re-compute the text)
- See Also:
-
Property Summary
PropertiesTypePropertyDescriptionio.github.palexdev.mfxcore.base.properties.styleable.StyleableObjectProperty<javafx.geometry.Pos> Specifies the alignment of the displayed data.javafx.beans.property.ObjectProperty<javafx.scene.Node> Allows adding aNodeto the cell.javafx.beans.property.IntegerPropertySpecifies the cell's index.javafx.beans.property.ObjectProperty<T> Specifies the cell's item.Properties inherited from class io.github.palexdev.mfxcore.controls.MFXControl
behaviorFactory, skinFactoryProperties inherited from class javafx.scene.control.Control
contextMenu, skin, tooltipProperties 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, visibleProperties inherited from interface javafx.scene.control.Skinnable
skin -
Field Summary
Fields 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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionio.github.palexdev.mfxcore.base.properties.styleable.StyleableObjectProperty<javafx.geometry.Pos> Specifies the alignment of the displayed data.protected VFXContext<T> context()Supplier<io.github.palexdev.mfxcore.behavior.MFXBehavior<? extends javafx.scene.Node>> voiddispose()Automatically called by the framework when the cell is not needed anymore.javafx.geometry.PosGets the value of thealignmentproperty.static List<javafx.css.CssMetaData<? extends javafx.css.Styleable, ?>> protected List<javafx.css.CssMetaData<? extends javafx.css.Styleable, ?>> javafx.scene.NodeGets the value of thegraphicproperty.intgetIndex()Gets the value of theindexproperty.getItem()Gets the value of theitemproperty.javafx.beans.property.ObjectProperty<javafx.scene.Node> Allows adding aNodeto the cell.javafx.beans.property.IntegerPropertySpecifies the cell's index.javafx.beans.property.ObjectProperty<T> Specifies the cell's item.voidonCreated(VFXContext<T> context) Called when a cell is created and associated with aVFXContainer.voidsetAlignment(javafx.geometry.Pos alignment) Sets the value of thealignmentproperty.voidsetGraphic(javafx.scene.Node graphic) Sets the value of thegraphicproperty.voidsetIndex(int index) Sets the value of theindexproperty.voidSets the value of theitemproperty.javafx.scene.NodetoNode()Converts the cell to aNode.voidupdateIndex(int index) Automatically called by the framework when the cell needs to update its index.voidupdateItem(T item) Automatically called by the framework when the cell needs to update its item.Methods inherited from class io.github.palexdev.mfxcore.controls.MFXControl
behaviorFactoryProperty, buildSkin, createDefaultSkin, getBehavior, preloadSkin, skinFactoryPropertyMethods inherited from class javafx.scene.control.Control
computeMaxHeight, computeMaxWidth, computeMinHeight, computeMinWidth, computePrefHeight, computePrefWidth, contextMenuProperty, executeAccessibleAction, getBaselineOffset, getContextMenu, getCssMetaData, getInitialFocusTraversable, getSkin, getTooltip, isResizable, layoutChildren, queryAccessibleAttribute, setContextMenu, setSkin, setTooltip, skinProperty, tooltipPropertyMethods inherited from class javafx.scene.layout.Region
backgroundProperty, borderProperty, cacheShapeProperty, centerShapeProperty, getBackground, getBorder, getHeight, getInsets, getMaxHeight, getMaxWidth, getMinHeight, getMinWidth, getOpaqueInsets, getPadding, getPrefHeight, getPrefWidth, getShape, getUserAgentStylesheet, getWidth, heightProperty, insetsProperty, isCacheShape, isCenterShape, 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
getChildren, getChildrenUnmodifiable, getManagedChildren, getStylesheets, isNeedsLayout, layout, lookup, needsLayoutProperty, requestLayout, 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, fireEvent, focusedProperty, focusTraversableProperty, focusVisibleProperty, focusWithinProperty, getAccessibleHelp, getAccessibleRole, getAccessibleRoleDescription, getAccessibleText, getBlendMode, getBoundsInLocal, getBoundsInParent, getCacheHint, getClip, getContentBias, getCursor, getDepthTest, getEffect, getEffectiveNodeOrientation, getEventDispatcher, getId, getInitialCursor, 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, requestFocusTraversal, 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 Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface io.github.palexdev.mfxcore.controls.MFXSkinnable
defaultSkinFactory, getSkinFactory, setDefaultSkinFactory, setSkinFactoryMethods inherited from interface io.github.palexdev.mfxcore.controls.MFXStyleable
setDefaultStyleClassesMethods inherited from interface javafx.scene.control.Skinnable
getSkin, setSkin, skinPropertyMethods inherited from interface javafx.css.Styleable
getCssMetaData, getId, getPseudoClassStates, getStyle, getStyleableNode, getStyleableParent, getStyleClass, getTypeSelectorMethods inherited from interface VFXCell
afterLayout, beforeLayout, onCache, onDeCacheMethods inherited from interface io.github.palexdev.mfxcore.behavior.WithBehavior
getBehaviorFactory, setBehaviorFactory, setDefaultBehaviorFactory
-
Property Details
-
alignment
public io.github.palexdev.mfxcore.base.properties.styleable.StyleableObjectProperty<javafx.geometry.Pos> alignmentPropertySpecifies the alignment of the displayed data. How this is used depends on the skin implementation.This is settable via CSS with the "-fx-alignment" property.
- See Also:
-
index
public javafx.beans.property.IntegerProperty indexPropertySpecifies the cell's index.- See Also:
-
item
-
graphic
public javafx.beans.property.ObjectProperty<javafx.scene.Node> graphicPropertyAllows adding aNodeto the cell. To be precise, how this property is used depends on the skin implementation.- See Also:
-
-
Constructor Details
-
VFXCellBase
-
-
Method Details
-
defaultStyleClasses
-
defaultBehaviorFactory
public Supplier<io.github.palexdev.mfxcore.behavior.MFXBehavior<? extends javafx.scene.Node>> defaultBehaviorFactory()- Specified by:
defaultBehaviorFactoryin interfaceio.github.palexdev.mfxcore.behavior.WithBehavior
-
toNode
public javafx.scene.Node toNode()Description copied from interface:VFXCellConverts the cell to aNode.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; } } -
updateItem
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
Updates theVFXCellBaseand read how this is handled.itemProperty().- Specified by:
updateItemin interfaceVFXCell<T>
-
updateIndex
public 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
Updates theVFXCellBaseand read how this is handled.indexProperty().- Specified by:
updateIndexin interfaceVFXCell<T>
-
onCreated
Called when a cell is created and associated with aVFXContainer. 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. The implementation stores the context and prevents overwrites once the instance is set (not null anymore). -
dispose
-
getAlignment
public javafx.geometry.Pos getAlignment()Gets the value of thealignmentproperty.- Property description:
- Specifies the alignment of the displayed data. How this is used depends on the skin implementation.
This is settable via CSS with the "-fx-alignment" property.
- Returns:
- the value of the
alignmentproperty - See Also:
-
alignmentProperty
public io.github.palexdev.mfxcore.base.properties.styleable.StyleableObjectProperty<javafx.geometry.Pos> alignmentProperty()Specifies the alignment of the displayed data. How this is used depends on the skin implementation.This is settable via CSS with the "-fx-alignment" property.
- Returns:
- the
alignmentproperty - See Also:
-
setAlignment
public void setAlignment(javafx.geometry.Pos alignment) Sets the value of thealignmentproperty.- Property description:
- Specifies the alignment of the displayed data. How this is used depends on the skin implementation.
This is settable via CSS with the "-fx-alignment" property.
- Parameters:
alignment- the value for thealignmentproperty- See Also:
-
getClassCssMetaData
-
getControlCssMetaData
- Overrides:
getControlCssMetaDatain classjavafx.scene.control.Control
-
context
- See Also:
-
getIndex
public int getIndex()Gets the value of theindexproperty.- Property description:
- Specifies the cell's index.
- Returns:
- the value of the
indexproperty - See Also:
-
indexProperty
public javafx.beans.property.IntegerProperty indexProperty()Specifies the cell's index.- Returns:
- the
indexproperty - See Also:
-
setIndex
public void setIndex(int index) Sets the value of theindexproperty.- Property description:
- Specifies the cell's index.
- Parameters:
index- the value for theindexproperty- See Also:
-
getItem
Gets the value of theitemproperty.- Property description:
- Specifies the cell's item.
- Returns:
- the value of the
itemproperty - See Also:
-
itemProperty
Specifies the cell's item.- Returns:
- the
itemproperty - See Also:
-
setItem
Sets the value of theitemproperty.- Property description:
- Specifies the cell's item.
- Parameters:
item- the value for theitemproperty- See Also:
-
getGraphic
public javafx.scene.Node getGraphic()Gets the value of thegraphicproperty.- Property description:
- Allows adding a
Nodeto the cell. To be precise, how this property is used depends on the skin implementation. - Returns:
- the value of the
graphicproperty - See Also:
-
graphicProperty
public javafx.beans.property.ObjectProperty<javafx.scene.Node> graphicProperty()Allows adding aNodeto the cell. To be precise, how this property is used depends on the skin implementation.- Returns:
- the
graphicproperty - See Also:
-
setGraphic
public void setGraphic(javafx.scene.Node graphic) Sets the value of thegraphicproperty.- Property description:
- Allows adding a
Nodeto the cell. To be precise, how this property is used depends on the skin implementation. - Parameters:
graphic- the value for thegraphicproperty- See Also:
-