TreeLayout { private void dumpTree(PrintStream output, TreeNode node, int indent, DumpConfiguration dumpConfiguration) { StringBuilder sb = new StringBuilder(); for (int i = 0; i < indent; i++) { sb.append(dumpConfiguration.indent); } if (dumpConfiguration.includeObjectToString) { sb.append("["); sb.append(node.getClass().getName() + "@" + Integer.toHexString(node.hashCode())); if (node.hashCode() != System.identityHashCode(node)) { sb.append("/identityHashCode:"); sb.append(Integer.toHexString(System.identityHashCode(node))); } sb.append("]"); } sb.append(StringUtil.quote(node != null ? node.toString() : null)); if (dumpConfiguration.includeNodeSize) { sb.append(" (size: "); sb.append(getNodeWidth(node)); sb.append("x"); sb.append(getNodeHeight(node)); sb.append(")"); } output.println(sb.toString()); for (TreeNode n : tree.getChildren(node)) { dumpTree(output, n, indent + 1, dumpConfiguration); } } TreeLayout(TreeForTreeLayout<TreeNode> tree,
			NodeExtentProvider<TreeNode> nodeExtentProvider,
			Configuration<TreeNode> configuration, boolean useIdentity);  TreeLayout(TreeForTreeLayout<TreeNode> tree,
			NodeExtentProvider<TreeNode> nodeExtentProvider,
			Configuration<TreeNode> configuration); TreeForTreeLayout<TreeNode> getTree(); NodeExtentProvider<TreeNode> getNodeExtentProvider(); Configuration<TreeNode> getConfiguration(); Rectangle2D getBounds(); int getLevelCount(); double getSizeOfLevel(int level); Map<TreeNode, Rectangle2D.Double> getNodeBounds(); void checkTree(); void dumpTree(PrintStream printStream, DumpConfiguration dumpConfiguration); void dumpTree(PrintStream printStream);  }
@Test public void testDumpTree() { StringTreeNode root = createSampleTree_1(); TreeLayout<StringTreeNode> layout = layout(root); ByteArrayOutputStream out = new ByteArrayOutputStream(); PrintStream printStream = new PrintStream(out); layout.dumpTree(printStream, new TreeLayout.DumpConfiguration("- ", true, false)); String s = out.toString(); assertEquals( "\"root\" (size: 60.0x20.0)" + NL + "- \"n1\" (size: 60.0x20.0)" + NL + "- - \"n1.1\" (size: 60.0x20.0)" + NL + "- - \"n1.2\" (size: 60.0x20.0)" + NL + "- \"n2\" (size: 60.0x20.0)" + NL + "- - \"n2.1\" (size: 60.0x20.0)" + NL, s); }