Package prefuse.data.util

Examples of prefuse.data.util.TreeNodeIterator


        Graph g = (Graph)m_vis.getGroup(m_group);
        TupleSet nodes = g.getNodes();
        nodes.addColumns(AREA_SCHEMA);
       
        // reset all sizes to zero
        Iterator iter = new TreeNodeIterator(root);
        while ( iter.hasNext() ) {
            NodeItem n = (NodeItem)iter.next();
            n.setDouble(AREA, 0);
        }
       
        // set raw sizes, compute leaf count
        iter = new TreeNodeIterator(root, false);
        while ( iter.hasNext() ) {
            NodeItem n = (NodeItem)iter.next();
            double area = 0;
            if ( n.getChildCount() == 0 ) {
              area = n.getSize();
              ++leafCount;
            } else if ( n.isExpanded() ) {
              NodeItem c = (NodeItem)n.getFirstChild();
              for (; c!=null; c = (NodeItem)c.getNextSibling()) {
                area += c.getDouble(AREA);
                ++leafCount;
              }
            }
            n.setDouble(AREA, area);
           
        }
       
        // scale sizes by display area factor
        Rectangle2D b = getLayoutBounds();
        double area = (b.getWidth()-1)*(b.getHeight()-1);
        double scale = area/root.getDouble(AREA);
        iter = new TreeNodeIterator(root);
        while ( iter.hasNext() ) {
            NodeItem n = (NodeItem)iter.next();
            n.setDouble(AREA, n.getDouble(AREA)*scale);
        }
    }
View Full Code Here


        Node r = tree.getRoot();
        Node c = r.getFirstChild();
       
        Node[] nodes = new Node[13];
        Edge[] edges = new Edge[13];
        Iterator iter = new TreeNodeIterator(c);
        for ( int i=0; iter.hasNext(); ++i ) {
            nodes[i] = (Node)iter.next();
            edges[i] = (Edge)nodes[i].getParentEdge();
        }
       
        assertEquals(true, tree.removeChild(c));
        assertEquals(tree.getNodeCount(), size-13);
View Full Code Here

TOP

Related Classes of prefuse.data.util.TreeNodeIterator

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.