Class ItemTreeToolkit


  • public final class ItemTreeToolkit
    extends Object
    Toolkit for working with item trees.
    • Constructor Detail

      • ItemTreeToolkit

        public ItemTreeToolkit()
    • Method Detail

      • printTree

        public static String printTree​(ITreeNode<IItem> node)
        Returns:
        A String representation of the tree. Useful for debugging.
      • appendLongestBreakdown

        public static void appendLongestBreakdown​(StringBuilder report,
                                                  ITreeNode<IItem> root)
        Renders a report of the longest encapsulating event chain.

        If we have A -> (B->D, C->E) and B has longer duration than C, the report will be A => B => D.

        Parameters:
        report - the report to write to
        root - the root node to start from
      • appendLayeredBreakdown

        public static void appendLayeredBreakdown​(StringBuilder report,
                                                  ITreeNode<IItem> root,
                                                  int maxDepth)
        Reports all encapsulation layers.

        If A -> (B->D, C->E), the report will show:

        • Layer 1: A (100 %)
        • Layer 2: B (X %), C (Y %)
        • Layer 3: D (U %), E (V %)

        Parameters:
        report - the report to write to
        root - the root node to start the analysis from
        maxDepth - maximum number of layers to analyze
      • getDepth

        public static int getDepth​(ITreeNode<?> node)
        Returns the number of ancestors the node has.
        Parameters:
        node - the node for which to calculate the depth
        Returns:
        the depth of the node from the root