Package prefuse.data

Examples of prefuse.data.Graph$Listener


     * @param m the number of rows of the grid
     * @param n the number of columns of the grid
     * @return an m-by-n grid structured graph
     */
    public static Graph getGrid(int m, int n) {
        Graph g = new Graph();
        g.getNodeTable().addColumns(LABEL_SCHEMA);
       
        Node[] nodes = new Node[m*n];
        for ( int i = 0; i < m*n; ++i ) {
            nodes[i] = g.addNode();
            nodes[i].setString(LABEL, String.valueOf(i));
           
            if ( i >= n )
                g.addEdge(nodes[i-n], nodes[i]);
            if ( i % n != 0 )
                g.addEdge(nodes[i-1], nodes[i]);
        }
        return g;
    }
View Full Code Here


        }
        return g;
    }
   
    public static Graph getHoneycomb(int levels) {
        Graph g = new Graph();
        g.getNodeTable().addColumns(LABEL_SCHEMA);
        ArrayList layer1 = halfcomb(g, levels);
        ArrayList layer2 = halfcomb(g, levels);
        for ( int i=0; i<(levels<<1); ++i ) {
            Node n1 = (Node)layer1.get(i);
            Node n2 = (Node)layer2.get(i);
            g.addEdge(n1, n2);
        }
        return g;
    }
View Full Code Here

    /**
     * @see prefuse.action.Action#run(double)
     */
    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);

  g.getSpanningTree(n);
       
        // calc relative widths and maximum tree depth
        // performs one pass over the tree
        m_maxDepth = 0;
        calcAngularWidth(n, 0);
View Full Code Here

            }
            m_edges.removeColumn(SRCID);
            m_edges.removeColumn(TRGID);

            // now create the graph
            m_graph = new Graph(m_nodes, m_edges, m_directed);
            if (m_graphid != null)
                m_graph.putClientProperty(ID, m_graphid);
        }
View Full Code Here

            this.putValue(AbstractAction.NAME, "Open File...");
            this.putValue(AbstractAction.ACCELERATOR_KEY,
                          KeyStroke.getKeyStroke("ctrl O"));
        }
        public void actionPerformed(ActionEvent e) {
            Graph g = IOLib.getGraphFile(m_view);
            if ( g == null ) return;
            String label = getLabel(m_view, g);
            if ( label != null ) {
                m_view.setGraph(g, label);
            }
View Full Code Here

    public static JFrame demo() {
        return demo((String)null, "label");
    }
   
    public static JFrame demo(String datafile, String label) {
        Graph g = null;
        if ( datafile == null ) {
            g = GraphLib.getGrid(15,15);
            label = "label";
        } else {
            try {
View Full Code Here

        JComponent graphview = demo("/socialnet.xml", "name");
        this.getContentPane().add(graphview);
    }

    public static JComponent demo(String datafile, String label) {
        Graph g = null;
        if ( datafile == null ) {
            g = GraphLib.getGrid(15,15);
        } else {
            try {
                g = new GraphMLReader().readGraph(datafile);
View Full Code Here

            for ( int r=0; r<NEDGES; ++r ) {
                edges.set(r, EHEADERS[c], EDGES[c][r]);
            }
        }
       
        return new Graph(nodes, edges, false,
                NHEADERS[0], EHEADERS[0], EHEADERS[1]);
    }
View Full Code Here

        }
    }
   
    public void testRemoveNode() {
        int cliqueSize = 5;
        Graph g = GraphLib.getClique(cliqueSize);
        Edge[] edges = new Edge[4];
       
        Node rem = (Node)g.nodes().next();
        Iterator it = rem.edges();
        for ( int i=0; it.hasNext(); ++i ) {
            edges[i] = (Edge)it.next();
        }
       
        assertEquals(true, g.removeNode(rem));
        assertEquals(false, rem.isValid());
       
        Iterator nodes = g.nodes();
        while ( nodes.hasNext() ) {
            assertEquals(cliqueSize-2, ((Node)nodes.next()).getDegree());
        }
        for ( int i=0; i<edges.length; ++i ) {
            assertEquals(false, edges[i].isValid());
View Full Code Here

        ts.addTuple(m_vn0);
    }
   
    public void testRepeatGroup() {
      Table t = new Table();
      Graph g = new Graph();
      try {
        m_vis.add("t", t);
        fail("Should not allow duplicate groups");
      } catch ( Exception e ) {
      }
View Full Code Here

TOP

Related Classes of prefuse.data.Graph$Listener

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.