Top Inners Fields Constructors Methods
com.dlsc.gemsfx.treeview

public Class TreeNode<T>

extends Object
Class Inheritance
Imports
javafx.beans.property.BooleanProperty, .DoubleProperty, .ObjectProperty, .ReadOnlyObjectProperty, .ReadOnlyObjectWrapper, .SimpleBooleanProperty, .SimpleDoubleProperty, .SimpleObjectProperty, javafx.collections.FXCollections, .ListChangeListener, .ObservableList, java.util.LinkedList, .Queue, .Spliterator, java.util.function.Consumer, java.util.stream.Stream, .StreamSupport

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class

Field Summary

Modifier and TypeField and Description
private final ObservableList<TreeNode<T>>
children

This list holds the child nodes of the current node in the tree hierarchy.

private static final boolean
private static final double
private static final double
private final BooleanProperty
private final DoubleProperty
private final ObservableList<TreeNode<T>>
linkedNodes

This list holds references to nodes that are directly linked or associated with the current node.

private String
name

Represents the name identifier for this node.

private final ReadOnlyObjectWrapper<TreeNode<T>>
public static final double
private final ObjectProperty<T>
private final DoubleProperty

Constructor Summary

AccessConstructor and Description
public
public
TreeNode(T value)

Method Summary

Modifier and TypeMethod and Description
public BooleanProperty
public ObservableList<TreeNode<T>>
public int

Returns:

the depth of the node in the tree
getDepth
()

Get the depth of the node in the tree.

public TreeNode<T>
getFirstChild()

Returns: The first node in the child node list.

public double
public TreeNode<T>
getLastChild()

Returns: The last node in the child node list.

public int
public ObservableList<TreeNode<T>>
public String
public TreeNode<T>
public T
public double
public DoubleProperty
public boolean
isAncestorCollapsed()

Returns: true if the node is parent is collapsed

public boolean
public boolean
isFirstChild()

Returns: true: if this node is the first node of the parent

public boolean
isLastChild()

Returns: true: if this node is the last node of the parent

public boolean
isLeaf()

Returns: true: if the node is a leaf node

public boolean

Returns:

true if the node is the root node of the tree
isRoot
()

If there is no parent node, it is the root node

public ReadOnlyObjectProperty<TreeNode<T>>
public void
setExpanded(boolean expanded)

public void
setHeight(double height)

public void
protected void
setParent(TreeNode<T> parent)

public void
setSize(double width, double height)

public void
setValue(T value)

public void
setWidth(double width)

public Stream<TreeNode<T>>
stream()

Convenient for traversing tree nodes.

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

public ObjectProperty<T>
public DoubleProperty
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

childrenback to summary
private final ObservableList<TreeNode<T>> children

This list holds the child nodes of the current node in the tree hierarchy. Each child node in this list is directly connected to and descends from the current node. It represents the default connectivity in the tree structure, where parent nodes are intrinsically linked to their children.

DEFAULT_EXPANDEDback to summary
private static final boolean DEFAULT_EXPANDED
DEFAULT_HEIGHTback to summary
private static final double DEFAULT_HEIGHT
DEFAULT_WIDTHback to summary
private static final double DEFAULT_WIDTH
expandedback to summary
private final BooleanProperty expanded
heightback to summary
private final DoubleProperty height
linkedNodesback to summary
private final ObservableList<TreeNode<T>> linkedNodes

This list holds references to nodes that are directly linked or associated with the current node. Unlike the 'children' list, which represents child nodes in a hierarchical structure, the 'linkedNodes' list represents peers or other related nodes that have a specific connection or relationship with this node, but are not necessarily its descendants in the tree hierarchy.

nameback to summary
private String name

Represents the name identifier for this node. ------------------------------------------------ The primary purpose of the 'name' is to assist in determining the style of the node and its links. For instance: 1. If the node's name is 'n', then the style class for the node would be 'node-n'. 2. For a regular parent-child relationship, if a node with name 'n' has a parent named 'm', the link connecting them will have a style class 'link-m-n'. 3. For any extra links, say from node 'p' to node 'n', the style class for the link would be 'link-extra-p-n'. ------------------------------------------------ Important considerations: - If the 'name' is null, all the above rules become invalid. - Both the relevant node and the current node must possess non-null 'name' values for these styling rules to apply. ------------------------------------------------ This naming convention aids in providing a systematic approach for styling, making it directly relatable to the node's relationship and connection type.

parentback to summary
private final ReadOnlyObjectWrapper<TreeNode<T>> parent
USE_TREE_CELL_SIZEback to summary
public static final double USE_TREE_CELL_SIZE
valueback to summary
private final ObjectProperty<T> value
widthback to summary
private final DoubleProperty width

Constructor Detail

TreeNodeback to summary
public TreeNode()
TreeNodeback to summary
public TreeNode(T value)

Method Detail

expandedPropertyback to summary
public BooleanProperty expandedProperty()
getChildrenback to summary
public ObservableList<TreeNode<T>> getChildren()
getDepthback to summary
public int getDepth()

Get the depth of the node in the tree. The depth of the root node is 0.

Returns:int

the depth of the node in the tree

getFirstChildback to summary
public TreeNode<T> getFirstChild()
Returns:TreeNode<T>

The first node in the child node list.

getHeightback to summary
public double getHeight()
getLastChildback to summary
public TreeNode<T> getLastChild()
Returns:TreeNode<T>

The last node in the child node list.

