sip = getParams(vip).mod; sop = getParams(vop).mod; sim = getParams(vim).mod; som = getParams(vom).mod; NodeItem nr = nextRight(vim); NodeItem nl = nextLeft(vip); while ( nr != null && nl != null ) { vim = nr; vip = nl; 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); sip += shift; sop += shift; sim += getParams(vim).mod; sip += getParams(vip).mod; som += getParams(vom).mod; sop += getParams(vop).mod; nr = nextRight(vim); nl = nextLeft(vip); if ( nr != null && nextRight(vop) == null ) {
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); for ( int i=0; c != null; ++i, c = (NodeItem)c.getNextSibling() ) firstWalk(c, i, depth+1); defaultAncestor = apportion(c, defaultAncestor); executeShifts(n); (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); }
NodeLinkTreeLayout treeLayout = new NodeLinkTreeLayout( GRAPH, orientation, 40, 0, 8 ); treeLayout.setLayoutAnchor( new Point2D.Double( 25, 300 ) ); m_vis.putAction( LAYOUT_ACTION, treeLayout ); NodeLinkTreeLayout rtl = (NodeLinkTreeLayout) m_vis.getAction( LAYOUT_ACTION ); CollapsedSubtreeLayout stl = (CollapsedSubtreeLayout) m_vis.getAction( SUB_LAYOUT_ACTION ); rtl.setOrientation( orientation ); stl.setOrientation( orientation );
NodeLinkTreeLayout treeLayout = new NodeLinkTreeLayout(tree, m_orientation, 50, 0, 8); treeLayout.setLayoutAnchor(new Point2D.Double(25,300)); m_vis.putAction("treeLayout", treeLayout);
rtl.setOrientation(orientation); stl.setOrientation(orientation);
/** * @see prefuse.action.layout.Layout#getLayoutAnchor() */ public Point2D getLayoutAnchor() { if ( m_anchor != null ) return m_anchor; m_tmpa.setLocation(0,0); if ( m_vis != null ) { Display d = m_vis.getDisplay(0); Rectangle2D b = this.getLayoutBounds(); switch ( m_orientation ) { case Constants.ORIENT_LEFT_RIGHT: m_tmpa.setLocation(m_offset, d.getHeight()/2.0); break; case Constants.ORIENT_RIGHT_LEFT: m_tmpa.setLocation(b.getMaxX()-m_offset, d.getHeight()/2.0); break; case Constants.ORIENT_TOP_BOTTOM: m_tmpa.setLocation(d.getWidth()/2.0, m_offset); break; case Constants.ORIENT_BOTTOM_TOP: m_tmpa.setLocation(d.getWidth()/2.0, b.getMaxY()-m_offset); break; } d.getInverseTransform().transform(m_tmpa, m_tmpa); } return m_tmpa; }