public void visit(Object parent, Object cell, Object previousSibling, int layer, int sibling) { StandardTreeNode parentNode = getTreeNode(parent); StandardTreeNode childNode = getTreeNode(cell); if (parentNode != null) { parentNode.addChild(childNode); childNode.setParent(parentNode); } } });
/** * Sets the minimum distance, upon the axis of orientation of the layout, * that a parent will be from any of its children * @deprecated use setLevelDistance * * @param distance * the minimum distance */ public void setChildParentDistance(double distance) { setLevelDistance(distance); }
protected void zip(CompactTreeNode node) { if (node.child != null) { attachParent(node, join(node)); } else { layoutLeaf(node); } if (node.parent != null) { zip(node.parent); } }
/** * 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); } }
/** * The API method used to exercise the layout upon the facade description * and produce a separate description of the vertex position and edge * routing changes made. It first builds a representation of the tree using * the inner tree class by doing a depth first search of the graph from the * root. It then lays out the graph using the obtained data * * @param graph * the facade describing the graph and its configuration */ public void run(JGraphFacade graph) { super.run(graph); }
/** * Laids out a tree node as a leaf, taking into account node shape * * @param t * the node to be laid out */ protected void layoutLeaf(CompactTreeNode t) { t.contour.upperTail = new PolyLine(t.height + 2 * nodeDistance, 0, null); t.contour.upperHead = t.contour.upperTail; t.contour.lowerTail = new PolyLine(0, -t.width - 2 * nodeDistance, null); t.contour.lowerHead = new PolyLine(t.height + 2 * nodeDistance, 0, t.contour.lowerTail); }
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; } } }
/** * Get the minimum distance between a parent from any of its children * @deprecated use getLevelDistance * * @return the level distance */ public double getChildParentDistance() { return getLevelDistance(); }
protected void unzip(CompactTreeNode node) { if (node.parent != null) { unzip(node.parent); } if (node.child != null) { // TODO detachParent(node); // TODO split(node); } else { // TODO rubout(node); } }
/** * @param depth the depth to set */ public void setDepth(int depth) { super.setDepth(depth); if (depth >= vertexDepthOrientationSwitch) { verticalStyleChildren = true; } }
/** * joins the specified tree node * * @param t * the tree node to be joined * @return Returns the size of the tree. */ protected double join(CompactTreeNode t) { CompactTreeNode c; double d, h, sum; c = t.child; t.contour = c.contour; sum = h = c.width + 2 * nodeDistance; c = c.sibling; while (c != null) { d = merge(t.contour, c.contour); c.offsetY = d + h; c.offsetX = 0; h = c.width + 2 * nodeDistance; sum += d + h; c = c.sibling; } return sum; }
/** * @param cell * the cell whose tree node is to be obtained * @return the tree node corresponding to the specified cell */ public TreeNode getTreeNode(Object cell) { if (cell == null) cell = virtualRootCell; if (cell != null) { TreeNode node = (TreeNode) nodes.get(cell); if (node == null) { node = new TreeNode(cell); nodes.put(cell, node); } return node; } return null; }
/** * * @return the left-most limit of the sub-tree beneath this node */ public double leftLimit() { return Math.min(normalize(leftBisector), (leftTangent)); }
/** * Creates a node corresponding to the specified graph cell and of the * given dimensions. Interally, the width and height are stored reversed * for a horizontal tree to reduce the processing required when laying * the tree out * * @param cell * the corresponding graph cell */ public CompactTreeNode(Object cell) { super(cell); contour = new Polygon(); }
/** * Creates tree node corresponding to the specified cell * * @param cell * the cell this tree node corresponds to */ public StandardTreeNode(Object cell) { super(cell); this.children = new ArrayList(); this.leftContour = new PolyLine(width / 2.0); this.rightContour = new PolyLine(width / 2.0); this.depth = 0; }
/** * Attaches the specified tree node in a parent-child relationship taking * into account node shape * * @param t * the internal tree node */ protected void attachParent(CompactTreeNode t, double h) { final double x; double y1; final double y2; x = nodeDistance + levelDistance; y2 = (h - t.width) / 2 - nodeDistance; y1 = y2 + t.width + 2 * nodeDistance - h; t.child.offsetX = x + t.height; t.child.offsetY = y1; t.contour.upperHead = new PolyLine(t.height, 0, new PolyLine(x, y1, t.contour.upperHead)); t.contour.lowerHead = new PolyLine(t.height, 0, new PolyLine(x, y2, t.contour.lowerHead)); }
/** * 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; }
/** * * @return the right-most limit of the sub-tree beneath this node */ public double rightLimit() { return Math.max(normalize(rightBisector), (rightTangent)); }
/** * * @param line1 * @param x1 * @param y1 * @param line2 * @param x2 * @param y2 * @return Returns a <code>PolyLine</code> */ protected PolyLine bridge(PolyLine line1, double x1, double y1, PolyLine line2, double x2, double y2) { double dy, dx, s; PolyLine r; dx = x2 + line2.dx - x1; if (line2.dx == 0) { dy = line2.dy; } else { s = dx * line2.dy; dy = s / line2.dx; } r = new PolyLine(dx, dy, line2.link); line1.link = new PolyLine(0, y2 + line2.dy - dy - y1, r); return r; }