private NodeItem ancestor(NodeItem vim, NodeItem v, NodeItem a) { NodeItem p = (NodeItem)v.getParent(); Params vimp = getParams(vim); if ( vimp.ancestor.getParent() == p ) { return vimp.ancestor; } else { return a; } }
private NodeItem nextLeft(NodeItem n) { NodeItem c = null; if ( n.isExpanded() ) c = (NodeItem)n.getFirstChild(); return ( c != null ? c : getParams(n).thread ); }
private NodeItem nextRight(NodeItem n) { NodeItem c = null; if ( n.isExpanded() ) c = (NodeItem)n.getLastChild(); return ( c != null ? c : getParams(n).thread ); }
private void executeShifts(NodeItem n) { double shift = 0, change = 0; for ( NodeItem c = (NodeItem)n.getLastChild(); c != null; c = (NodeItem)c.getPreviousSibling() ) { Params cp = getParams(c); cp.prelim += shift; cp.mod += shift; change += cp.change; shift += cp.shift + change; } }
vom = (NodeItem)vip.getParent().getFirstChild(); sip = getParams(vip).mod; sop = getParams(vop).mod; sim = getParams(vim).mod; som = getParams(vom).mod; vom = nextLeft(vom); vop = nextRight(vop); getParams(vop).ancestor = v; double shift = (getParams(vim).prelim + sim) - (getParams(vip).prelim + sip) + spacing(vim,vip,false); if ( shift > 0 ) { moveSubtree(ancestor(vim,v,a), v, shift); sim += getParams(vim).mod; sip += getParams(vip).mod; som += getParams(vom).mod; sop += getParams(vop).mod; Params vopp = getParams(vop); vopp.thread = nr; vopp.mod += sim - sop; Params vomp = getParams(vom); vomp.thread = nl; vomp.mod += sip - som;
private void firstWalk(NodeItem n, int num, int depth) { Params np = getParams(n); np.number = num; updateDepths(depth, n); np.prelim = 0; } else { np.prelim = getParams(l).prelim + spacing(l,n,true); (getParams(leftMost).prelim + getParams(rightMost).prelim); np.prelim = getParams(left).prelim + spacing(left, n, true); np.mod = np.prelim - midpoint; } else {
/** * @see prefuse.action.Action#run(double) */ public void run(double frac) { Graph g = (Graph)m_vis.getGroup(m_group); initSchema(g.getNodes()); Arrays.fill(m_depths, 0); m_maxDepth = 0; Point2D a = getLayoutAnchor(); m_ax = a.getX(); m_ay = a.getY(); NodeItem root = getLayoutRoot(); Params rp = getParams(root); g.getSpanningTree(root); // do first pass - compute breadth information, collect depth info firstWalk(root, 0, 1); // sum up the depth info determineDepths(); // do second pass - assign layout positions secondWalk(root, null, -rp.prelim, 0); }
private void secondWalk(NodeItem n, NodeItem p, double m, int depth) { Params np = getParams(n); setBreadth(n, p, np.prelim + m); setDepth(n, p, m_depths[depth]); if ( n.isExpanded() ) { depth += 1; for ( NodeItem c = (NodeItem)n.getFirstChild(); c != null; c = (NodeItem)c.getNextSibling() ) { secondWalk(c, n, m + np.mod, depth); } } np.clear(); }