Package org.gephi.graph.api

Examples of org.gephi.graph.api.GraphFactory


        assertNull(rootGraph.getNode("n1"));
    }

    @Test
    public void testViewEdges() {
        GraphFactory factory = graphModel.factory();
        Node n1 = factory.newNode("n1");
        Node n2 = factory.newNode("n2");
        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()));
View Full Code Here


                        @Override
                        public void mouseClick(int[] positionViewport, float[] position3d) {
                            //Get current graph
                            GraphController gc = Lookup.getDefault().lookup(GraphController.class);
                            Graph graph = gc.getModel().getGraph();
                            GraphFactory factory = gc.getModel().factory();

                            //Add node
                            Node node = factory.newNode();
                            node.getNodeData().setX(position3d[0]);
                            node.getNodeData().setY(position3d[1]);
                            node.getNodeData().setSize(10f);
                            graph.addNode(node);
                        }
                    },
                    new NodeClickEventListener() {

                        @Override
                        public void clickNodes(Node[] nodes) {
                            //Get mouse position
                            float[] position3d = VizController.getInstance().getGraphIO().getMousePosition3d();

                            //Get current graph
                            GraphController gc = Lookup.getDefault().lookup(GraphController.class);
                            Graph graph = gc.getModel().getGraph();
                            GraphFactory factory = gc.getModel().factory();

                            //Add node
                            Node node = factory.newNode();
                            node.getNodeData().setX(position3d[0]);
                            node.getNodeData().setY(position3d[1]);
                            node.getNodeData().setSize(10f);
                            graph.addNode(node);

                            //Add edges with the clicked nodes
                            for (Node n : nodes) {
                                Edge edge = factory.newEdge(node, n);
                                graph.addEdge(edge);
                            }
                        }
                    }};
    }
View Full Code Here

        //Architecture
        GraphController graphController = Lookup.getDefault().lookup(GraphController.class);
        GraphModel graphModel = Lookup.getDefault().lookup(GraphController.class).getGraphModel();

        Graph graph = graphModel.getGraph();;
        GraphFactory factory = graphModel.factory();

        //Attributes - Creates columns for properties
        attributeModel = graphController.getAttributeModel();
        flushColumns();

        //Dynamic
//        if (container.getTimeFormat() != null) {
//            DynamicController dynamicController = Lookup.getDefault().lookup(DynamicController.class);
//            if (dynamicController != null) {
//                dynamicController.setTimeFormat(container.getTimeFormat());
//            }
//        }

        int nodeCount = 0;
        //Create all nodes
        for (NodeDraft draftNode : container.getNodes()) {
            String id = draftNode.getId();
            Node node = factory.newNode(id);
            graph.addNode(node);
            nodeCount++;
            flushToNode(draftNode, node);
        }

        //Create all edges and push to data structure
        int edgeCount = 0;
        for (EdgeDraft draftEdge : container.getEdges()) {
            String id = draftEdge.getId();
            String sourceId = draftEdge.getSource().getId();
            String targetId = draftEdge.getTarget().getId();
            Node source = graph.getNode(sourceId);
            Node target = graph.getNode(targetId);
            Object type = draftEdge.getType();
            int edgeType = graphModel.addEdgeType(type);

            Edge edge = graph.getEdge(source, target, edgeType);
            switch (container.getEdgeDefault()) {
                case DIRECTED:
                    edge = factory.newEdge(id, source, target, edgeType, draftEdge.getWeight(), true);
                    break;
                case UNDIRECTED:
                    edge = factory.newEdge(id, source, target, edgeType, draftEdge.getWeight(), false);
                    break;
                case MIXED:
                    boolean directed = draftEdge.getDirection() != null && draftEdge.getDirection().equals(EdgeDirection.UNDIRECTED) ? false : true;
                    edge = factory.newEdge(id, source, target, edgeType, draftEdge.getWeight(), directed);
            }
            edgeCount++;
            graph.addEdge(edge);

            flushToEdge(draftEdge, edge);
View Full Code Here

        //Architecture
        GraphController graphController = Lookup.getDefault().lookup(GraphController.class);
        GraphModel graphModel = Lookup.getDefault().lookup(GraphController.class).getGraphModel();

        Graph graph = graphModel.getGraph();
        GraphFactory factory = graphModel.factory();

        //Attributes - Creates columns for properties
        attributeModel = graphController.getAttributeModel();
        flushColumns();

        //Dynamic
//        if (container.getTimeFormat() != null) {
//            DynamicController dynamicController = Lookup.getDefault().lookup(DynamicController.class);
//            dynamicController.setTimeFormat(container.getTimeFormat());
//        }

        int nodeCount = 0;
        //Create all nodes
        for (NodeDraft draftNode : container.getNodes()) {
            String id = draftNode.getId();
            Node node = graph.getNode(id);
            if (node == null) {
                node = factory.newNode(id);
                graph.addNode(node);
                nodeCount++;
            }
            flushToNode(draftNode, node);
        }

        //Create all edges and push to data structure
        int edgeCount = 0;
        for (EdgeDraft draftEdge : container.getEdges()) {
            String id = draftEdge.getId();
            String sourceId = draftEdge.getSource().getId();
            String targetId = draftEdge.getTarget().getId();
            Node source = graph.getNode(sourceId);
            Node target = graph.getNode(targetId);
            Object type = draftEdge.getType();
            int edgeType = graphModel.addEdgeType(type);

            Edge edge = graph.getEdge(source, target, edgeType);
            if (edge == null) {
                switch (container.getEdgeDefault()) {
                    case DIRECTED:
                        edge = factory.newEdge(id, source, target, edgeType, draftEdge.getWeight(), true);
                        break;
                    case UNDIRECTED:
                        edge = factory.newEdge(id, source, target, edgeType, draftEdge.getWeight(), true);
                        break;
                    case MIXED:
                        boolean directed = draftEdge.getDirection().equals(EdgeDirection.UNDIRECTED) ? false : true;
                        edge = factory.newEdge(id, source, target, edgeType, draftEdge.getWeight(), directed);
                }
                edgeCount++;
                graph.addEdge(edge);
            }
            flushToEdge(draftEdge, edge);
View Full Code Here

TOP

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

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.