Package org.gephi.graph.api

Examples of org.gephi.graph.api.GraphView


    public void testDelete() {
        Node node1 = nodeMap.get("Node 1");
        Node node2 = nodeMap.get("Node 2");
        Edge edge21 = edgeMap.get("2-1");

        GraphView newView = dhnsGlobal.newView();
        HierarchicalGraph viewGraph = dhnsGlobal.getHierarchicalGraph(newView);

        assertNotNull(node1.getNodeData().getNode(newView.getViewId()));
        assertNotNull(dhnsGlobal.getGraphStructure().getNodeFromDictionnary(node1.getId(), newView.getViewId()));
        assertNotNull(dhnsGlobal.getGraphStructure().getNodeFromDictionnary(node1.getId(), graphGlobal.getView().getViewId()));
        assertNotNull(dhnsGlobal.getGraphStructure().getEdgeFromDictionnary(edge21.getId()));

        graphGlobal.removeNode(node1);

        assertNull(node1.getNodeData().getNode(graphGlobal.getView().getViewId()));
        assertNull(node1.getNodeData().getNode(newView.getViewId()));

        assertEquals(Boolean.FALSE, graphGlobal.contains(node1));
        assertEquals(Boolean.FALSE, viewGraph.contains(node1));
        assertEquals(Boolean.FALSE, graphGlobal.contains(edge21));
        assertEquals(Boolean.FALSE, viewGraph.contains(edge21));
View Full Code Here


            if (graphs.length > 1) {
                throw new IllegalArgumentException("Not Filter accepts a single graph in parameter");
            }

            HierarchicalGraph hgraph = (HierarchicalGraph) graphs[0];
            GraphView hgraphView = hgraph.getView();
            HierarchicalGraph mainHGraph = hgraph.getView().getGraphModel().getHierarchicalGraph();
            for (Edge e : mainHGraph.getEdges().toArray()) {
                Node source = e.getSource().getNodeData().getNode(hgraphView.getViewId());
                Node target = e.getTarget().getNodeData().getNode(hgraphView.getViewId());
                if (source != null && target != null) {
                    Edge edgeInGraph = hgraph.getEdge(source, target);
                    if (edgeInGraph == null) {
                        //The edge is not in graph
                        hgraph.addEdge(e);
View Full Code Here

        Node n1 = factory.newNode("n1");
        Node n2 = factory.newNode("n2");
        rootGraph.addNode(n1);
        rootGraph.addNode(n2);

        GraphView newView = graphModel.newView();
        Graph graphNewView = graphModel.getGraph(newView);
        Node n1c = graphNewView.getNode("n1");
        assertNotSame(n1, n1c);
        assertSame(n1.getNodeData(), n1c.getNodeData());
        assertEquals(((AbstractNode) n1c).getViewId(), newView.getViewId());
        assertSame(n1c, graphNewView.getNode(n1.getId()));

        graphNewView.removeNode(n1c);
        assertNull(graphNewView.getNode("n1"));
        assertNotNull(rootGraph.getNode("n1"));
View Full Code Here

        rootGraph.addNode(n1);
        rootGraph.addNode(n2);
        Edge e1 = factory.newEdge("e1", n1, n2, 1f, false);
        rootGraph.addEdge(e1);

        GraphView newView = graphModel.newView();
        Graph graphNewView = graphModel.getGraph(newView);
        assertNotNull(graphNewView.getEdge(e1.getId()));
        assertNotNull(graphNewView.getEdge(e1.getEdgeData().getId()));
        assertSame(e1, graphNewView.getEdge(e1.getId()));
View Full Code Here

        public Graph filter(Graph[] graphs) {
            if (graphs.length > 1) {
                throw new IllegalArgumentException("Not Filter accepts a single graph in parameter");
            }
            HierarchicalGraph hgraph = (HierarchicalGraph) graphs[0];
            GraphView hgraphView = hgraph.getView();
            HierarchicalGraph mainHGraph = hgraph.getView().getGraphModel().getHierarchicalGraph();
            for (Node n : mainHGraph.getNodes().toArray()) {
                if (n.getNodeData().getNode(hgraphView.getViewId()) == null) {
                    //The node n is not in graph
                    hgraph.addNode(n);
                } else {
                    //The node n is in graph
                    hgraph.removeNode(n);
                }
            }

            for (Node n : hgraph.getNodes().toArray()) {
                Node mainNode = n.getNodeData().getNode(mainHGraph.getView().getViewId());
                Edge[] edges = mainHGraph.getEdgesAndMetaEdges(mainNode).toArray();
                for (Edge e : edges) {
                    if (e.getSource().getNodeData().getNode(hgraphView.getViewId()) != null
                            && e.getTarget().getNodeData().getNode(hgraphView.getViewId()) != null) {
                        hgraph.addEdge(e);
                    }
                }
            }
View Full Code Here

        GraphModel graphModel = Lookup.getDefault().lookup(GraphController.class).getModel();
        Graph result = processor.process((AbstractQueryImpl) query, graphModel);
//        System.out.println("#Nodes: " + result.getNodeCount());
//        System.out.println("#Edges: " + result.getEdgeCount());
        if (running) {
            GraphView view = result.getView();
            graphModel.setVisibleView(view);
            if (model.getCurrentResult() != null) {
                graphModel.destroyView(model.getCurrentResult());
            }
            model.setCurrentResult(view);
View Full Code Here

            VisualizationController visController = Lookup.getDefault().lookup(VisualizationController.class);
            if (visController != null) {
                visController.selectNodes(result.getNodes().toArray());
                visController.selectEdges(result.getEdges().toArray());
            }
            GraphView view = result.getView();
            model.setCurrentResult(view);
        } else {
            //destroy view
            graphModel.destroyView(result.getView());
        }
View Full Code Here

    }

    public void exportToColumn(String title, Query query) {
        HierarchicalGraph result;
        if (model.getCurrentQuery() == query) {
            GraphView view = model.getCurrentResult();
            if (view == null) {
                return;
            }
            result = model.getGraphModel().getHierarchicalGraph(view);
        } else {
View Full Code Here

    }

    public void exportToNewWorkspace(Query query) {
        HierarchicalGraph result;
        if (model.getCurrentQuery() == query) {
            GraphView view = model.getCurrentResult();
            if (view == null) {
                return;
            }
            result = model.getGraphModel().getHierarchicalGraph(view);
        } else {
View Full Code Here

    }

    public void exportToLabelVisible(Query query) {
        HierarchicalGraph result;
        if (model.getCurrentQuery() == query) {
            GraphView view = model.getCurrentResult();
            if (view == null) {
                return;
            }
            result = model.getGraphModel().getHierarchicalGraph(view);
        } else {
View Full Code Here

TOP

Related Classes of org.gephi.graph.api.GraphView

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.