Top Fields Constructors Methods
com.dlsc.gemsfx.treeview

public Class TreeNodeViewSkin<T>

extends SkinBase<TreeNodeView<T>>
Class Inheritance
Imports
javafx.beans.InvalidationListener, javafx.beans.value.ChangeListener, javafx.collections.ListChangeListener, javafx.geometry.HPos, .Point2D, .VPos, javafx.scene.Group, .Node, javafx.scene.control.SkinBase, java.util.ArrayList, .HashMap, .LinkedList, .List, .Map, .Queue

Field Summary

Modifier and TypeField and Description
private final Map<TreeNode<T>, ListChangeListener<TreeNode<T>>>
private final Group
private final List<TreeNode<T>>
private final Map<TreeNode<T>, InvalidationListener>
private final Map<TreeNode<T>, InvalidationListener>
private final Map<Integer, Double>
levelToMaxDimensionMap

A map storing the maximum dimension (either width or height based on the layout direction) for each level (or depth) in the tree.

private final Map<TreeNode<T>, List<Node>>
private final Map<TreeNode<T>, Point2D>
nodeToPositionMap

The position of the nodes

private final Map<TreeNode<T>, Double>
nodeTotalDimensionMap

A map storing the total dimension (either width or height based on the layout direction) of each node.

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
private void
private void
private void
private void
clearMapsForBuild()

Clear all maps; (including listeners)

private void
clearMapsForUpdate()

Clear the position information of the nodes; do not clear the listeners

private double
private double
computeCompactAdjustedXPosition(double x, double maxLevelWidth, double nodeWidth, HPos alignment, TreeNodeView.LayoutDirection direction)

private double
computeCompactAdjustedYPosition(double y, double maxLevelHeight, double nodeHeight, VPos alignment, TreeNodeView.LayoutDirection layoutDirection)

protected double
computeMaxHeight(double width, double topInset, double rightInset, double bottomInset, double leftInset)

Overrides javafx.scene.control.SkinBase.computeMaxHeight.

Computes the maximum allowable height of the Skin, based on the provided width.

protected double
computeMaxWidth(double height, double topInset, double rightInset, double bottomInset, double leftInset)

Overrides javafx.scene.control.SkinBase.computeMaxWidth.

Computes the maximum allowable width of the Skin, based on the provided height.

public double
public double
protected double
computePrefHeight(double width, double topInset, double rightInset, double bottomInset, double leftInset)

Overrides javafx.scene.control.SkinBase.computePrefHeight.

Calculates the preferred height of this SkinBase.

protected double
computePrefWidth(double height, double topInset, double rightInset, double bottomInset, double leftInset)

Overrides javafx.scene.control.SkinBase.computePrefWidth.

Calculates the preferred width of this SkinBase.

private double
computeRegularAdjustedXPosition(double x, double maxLevelWidth, double nodeWidth, HPos alignment, TreeNodeView.LayoutDirection direction)

private double
computeRegularAdjustedYPosition(double y, double maxLevelHeight, double nodeHeight, VPos alignment, TreeNodeView.LayoutDirection layoutDirection)

private InvalidationListener
private ListChangeListener<TreeNode<T>>
private void
private void
private void
drawNode(TreeNode<T> node)

private double
private double
findMaxRowWidth(TreeNode<T> root)

Calculate the width of the widest row/level in the tree.

private void
private void
private void
private void
positionNodesCompactHorizontally(TreeNode<T> root, double maxColumnHeight, TreeNodeView.LayoutDirection direction)

private void
positionNodesCompactVertically(TreeNode<T> root, double maxRowWidth, TreeNodeView.LayoutDirection direction)

private void
private void
positionNodesRegularHorizontally(TreeNode<T> node, double x, double y, TreeNodeView.LayoutDirection layoutDirection)

private void
positionNodesRegularVertically(TreeNode<T> node, double x, double y, TreeNodeView.LayoutDirection layoutDirection)

public void
private void
private void
toggleChildrenVisibility(TreeNode<T> node, boolean isVisible, boolean updateTreeAfterToggle)

Toggle the visibility of the node's children

private void
updateTree()

