Class TreeNode<T>
java.lang.Object
com.dlsc.gemsfx.treeview.TreeNode<T>
- Type Parameters:
T- the type of the value stored in the node
A model node used by
TreeNodeView to describe a tree hierarchy.
Each node stores a value, parent-child relationships, optional additional linked nodes, expansion state, and optional dimensions used by the view when laying out cells.
-
Property Summary
PropertiesTypePropertyDescriptionfinal javafx.beans.property.BooleanPropertyThe expanded property.final javafx.beans.property.DoublePropertyThe preferred height property.The read-only parent property.final javafx.beans.property.ObjectProperty<T> The value property.final javafx.beans.property.DoublePropertyThe preferred width property. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final doubleSentinel value indicating that the view's default cell width or height should be used. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal javafx.beans.property.BooleanPropertyThe expanded property.Returns the observable list of child nodes.intgetDepth()Get the depth of the node in the tree.Returns the first child node.final doubleGets the value of theheightproperty.Returns the last child node.intgetLevel()Returns the level of this node in the tree.Returns the observable list of additional nodes linked to this node.getName()Returns the optional name used for styling this node and its links.Gets the value of theparentproperty.final TgetValue()Gets the value of thevalueproperty.final doublegetWidth()Gets the value of thewidthproperty.final javafx.beans.property.DoublePropertyThe preferred height property.booleanChecks whether any ancestor of this node is collapsed.final booleanGets the value of theexpandedproperty.booleanChecks whether this node is the first child of its parent.booleanChecks whether this node is the last child of its parent.booleanisLeaf()Checks whether this node has no children.booleanisRoot()If there is no parent node, it is the root nodeThe read-only parent property.final voidsetExpanded(boolean expanded) Sets the value of theexpandedproperty.final voidsetHeight(double height) Sets the value of theheightproperty.voidSets the optional name used for styling this node and its links.protected final voidSets the value of theparentproperty.voidsetSize(double width, double height) Sets the preferred width and height of this node.final voidSets the value of thevalueproperty.final voidsetWidth(double width) Sets the value of thewidthproperty.stream()Creates a breadth-first stream starting with this node.toString()final javafx.beans.property.ObjectProperty<T> The value property.final javafx.beans.property.DoublePropertyThe preferred width property.
-
Property Details
-
parent
-
expanded
public final javafx.beans.property.BooleanProperty expandedPropertyThe expanded property.- See Also:
-
value
-
width
public final javafx.beans.property.DoubleProperty widthPropertyThe preferred width property.A value of
USE_TREE_CELL_SIZElets the view use its default cell width.- See Also:
-
height
public final javafx.beans.property.DoubleProperty heightPropertyThe preferred height property.A value of
USE_TREE_CELL_SIZElets the view use its default cell height.- See Also:
-
-
Field Details
-
USE_TREE_CELL_SIZE
public static final double USE_TREE_CELL_SIZESentinel value indicating that the view's default cell width or height should be used.- See Also:
-
-
Constructor Details
-
TreeNode
public TreeNode()Creates an empty tree node. -
TreeNode
Creates a tree node with the given value.- Parameters:
value- the value stored in this node
-
-
Method Details
-
getName
Returns the optional name used for styling this node and its links.- Returns:
- the node name
-
setName
Sets the optional name used for styling this node and its links.- Parameters:
name- the node name
-
parentProperty
-
setParent
-
getParent
-
getChildren
-
getLinkedNodes
-
isExpanded
public final boolean isExpanded()Gets the value of theexpandedproperty.- Property description:
- The expanded property.
- Returns:
- the value of the
expandedproperty - See Also:
-
expandedProperty
public final javafx.beans.property.BooleanProperty expandedProperty()The expanded property.- Returns:
- the expanded property
- See Also:
-
setExpanded
public final void setExpanded(boolean expanded) Sets the value of theexpandedproperty.- Property description:
- The expanded property.
- Parameters:
expanded- the value for theexpandedproperty- See Also:
-
getValue
Gets the value of thevalueproperty.- Property description:
- The value property.
- Returns:
- the value of the
valueproperty - See Also:
-
valueProperty
The value property.- Returns:
- the value property
- See Also:
-
setValue
Sets the value of thevalueproperty.- Property description:
- The value property.
- Parameters:
value- the value for thevalueproperty- See Also:
-
getWidth
public final double getWidth()Gets the value of thewidthproperty.- Property description:
- The preferred width property.
A value of
USE_TREE_CELL_SIZElets the view use its default cell width. - Returns:
- the value of the
widthproperty - See Also:
-
widthProperty
public final javafx.beans.property.DoubleProperty widthProperty()The preferred width property.A value of
USE_TREE_CELL_SIZElets the view use its default cell width.- Returns:
- the width property
- See Also:
-
setWidth
public final void setWidth(double width) Sets the value of thewidthproperty.- Property description:
- The preferred width property.
A value of
USE_TREE_CELL_SIZElets the view use its default cell width. - Parameters:
width- the value for thewidthproperty- See Also:
-
getHeight
public final double getHeight()Gets the value of theheightproperty.- Property description:
- The preferred height property.
A value of
USE_TREE_CELL_SIZElets the view use its default cell height. - Returns:
- the value of the
heightproperty - See Also:
-
heightProperty
public final javafx.beans.property.DoubleProperty heightProperty()The preferred height property.A value of
USE_TREE_CELL_SIZElets the view use its default cell height.- Returns:
- the height property
- See Also:
-
setHeight
public final void setHeight(double height) Sets the value of theheightproperty.- Property description:
- The preferred height property.
A value of
USE_TREE_CELL_SIZElets the view use its default cell height. - Parameters:
height- the value for theheightproperty- See Also:
-
setSize
public void setSize(double width, double height) Sets the preferred width and height of this node.- Parameters:
width- the preferred node widthheight- the preferred node height
-
isLeaf
public boolean isLeaf()Checks whether this node has no children.- Returns:
- true if the node is a leaf node
-
getDepth
public int getDepth()Get the depth of the node in the tree. The depth of the root node is 0.- Returns:
- the depth of the node in the tree
-
getLevel
public int getLevel()Returns the level of this node in the tree.- Returns:
- the level of this node, equivalent to
getDepth()
-
isRoot
public boolean isRoot()If there is no parent node, it is the root node- Returns:
- true if the node is the root node of the tree
-
getLastChild
-
isLastChild
public boolean isLastChild()Checks whether this node is the last child of its parent.- Returns:
- true if this node is the last node of the parent
-
isFirstChild
public boolean isFirstChild()Checks whether this node is the first child of its parent.- Returns:
- true if this node is the first node of the parent
-
getFirstChild
-
isAncestorCollapsed
public boolean isAncestorCollapsed()Checks whether any ancestor of this node is collapsed.- Returns:
- true if one of this node's ancestors is collapsed
-
stream
-
toString
-