protected void zip(CompactTreeNode node) { if (node.child != null) { attachParent(node, join(node)); } else { layoutLeaf(node); } if (node.parent != null) { zip(node.parent); } }
/** * Get the minimum distance between a parent from any of its children * @deprecated use getLevelDistance * * @return the level distance */ public double getChildParentDistance() { return getLevelDistance(); }
public void visit(Object parent, Object cell, Object previousSibling, int layer, int sibling) { CompactTreeNode parentNode = getTreeLayoutNode(parent); CompactTreeNode childNode = getTreeLayoutNode(cell); if (parentNode != null) { if (previousSibling == null) { parentNode.child = childNode; } else { CompactTreeNode prevNode = getTreeLayoutNode(previousSibling); prevNode.sibling = childNode; } } }
/** * 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); } }
layoutTree(getTreeLayoutNode(graph.getRootAt(i))); dispatchResult(nodes.values());
/** * Lays out a Moen in the left-right orientation * * @param node * the current node being laid out * @param off_x * x-axis offset * @param off_y * y-axis offset */ protected void leftRightNodeLayout(CompactTreeNode node, double off_x, double off_y) { CompactTreeNode child, s; double siblingOffset; node.x += off_x + node.offsetX; node.y += off_y + node.offsetY; child = node.child; // topmost child if (child != null) { leftRightNodeLayout(child, node.x, node.y); s = child.sibling; siblingOffset = node.y + child.offsetY; while (s != null) { leftRightNodeLayout(s, node.x + child.offsetX, siblingOffset); siblingOffset += s.offsetY; s = s.sibling; } } }
/** * Obtains the mapped node from the internal tree representation used from * the cell specified * * @param cell * the cell whose <code>TreeLayoutNode</code> is to be found * @return the internal node representation of the specified cell */ protected CompactTreeNode getTreeLayoutNode(Object cell) { if (cell != null) { return getTreeLayoutNode(cell, true); } return null; }