When expanding or collapsing, the display of the tree needs to be updated

Inherited from javafx.scene.control.SkinBase:
computeBaselineOffsetcomputeMinHeightcomputeMinWidthconsumeMouseEventsdisposeexecuteAccessibleActiongetChildrengetClassCssMetaDatagetCssMetaDatagetNodegetSkinnablelayoutChildrenlayoutInArealayoutInArealayoutInAreapositionInAreapositionInAreapseudoClassStateChangedqueryAccessibleAttributeregisterChangeListenerregisterInvalidationListenerregisterListChangeListenersnappedBottomInsetsnappedLeftInsetsnappedRightInsetsnappedTopInsetsnapPositionsnapPositionXsnapPositionYsnapSizesnapSizeXsnapSizeYsnapSpacesnapSpaceXsnapSpaceYunregisterChangeListenersunregisterInvalidationListenersunregisterListChangeListeners

Field Detail

childrenListListenerMapback to summary
private final Map<TreeNode<T>, ListChangeListener<TreeNode<T>>> childrenListListenerMap
contentGroupback to summary
private final Group contentGroup
currentLevelNodesCacheback to summary
private final List<TreeNode<T>> currentLevelNodesCache
expandListenerMapback to summary
private final Map<TreeNode<T>, InvalidationListener> expandListenerMap
invailidateListenerMapback to summary
private final Map<TreeNode<T>, InvalidationListener> invailidateListenerMap
levelToMaxDimensionMapback to summary
private final Map<Integer, Double> levelToMaxDimensionMap

A map storing the maximum dimension (either width or height based on the layout direction) for each level (or depth) in the tree. - For LEFT_TO_RIGHT or RIGHT_TO_LEFT layouts, it represents the maximum height for a particular depth or level. - For TOP_TO_BOTTOM or BOTTOM_TO_TOP layouts, it represents the maximum width for a particular depth or level. This map ensures that nodes on the same level do not overlap and provides consistent spacing across different layout directions.

nodeToComponentsMapback to summary
private final Map<TreeNode<T>, List<Node>> nodeToComponentsMap
nodeToPositionMapback to summary
private final Map<TreeNode<T>, Point2D> nodeToPositionMap

The position of the nodes

nodeTotalDimensionMapback to summary
private final Map<TreeNode<T>, Double> nodeTotalDimensionMap

A map storing the total dimension (either width or height based on the layout direction) of each node. - For LEFT_TO_RIGHT or RIGHT_TO_LEFT layouts, it represents the total height of a node, which includes the node itself and its maximum subtree height. - For TOP_TO_BOTTOM or BOTTOM_TO_TOP layouts, it represents the total width of a node, including the node and its maximum subtree width. The purpose of this map is to dynamically adapt to different layout directions and provide a consistent way to handle node dimensions.

Constructor Detail

TreeNodeViewSkinback to summary
public TreeNodeViewSkin(TreeNodeView<T> view)

Method Detail

addListenersToNodeback to summary
private void addListenersToNode(TreeNode<T> node)
buildTreeback to summary
private void buildTree()
calculatePositionsback to summary
private void calculatePositions(TreeNode<T> root)
clearMapsForBuildback to summary
private void clearMapsForBuild()

Clear all maps; (including listeners)

clearMapsForUpdateback to summary
private void clearMapsForUpdate()

Clear the position information of the nodes; do not clear the listeners

computeAndCacheNodeDimensionback to summary
private double computeAndCacheNodeDimension(TreeNode<T> node)
computeCompactAdjustedXPositionback to summary
private double computeCompactAdjustedXPosition(double x, double maxLevelWidth, double nodeWidth, HPos alignment, TreeNodeView.LayoutDirection direction)
computeCompactAdjustedYPositionback to summary
private double computeCompactAdjustedYPosition(double y, double maxLevelHeight, double nodeHeight, VPos alignment, TreeNodeView.LayoutDirection layoutDirection)
computeMaxHeightback to summary
protected double computeMaxHeight(double width, double topInset, double rightInset, double bottomInset, double leftInset)

Overrides javafx.scene.control.SkinBase.computeMaxHeight.