getLevelback to summary
public int getLevel()
getLinkedNodesback to summary
public ObservableList<TreeNode<T>> getLinkedNodes()
getNameback to summary
public String getName()
getParentback to summary
public TreeNode<T> getParent()
getValueback to summary
public T getValue()
getWidthback to summary
public double getWidth()
heightPropertyback to summary
public DoubleProperty heightProperty()
isAncestorCollapsedback to summary
public boolean isAncestorCollapsed()
Returns:boolean

true if the node is parent is collapsed

isExpandedback to summary
public boolean isExpanded()
isFirstChildback to summary
public boolean isFirstChild()
Returns:boolean

true: if this node is the first node of the parent

isLastChildback to summary
public boolean isLastChild()
Returns:boolean

true: if this node is the last node of the parent

isLeafback to summary
public boolean isLeaf()
Returns:boolean

true: if the node is a leaf node

isRootback to summary
public boolean isRoot()

If there is no parent node, it is the root node

Returns:boolean

true if the node is the root node of the tree

parentPropertyback to summary
public ReadOnlyObjectProperty<TreeNode<T>> parentProperty()
setExpandedback to summary
public void setExpanded(boolean expanded)
setHeightback to summary
public void setHeight(double height)
setNameback to summary
public void setName(String name)
setParentback to summary
protected void setParent(TreeNode<T> parent)
setSizeback to summary
public void setSize(double width, double height)
setValueback to summary
public void setValue(T value)
setWidthback to summary
public void setWidth(double width)
streamback to summary
public Stream<TreeNode<T>> stream()

Convenient for traversing tree nodes.

toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Annotations
@Override
valuePropertyback to summary
public ObjectProperty<T> valueProperty()
widthPropertyback to summary
public DoubleProperty widthProperty()
com.dlsc.gemsfx.treeview back to summary

private Class TreeNode.TreeNodeSpliterator<T>

extends Object
implements Spliterator<TreeNode<T>>
Class Inheritance
All Implemented Interfaces
java.util.Spliterator

Field Summary

Modifier and TypeField and Description
private final Queue<TreeNode<T>>

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public int
characteristics()

Implements java.util.Spliterator.characteristics.

Returns a set of characteristics of this Spliterator and its elements.

public long
estimateSize()

Implements java.util.Spliterator.estimateSize.

Returns an estimate of the number of elements that would be encountered by a forEachRemaining traversal, or returns Long#MAX_VALUE if infinite, unknown, or too expensive to compute.

public boolean
tryAdvance(Consumer<? super TreeNode<T>> action)

Implements java.util.Spliterator.tryAdvance.

If a remaining element exists: performs the given action on it, returning true; else returns false.

public Spliterator<TreeNode<T>>
trySplit()

Implements java.util.Spliterator.trySplit.

If this spliterator can be partitioned, returns a Spliterator covering elements, that will, upon return from this method, not be covered by this Spliterator.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

queueback to summary
private final Queue<TreeNode<T>> queue

Constructor Detail

TreeNodeSpliteratorback to summary
pack-priv TreeNodeSpliterator(TreeNode<T> root)

Method Detail

characteristicsback to summary
public int characteristics()

Implements java.util.Spliterator.characteristics.

Doc from java.util.Spliterator.characteristics.

Returns a set of characteristics of this Spliterator and its elements. The result is represented as ORed values from ORDERED, DISTINCT, SORTED, SIZED, NONNULL, IMMUTABLE, CONCURRENT, SUBSIZED. Repeated calls to characteristics() on a given spliterator, prior to or in-between calls to trySplit, should always return the same result.

If a Spliterator reports an inconsistent set of characteristics (either those returned from a single invocation or across multiple invocations), no guarantees can be made about any computation using this Spliterator.

Annotations
@Override
estimateSizeback to summary
public long estimateSize()

Implements java.util.Spliterator.estimateSize.

Doc from java.util.Spliterator.estimateSize.

Returns an estimate of the number of elements that would be encountered by a forEachRemaining traversal, or returns Long#MAX_VALUE if infinite, unknown, or too expensive to compute.

If this Spliterator is SIZED and has not yet been partially traversed or split, or this Spliterator is SUBSIZED and has not yet been partially traversed, this estimate must be an accurate count of elements that would be encountered by a complete traversal. Otherwise, this estimate may be arbitrarily inaccurate, but must decrease as specified across invocations of trySplit.

Annotations
@Override
tryAdvanceback to summary
public boolean tryAdvance(Consumer<? super TreeNode<T>> action)

Implements java.util.Spliterator.tryAdvance.

Doc from java.util.Spliterator.tryAdvance.

If a remaining element exists: performs the given action on it, returning true; else returns false. If this Spliterator is ORDERED the action is performed on the next element in encounter order. Exceptions thrown by the action are relayed to the caller.

Subsequent behavior of a spliterator is unspecified if the action throws an exception.

Annotations
@Override
trySplitback to summary
public Spliterator<TreeNode<T>> trySplit()

Implements java.util.Spliterator.trySplit.

Doc from java.util.Spliterator.trySplit.

If this spliterator can be partitioned, returns a Spliterator covering elements, that will, upon return from this method, not be covered by this Spliterator.

If this Spliterator is ORDERED, the returned Spliterator must cover a strict prefix of the elements.

Unless this Spliterator covers an infinite number of elements, repeated calls to trySplit() must eventually return null. Upon non-null return:

  • the value reported for estimateSize() before splitting, must, after splitting, be greater than or equal to estimateSize() for this and the returned Spliterator; and
  • if this Spliterator is SUBSIZED, then estimateSize() for this spliterator before splitting must be equal to the sum of estimateSize() for this and the returned Spliterator after splitting.

This method may return null for any reason, including emptiness, inability to split after traversal has commenced, data structure constraints, and efficiency considerations.

Annotations
@Override