Class TreeNode


  • public class TreeNode
    extends java.lang.Object
    Bean to represent one row in the display of a tree
    Author:
    Kim Rutherford, Mark Woodbridge
    • Constructor Summary

      Constructors 
      Constructor Description
      TreeNode​(java.lang.Object o, java.lang.String text, int indentation, boolean selected, boolean leaf, boolean open, java.util.List<java.lang.String> structure)
      Constructor
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean equals​(java.lang.Object obj)
      int getIndentation()
      Get the indentation
      java.lang.Object getObject()
      Get the Object
      java.util.List<java.lang.String> getStructure()
      Returns the structure of the tree.
      java.lang.String getText()
      Get the text that was passed to the constructor
      int hashCode()
      boolean isLeaf()
      Is this node a leaf?
      boolean isOpen()
      Is this node expanded?
      boolean isSelected()
      Is this node selected?
      java.lang.String toString()
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • TreeNode

        public TreeNode​(java.lang.Object o,
                        java.lang.String text,
                        int indentation,
                        boolean selected,
                        boolean leaf,
                        boolean open,
                        java.util.List<java.lang.String> structure)
        Constructor
        Parameters:
        o - the Object
        text - extra text describing this node
        indentation - the indentation
        selected - whether the node has been selected
        leaf - whether this is a leaf node
        open - whether this node is 'open' ie. expanded
        structure - a List of Strings - for definition, see getStructure()
    • Method Detail

      • getObject

        public java.lang.Object getObject()
        Get the Object
        Returns:
        the Object
      • getText

        public java.lang.String getText()
        Get the text that was passed to the constructor
        Returns:
        the test
      • getIndentation

        public int getIndentation()
        Get the indentation
        Returns:
        the indentation
      • isSelected

        public boolean isSelected()
        Is this node selected?
        Returns:
        true if this node is selected, and false otherwise
      • isLeaf

        public boolean isLeaf()
        Is this node a leaf?
        Returns:
        true if this node is a leaf, and false otherwise
      • isOpen

        public boolean isOpen()
        Is this node expanded?
        Returns:
        true if this node is expanded, and false otherwise
      • getStructure

        public java.util.List<java.lang.String> getStructure()
        Returns the structure of the tree. This is an array of Strings, which are one of four possible strings, in order to draw a tree structure:
        • blank - Do not draw any lines.
        • straight - Draw a straight vertical line.
        • ell - Draw an L-shaped line.
        • tee - Draw a T-junction, with lines going vertically and to the right.
        If the sequence of these is correctly drawn in front of each tree node, then a tree structure will be drawn correctly.
        Returns:
        a List of Strings
      • equals

        public boolean equals​(java.lang.Object obj)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object