java.lang.Object
javafx.scene.Node
javafx.scene.Parent
javafx.scene.layout.Region
javafx.scene.control.Control
io.github.palexdev.materialfx.controls.base.AbstractMFXTreeItem<T>
- Type Parameters:
T- The type of the data within TreeItem.
- All Implemented Interfaces:
Styleable,EventTarget,Skinnable
- Direct Known Subclasses:
MFXTreeItem
Base class for every item used in
MFXTreeView.
To be precise the MFXTreeView class is just the container of the tree.
According to this implementation each item is a tree, the base concept is something like this:
public class Node<T> {
private T data;
private Node<T> parent;
private List<Node<T>> children;
}
The root is defined as the element which parent is null.
-
Property Summary
PropertiesTypePropertyDescriptionSpecifies the cell factory used by this item.Specifies the left margin of each children.Selection property.Specifies whether the item should be expanded when created.Properties 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, 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
FieldsModifier and TypeFieldDescriptionprotected final ObjectProperty<Callback<AbstractMFXTreeItem<T>,AbstractMFXTreeCell<T>>> protected final Tprotected final ObservableList<AbstractMFXTreeItem<T>>protected AbstractMFXTreeItem<T>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 TypeMethodDescriptionSpecifies the cell factory used by this item.Specifies the left margin of each children.protected abstract voiddoublegetData()longgetIndex()Calculates the item's index in the tree structure.getItems()longCalculates the number of items contained by this item (included).intgetLevel()Calculates the this item's level in the tree structure.Retrieves the next item at the same level in the tree.Retrieves the previous item at the same level in the tree.getRoot()Retrieves the tree's root.abstract ITreeSelectionModel<T>Retrieves the instance of the TreeView which contains the tree.booleanisLeaf()booleanisRoot()Checks if the parent item is null.booleanbooleanSelection property.voidsetCellFactory(Callback<AbstractMFXTreeItem<T>, AbstractMFXTreeCell<T>> cellFactory) Sets the cell factory used by this item.voidsetChildrenMargin(double childrenMargin) Sets the children left margin.voidsetItemParent(AbstractMFXTreeItem<T> parent) Sets this item's parent.voidsetItems(ObservableList<AbstractMFXTreeItem<T>> items) voidsetSelected(boolean selected) Sets this item selection state.voidsetStartExpanded(boolean startExpanded) Sets the state ofstartExpandedProperty()voidsetTreeView(MFXTreeView<T> treeView) Sets this item's TreeView reference to the given one.Specifies whether the item should be expanded when created.protected abstract voidupdateChildrenParent(List<? extends AbstractMFXTreeItem<T>> treeItems, AbstractMFXTreeItem<T> newParent) Methods inherited from class javafx.scene.control.Control
computeMaxHeight, computeMaxWidth, computeMinHeight, computeMinWidth, computePrefHeight, computePrefWidth, contextMenuProperty, createDefaultSkin, executeAccessibleAction, getBaselineOffset, getClassCssMetaData, getContextMenu, getControlCssMetaData, 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, 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, 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 javafx.css.Styleable
getStyleableNode
-
Property Details
-
treeView
- See Also:
-
childrenMargin
Specifies the left margin of each children.- See Also:
-
startExpanded
Specifies whether the item should be expanded when created.- See Also:
-
cellFactory
Specifies the cell factory used by this item.- See Also:
-
selected
Selection property.- See Also:
-
-
Field Details
-
data
-
items
-
parent
-
cellFactory
-
-
Constructor Details
-
AbstractMFXTreeItem
-
-
Method Details
-
getSelectionModel
-
defaultCellFactory
protected abstract void defaultCellFactory() -
updateChildrenParent
protected abstract void updateChildrenParent(List<? extends AbstractMFXTreeItem<T>> treeItems, AbstractMFXTreeItem<T> newParent) -
isRoot
public boolean isRoot()Checks if the parent item is null.- Returns:
- true if parent is null otherwise returns false
-
getRoot
Retrieves the tree's root.- Returns:
- the root item
-
getIndex
public long getIndex()Calculates the item's index in the tree structure.- Returns:
- the item's index
- See Also:
-
getItemsCount
public long getItemsCount()Calculates the number of items contained by this item (included). -
getLevel
public int getLevel()Calculates the this item's level in the tree structure. -
getNextSibling
Retrieves the next item at the same level in the tree.- Returns:
- the item's next sibling. Null if is root or there is no other item next
-
getPreviousSibling
Retrieves the previous item at the same level in the tree.- Returns:
- the item's previous sibling. Null if is root or there is no other item before
-
isLeaf
public boolean isLeaf()- Returns:
- if this item is leaf or not.
-
getTreeView
Retrieves the instance of the TreeView which contains the tree.The reference is stored only in the root item so this method retrieves the root first and then returns the tree view instance.
- Returns:
- the TreeView instance
-
treeViewProperty
- See Also:
-
setTreeView
Sets this item's TreeView reference to the given one.WARNING: THIS METHOD IS INTENDED FOR INTERNAL USE ONLY
- See Also:
-
getData
- Returns:
- the data associated with this item
-
getItems
- Returns:
- the list containing this item's children
-
setItems
-
getItemParent
- Returns:
- this item's parent item
-
setItemParent
Sets this item's parent. This method should be called by subclasses only.WARNING: THIS METHOD IS INTENDED FOR INTERNAL USE ONLY
-
getChildrenMargin
public double getChildrenMargin()- Returns:
- the children left margin to be used in layout.
-
childrenMarginProperty
Specifies the left margin of each children.- See Also:
-
setChildrenMargin
public void setChildrenMargin(double childrenMargin) Sets the children left margin. -
isStartExpanded
public boolean isStartExpanded()- Returns:
- the state of
startExpandedProperty()
-
startExpandedProperty
Specifies whether the item should be expanded when created.- See Also:
-
setStartExpanded
public void setStartExpanded(boolean startExpanded) Sets the state ofstartExpandedProperty() -
getCellFactory
- Returns:
- this item's cell factory
-
cellFactoryProperty
public ObjectProperty<Callback<AbstractMFXTreeItem<T>,AbstractMFXTreeCell<T>>> cellFactoryProperty()Specifies the cell factory used by this item.- See Also:
-
setCellFactory
Sets the cell factory used by this item. -
isSelected
public boolean isSelected()- Returns:
- this item's selection state.
-
selectedProperty
Selection property.- See Also:
-
setSelected
public void setSelected(boolean selected) Sets this item selection state.
-