/** * Laids out the specified tree node in the internal tree representation * * @param t * the node to be laid out */ protected void layout(CompactTreeNode t) { CompactTreeNode c; if (t == null) { return; } c = t.child; while (c != null) { layout(c); c = c.sibling; } if (t.child != null) { attachParent(t, join(t)); } else { layoutLeaf(t); } }
/** * Top-level layout method for Moen * * @param root * the root node of the tree */ protected void layoutTree(CompactTreeNode root) { // kick off Moen's algorithm layout(root); Rectangle2D rect = graph.getBounds(root.getCell()); double rootPositionX = rect.getX(); double rootPositionY = rect.getY(); switch (orientation) { case SwingConstants.WEST: leftRightNodeLayout(root, rootPositionX, rootPositionY); break; case SwingConstants.NORTH: upDownNodeLayout(root, null, rootPositionX, rootPositionY); break; default: leftRightNodeLayout(root, rootPositionX, rootPositionY); } }