Class IntrospectorModel

java.lang.Object
introspector.model.IntrospectorModel
All Implemented Interfaces:
TreeModel

public class IntrospectorModel extends Object implements TreeModel
Model object that represents a tree. It implements the TreeModel to allow its visualization as a JTree.
  • Field Details

    • root

      private final Node root
      The root node of the tree.
  • Constructor Details

    • IntrospectorModel

      public IntrospectorModel(String name, Object root)
      Constructs a tres given its name and the root object
      Parameters:
      name - The name used to visualize the tree.
      root - The object that will be used as the root node of the tree.
    • IntrospectorModel

      public IntrospectorModel(String name, Object root, boolean deepClone)
      Constructs a tres given its name, the root object and whether the tree should be cloned deeply.
      Parameters:
      name - The name used to visualize the tree.
      root - The object that will be used as the root node of the tree.
      deepClone - Whether the tree should be cloned deeply. This is important when the tree is going to be compared with a later version of the tree. In such a case, it must be cloned deeply to show the differences between the two trees.
  • Method Details

    • getRoot

      public Node getRoot()
      Specified by:
      getRoot in interface TreeModel
      Returns:
      The root node of the tree.
    • getChild

      public Node getChild(Object parent, int index)
      Returns the index-th child of the parent node.
      Specified by:
      getChild in interface TreeModel
      Parameters:
      parent - a node in the tree, obtained from this data source
      index - index of child to be returned
      Returns:
      the index-th child of the parent node.
    • getChildCount

      public int getChildCount(Object parent)
      Returns the number of children of parent node.
      Specified by:
      getChildCount in interface TreeModel
      Parameters:
      parent - a node in the tree, obtained from this data source
      Returns:
      the number of children of parent node.
    • isLeaf

      public boolean isLeaf(Object object)
      Returns whether the parameter is a leaf node.
      Specified by:
      isLeaf in interface TreeModel
      Parameters:
      object - a node in the tree, obtained from this data source
      Returns:
      whether the parameter is a leaf node.
    • getIndexOfChild

      public int getIndexOfChild(Object parent, Object child)
      Gets the index of the child node in parent.
      Specified by:
      getIndexOfChild in interface TreeModel
      Parameters:
      parent - a node in the tree, obtained from this data source
      child - the node we are interested in
      Returns:
      the index of the child node in parent.
    • valueForPathChanged

      public void valueForPathChanged(TreePath path, Object newValue)
      Specified by:
      valueForPathChanged in interface TreeModel
    • addTreeModelListener

      public void addTreeModelListener(TreeModelListener l)
      Specified by:
      addTreeModelListener in interface TreeModel
    • removeTreeModelListener

      public void removeTreeModelListener(TreeModelListener l)
      Specified by:
      removeTreeModelListener in interface TreeModel