Package prefuse.visual

Examples of prefuse.visual.NodeItem


       
        Point2D a = getLayoutAnchor();
        m_ax = a.getX();
        m_ay = a.getY();
       
        NodeItem root = getLayoutRoot();
        Params rp = getParams(root);
       
        // do first pass - compute breadth information, collect depth info
        firstWalk(root, 0, 1);
       
View Full Code Here


        updateDepths(depth, n);
       
        boolean expanded = n.isExpanded();
        if ( n.getChildCount() == 0 || !expanded ) // is leaf
        {
            NodeItem l = (NodeItem)n.getPreviousSibling();
            if ( l == null ) {
                np.prelim = 0;
            } else {
                np.prelim = getParams(l).prelim + spacing(l,n,true);
            }
        }
        else if ( expanded )
        {
            NodeItem leftMost = (NodeItem)n.getFirstChild();
            NodeItem rightMost = (NodeItem)n.getLastChild();
            NodeItem defaultAncestor = leftMost;
            NodeItem c = leftMost;
            for ( int i=0; c != null; ++i, c = (NodeItem)c.getNextSibling() )
            {
                firstWalk(c, i, depth+1);
                defaultAncestor = apportion(c, defaultAncestor);
            }
           
            executeShifts(n);
           
            double midpoint = 0.5 *
                (getParams(leftMost).prelim + getParams(rightMost).prelim);
           
            NodeItem left = (NodeItem)n.getPreviousSibling();
            if ( left != null ) {
                np.prelim = getParams(left).prelim + spacing(left, n, true);
                np.mod = np.prelim - midpoint;
            } else {
                np.prelim = midpoint;
View Full Code Here

            }
        }
    }
   
    private NodeItem apportion(NodeItem v, NodeItem a) {       
        NodeItem w = (NodeItem)v.getPreviousSibling();
        if ( w != null ) {
            NodeItem vip, vim, vop, vom;
            double   sip, sim, sop, som;
           
            vip = vop = v;
            vim = w;
            vom = (NodeItem)vip.getParent().getFirstChild();
           
            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);
View Full Code Here

        }
        return a;
    }
   
    private NodeItem nextLeft(NodeItem n) {
        NodeItem c = null;
        if ( n.isExpanded() ) c = (NodeItem)n.getFirstChild();
        return ( c != null ? c : getParams(n).thread );
    }
View Full Code Here

        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 );
    }
View Full Code Here

            shift += cp.shift + change;
        }
    }
   
    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;
View Full Code Here

    public void run(double frac) {
        Graph g = (Graph)m_vis.getGroup(m_group);
        initSchema(g.getNodes());
       
        m_origin = getLayoutAnchor();
        NodeItem n = getLayoutRoot();
        Params np = (Params)n.get(PARAMS);
       
        // calc relative widths and maximum tree depth
        // performs one pass over the tree
        m_maxDepth = 0;
        calcAngularWidth(n, 0);
View Full Code Here

            m_prevRoot = r;
            return;
        }
       
        // try to find previous parent of root
        NodeItem p = m_prevRoot;
        while ( true ) {
            NodeItem pp = (NodeItem)p.getParent();
            if ( pp == r ) {
                break;
            } else if ( pp == null ) {
                m_prevRoot = r;
                return;
View Full Code Here

        double diameter = d==0 ? 0 : Math.sqrt(w*w+h*h) / d;
       
        if ( n.isExpanded() && n.getChildCount() > 0 ) {
            Iterator childIter = n.children();
            while ( childIter.hasNext() ) {
                NodeItem c = (NodeItem)childIter.next();
                aw += calcAngularWidth(c,d+1);
            }
            aw = Math.max(diameter, aw);
        } else {
            aw = diameter;
View Full Code Here

    }
   
    private Iterator sortedChildren(final NodeItem n) {
        double base = 0;
        // update base angle for node ordering
        NodeItem p = (NodeItem)n.getParent();
        if ( p != null ) {
            base = normalize(Math.atan2(p.getY()-n.getY(), p.getX()-n.getX()));
        }
        int cc = n.getChildCount();
        if ( cc == 0 ) return null;

        NodeItem c = (NodeItem)n.getFirstChild();
       
        // TODO: this is hacky and will break when filtering
        // how to know that a branch is newly expanded?
        // is there an alternative property we should check?
        if ( !c.isStartVisible() ) {
            // use natural ordering for previously invisible nodes
            return n.children();
        }
       
        double angle[] = new double[cc];
        final int idx[] = new int[cc];
        for ( int i=0; i<cc; ++i, c=(NodeItem)c.getNextSibling() ) {
            idx[i] = i;
            angle[i] = normalize(-base +
                Math.atan2(c.getY()-n.getY(), c.getX()-n.getX()));
        }
        ArrayLib.sort(angle, idx);
       
        // return iterator over sorted children
        return new Iterator() {
View Full Code Here

TOP

Related Classes of prefuse.visual.NodeItem

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.