/** * Top-level method that performs actual layout of tree for a specific node. * Note this acts upon the internal tree node structure * * @param node * the tree node to be laid out */ protected void layout(StandardTreeNode node) { if (node.children.size() == 0) { // do nothing } else if (node.children.size() == 1) { StandardTreeNode sub = (StandardTreeNode) node.children.get(0); sub.setDepth(node.getDepth() + 1); layout(sub); sub.leftContour.dx = (sub.width - node.width) / 2; sub.rightContour.dx = (sub.width - node.width) / 2; node.leftContour.next = sub.leftContour; node.rightContour.next = sub.rightContour; } else { for (Iterator it = node.children.iterator(); it.hasNext();) { StandardTreeNode n = (StandardTreeNode) it.next(); n.setDepth(node.getDepth() + 1); layout(n); } join(node); } }