/** * Displays the tree, starting with the given root node. * * @param root the Node that is the root of the tree to be displayed * @param offset the String */ public static void displayTree(Node root, String offset) { if (root.children.size() == 0) { DecisionTree.appendText("\n" + offset + " THEN (" + root.label + ") (Leaf node)"); return; } else { Enumeration enum1 = root.children.elements(); Enumeration enum2 = root.linkLabels.elements(); DecisionTree.appendText("\n" + offset + " " + root.label + " (Interior node)"); while (enum1.hasMoreElements()) { DecisionTree.appendText("\n" + offset + " IF (" + (String) enum2.nextElement() + ")"); displayTree((Node) enum1.nextElement(), offset + " "); } } }