Package prefuse.data

Examples of prefuse.data.Tree


   
    /**
     * @see prefuse.action.GroupAction#run(double)
     */
    public void run(double frac) {
        Tree tree = ((Graph)m_vis.getGroup(m_group)).getSpanningTree();
        m_divisor = tree.getNodeCount();
        m_root = (NodeItem)tree.getRoot();
       
        // mark the items
        Iterator items = m_vis.visibleItems(m_group);
        while ( items.hasNext() ) {
            VisualItem item = (VisualItem)items.next();
View Full Code Here


    public static final String TREE_CHI = "/chi-ontology.xml.gz";
   
    public void testTreeReader() {
        // load tree
        URL url = TreeMap.class.getResource(TREE_CHI);
        Tree t = null;
        try {
            GZIPInputStream gzin = new GZIPInputStream(url.openStream());
            t = (Tree) new TreeMLReader().readGraph(gzin);
        } catch ( Exception e ) {
            e.printStackTrace();
            fail();
        }
       
        assertEquals(true, t.isValidTree());
       
        Node[] nodelist = new Node[t.getNodeCount()];
       
        Iterator nodes = t.nodes();
        for ( int i=0; nodes.hasNext(); ++i ) {
            nodelist[i] = (Node)nodes.next();
        }
        assertEquals(false, nodes.hasNext());
    }
View Full Code Here

        }
        assertEquals(false, nodes.hasNext());
    }
   
    public void testAddChild() {
        Tree tree = GraphLib.getBalancedTree(2,1);
        Node r = tree.getRoot();
        Node n = tree.addChild(r);
        assertEquals(true, n!=null);
        n.setString("label", "new node");
        assertEquals(r.getLastChild(), n);
    }
View Full Code Here

        n.setString("label", "new node");
        assertEquals(r.getLastChild(), n);
    }
   
    public void testRemoveChild() {
        Tree tree = GraphLib.getBalancedTree(2,1);
        int size = tree.getNodeCount();
        Node r = tree.getRoot();
        Node c = r.getFirstChild();
        Edge e = c.getParentEdge();
       
        assertEquals(true, tree.removeChild(c));
        assertEquals(tree.getNodeCount(), size-1);
        assertEquals(false, c.isValid());
        assertEquals(false, e.isValid());
        assertEquals(true, r.getFirstChild() != c);
    }
View Full Code Here

    public static JComponent demo() {
        return demo(TREE_CHI, "name");
    }
   
    public static JComponent demo(String datafile, final String label) {
        Tree t = null;
        try {
            t = (Tree)new TreeMLReader().readGraph(datafile);
        } catch ( Exception e ) {
            e.printStackTrace();
            System.exit(1);
View Full Code Here

TOP

Related Classes of prefuse.data.Tree

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.