Doc from javafx.scene.control.SkinBase.computeMaxHeight.

Computes the maximum allowable height of the Skin, based on the provided width.

Annotations
@Override
computeMaxWidthback to summary
protected double computeMaxWidth(double height, double topInset, double rightInset, double bottomInset, double leftInset)

Overrides javafx.scene.control.SkinBase.computeMaxWidth.

Doc from javafx.scene.control.SkinBase.computeMaxWidth.

Computes the maximum allowable width of the Skin, based on the provided height.

Annotations
@Override
computeNodeHeightback to summary
public double computeNodeHeight(TreeNode<T> node)
computeNodeWidthback to summary
public double computeNodeWidth(TreeNode<T> node)
computePrefHeightback to summary
protected double computePrefHeight(double width, double topInset, double rightInset, double bottomInset, double leftInset)

Overrides javafx.scene.control.SkinBase.computePrefHeight.

Doc from javafx.scene.control.SkinBase.computePrefHeight.

Calculates the preferred height of this SkinBase. The default implementation calculates this height as the height of the area occupied by its managed children when they are positioned at their current positions at their preferred heights.

Annotations
@Override
computePrefWidthback to summary
protected double computePrefWidth(double height, double topInset, double rightInset, double bottomInset, double leftInset)

Overrides javafx.scene.control.SkinBase.computePrefWidth.

Doc from javafx.scene.control.SkinBase.computePrefWidth.

Calculates the preferred width of this SkinBase. The default implementation calculates this width as the width of the area occupied by its managed children when they are positioned at their current positions at their preferred widths.

Annotations
@Override
computeRegularAdjustedXPositionback to summary
private double computeRegularAdjustedXPosition(double x, double maxLevelWidth, double nodeWidth, HPos alignment, TreeNodeView.LayoutDirection direction)
computeRegularAdjustedYPositionback to summary
private double computeRegularAdjustedYPosition(double y, double maxLevelHeight, double nodeHeight, VPos alignment, TreeNodeView.LayoutDirection layoutDirection)
createExpandListenerback to summary
private InvalidationListener createExpandListener(TreeNode<T> node)
createNodeListChangeListenerback to summary
private ListChangeListener<TreeNode<T>> createNodeListChangeListener()
drawAdditionalLinkedNodesback to summary
private void drawAdditionalLinkedNodes()
drawLinksForNodeback to summary
private void drawLinksForNode(TreeNode<T> node)
drawNodeback to summary
private void drawNode(TreeNode<T> node)
findMaxColumnHeightback to summary
private double findMaxColumnHeight(TreeNode<T> root)
findMaxRowWidthback to summary
private double findMaxRowWidth(TreeNode<T> root)

Calculate the width of the widest row/level in the tree.

initNodeListenersback to summary
private void initNodeListeners()
initTreeback to summary
private void initTree()
positionNodesCompactback to summary
private void positionNodesCompact(TreeNode<T> root)
positionNodesCompactHorizontallyback to summary
private void positionNodesCompactHorizontally(TreeNode<T> root, double maxColumnHeight, TreeNodeView.LayoutDirection direction)
positionNodesCompactVerticallyback to summary
private void positionNodesCompactVertically(TreeNode<T> root, double maxRowWidth, TreeNodeView.LayoutDirection direction)
positionNodesRegularback to summary
private void positionNodesRegular(TreeNode<T> root)
positionNodesRegularHorizontallyback to summary
private void positionNodesRegularHorizontally(TreeNode<T> node, double x, double y, TreeNodeView.LayoutDirection layoutDirection)
positionNodesRegularVerticallyback to summary
private void positionNodesRegularVertically(TreeNode<T> node, double x, double y, TreeNodeView.LayoutDirection layoutDirection)
refreshback to summary
public void refresh()
removeListenersFromNodeback to summary
private void removeListenersFromNode(TreeNode<T> removedNode)
toggleChildrenVisibilityback to summary
private void toggleChildrenVisibility(TreeNode<T> node, boolean isVisible, boolean updateTreeAfterToggle)

Toggle the visibility of the node's children

updateTreeback to summary
private void updateTree()

When expanding or collapsing, the display of the tree needs to be updated