Package org.gephi.graph.api

Examples of org.gephi.graph.api.Graph


        return null;
    }

    public EdgeRanking getEdgeAttributeRanking(AttributeColumn column) {
        GraphModel model = Lookup.getDefault().lookup(GraphController.class).getModel();
        Graph graph = model.getGraphVisible();
        if (RankingFactory.isNumberColumn(column)) {
            EdgeRanking r = RankingFactory.getEdgeAttributeRanking(column, graph);
            if (r.getMinimumValue() != null && r.getMaximumValue() != null && !r.getMinimumValue().equals(r.getMaximumValue())) {
                return r;
            }
View Full Code Here


    public NodeRanking[] getNodeRanking() {
        AttributeController attributeController = Lookup.getDefault().lookup(AttributeController.class);
        List<Ranking> rankingList = new ArrayList<Ranking>();
        GraphModel model = Lookup.getDefault().lookup(GraphController.class).getModel();
        Graph graph = model.getGraphVisible();

        //Topology
        NodeRanking degreeRanking = RankingFactory.getNodeDegreeRanking(graph);
        if (degreeRanking.getMinimumValue() != null && degreeRanking.getMaximumValue() != null && !degreeRanking.getMinimumValue().equals(degreeRanking.getMaximumValue())) {
            rankingList.add(degreeRanking);
View Full Code Here

        return rankingArray;
    }

    public EdgeRanking[] getEdgeRanking() {
        AttributeController attributeController = Lookup.getDefault().lookup(AttributeController.class);
        Graph graph = Lookup.getDefault().lookup(GraphController.class).getModel().getGraphVisible();
        List<Ranking> rankingList = new ArrayList<Ranking>();
        for (AttributeColumn column : attributeController.getModel().getEdgeTable().getColumns()) {
            if (RankingFactory.isNumberColumn(column)) {
                EdgeRanking r = RankingFactory.getEdgeAttributeRanking(column, graph);
                if (r.getMinimumValue() != null && r.getMaximumValue() != null && !r.getMinimumValue().equals(r.getMaximumValue())) {
View Full Code Here

    public void duplicateNodes(Dhns destination, Node[] nodes) {
        Map<AbstractNode, AbstractNode> nodeMap = new HashMap<AbstractNode, AbstractNode>();

        GraphFactoryImpl factory = destination.factory();
        Graph destGraph = null;
        if (dhns.isDirected()) {
            destGraph = destination.getDirectedGraph();
        } else if (dhns.isUndirected()) {
            destGraph = destination.getUndirectedGraph();
        } else {
            destGraph = destination.getMixedGraph();
        }
        dhns.readLock();
        destination.writeLock();

        //Nodes
        for (Node sourceNode : nodes) {
            AbstractNode absSourceNode = (AbstractNode) sourceNode;
            AbstractNode nodeCopy = factory.newNode(sourceNode.getNodeData().getId());
            destGraph.addNode(nodeCopy);
            duplicateNodeData((NodeDataImpl) sourceNode.getNodeData(), (NodeDataImpl) nodeCopy.getNodeData());
            nodeMap.put(absSourceNode, nodeCopy);
        }

        //Edges
        ParamAVLIterator<AbstractEdge> edgeIterator = new ParamAVLIterator<AbstractEdge>();
        for (Node sourceNode : nodes) {
            AbstractNode absSourceNode = (AbstractNode) sourceNode;
            AbstractNode nodeCopy = nodeMap.get(absSourceNode);
            int sourceView = absSourceNode.getViewId();
            if (!absSourceNode.getEdgesOutTree().isEmpty()) {
                for (edgeIterator.setNode(absSourceNode.getEdgesOutTree()); edgeIterator.hasNext();) {
                    AbstractEdge edge = edgeIterator.next();
                    AbstractNode originalTargetNode = edge.getTarget(sourceView);
                    AbstractNode copyTargetNode = nodeMap.get(originalTargetNode);
                    if (copyTargetNode != null) {
                        AbstractEdge edgeCopy = factory.newEdge(edge.getEdgeData().getId(), nodeCopy, copyTargetNode, edge.getWeight(), edge.isDirected());
                        destGraph.addEdge(edgeCopy);
                        duplicateEdgeData(edge.getEdgeData(), edgeCopy.getEdgeData());
                    }
                }
            }
            if (!absSourceNode.getMetaEdgesOutTree().isEmpty()) {
                for (edgeIterator.setNode(absSourceNode.getMetaEdgesOutTree()); edgeIterator.hasNext();) {
                    AbstractEdge edge = edgeIterator.next();
                    AbstractNode originalTargetNode = edge.getTarget(sourceView);
                    AbstractNode copyTargetNode = nodeMap.get(originalTargetNode);
                    if (copyTargetNode != null) {
                        AbstractEdge edgeCopy = factory.newEdge(edge.getEdgeData().getId(), nodeCopy, copyTargetNode, edge.getWeight(), edge.isDirected());
                        destGraph.addEdge(edgeCopy);
                        duplicateEdgeData(edge.getEdgeData(), edgeCopy.getEdgeData());
                    }
                }
            }
        }
View Full Code Here

        resetColorButton.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent evt) {
                color = resetColorButton.getColor();
                GraphController gc = Lookup.getDefault().lookup(GraphController.class);
                Graph graph = gc.getModel().getGraphVisible();
                for (Node n : graph.getNodes().toArray()) {
                    n.getNodeData().setR(color.getRed() / 255f);
                    n.getNodeData().setG(color.getGreen() / 255f);
                    n.getNodeData().setB(color.getBlue() / 255f);
                    n.getNodeData().setAlpha(1f);
                }
                for (Edge e : graph.getEdges().toArray()) {
                    e.getEdgeData().setR(-1f);
                    e.getEdgeData().setG(color.getGreen() / 255f);
                    e.getEdgeData().setB(color.getBlue() / 255f);
                    e.getEdgeData().setAlpha(1f);
                }
            }
        });
        add(resetColorButton);

        //Reset sizes
        final JButton resetSizeButton = new JButton();
        resetSizeButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/gephi/visualization/component/resetSize.png")));
        resetSizeButton.setToolTipText(NbBundle.getMessage(ActionsToolbar.class, "ActionsToolbar.resetSizes"));
        resetSizeButton.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent e) {
                GraphController gc = Lookup.getDefault().lookup(GraphController.class);
                Graph graph = gc.getModel().getGraphVisible();
                for (Node n : graph.getNodes().toArray()) {
                    n.getNodeData().setSize(size);
                }
            }
        });
        resetSizeButton.addMouseListener(new MouseAdapter() {

            @Override
            public void mouseClicked(MouseEvent e) {

                if (SwingUtilities.isRightMouseButton(e)) {
                    Object res = JOptionPane.showInputDialog(resetSizeButton, NbBundle.getMessage(ActionsToolbar.class, "ActionsToolbar.resetSizes.dialog"), "" + size);
                    if (res != null) {
                        try {
                            size = Float.parseFloat((String) res);
                        } catch (Exception ex) {
                        }
                    }
                }
            }
        });
        add(resetSizeButton);

        //Reset label colors
        final JButton resetLabelColorButton = new JButton();
        resetLabelColorButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/gephi/visualization/component/resetLabelColor.png")));
        resetLabelColorButton.setToolTipText(NbBundle.getMessage(ActionsToolbar.class, "ActionsToolbar.resetLabelColors"));
        resetLabelColorButton.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent evt) {
                GraphController gc = Lookup.getDefault().lookup(GraphController.class);
                Graph graph = gc.getModel().getGraphVisible();
                for (Node n : graph.getNodes().toArray()) {
                    n.getNodeData().getTextData().setColor(null);
                }
                for (Edge e : graph.getEdges().toArray()) {
                    e.getEdgeData().getTextData().setColor(null);
                }
            }
        });
        add(resetLabelColorButton);

        //Reset label colors
        final JButton resetLabelVisibleButton = new JButton();
        resetLabelVisibleButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/gephi/visualization/component/resetLabelVisible.png")));
        resetLabelVisibleButton.setToolTipText(NbBundle.getMessage(ActionsToolbar.class, "ActionsToolbar.resetLabelVisible"));
        resetLabelVisibleButton.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent evt) {
                GraphController gc = Lookup.getDefault().lookup(GraphController.class);
                Graph graph = gc.getModel().getGraphVisible();
                for (Node n : graph.getNodes().toArray()) {
                    n.getNodeData().getTextData().setVisible(true);
                }
                for (Edge e : graph.getEdges().toArray()) {
                    e.getEdgeData().getTextData().setVisible(true);
                }
            }
        });
        add(resetLabelVisibleButton);

        //Reset label size
        JButton resetLabelSizeButton = new JButton();
        resetLabelSizeButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/gephi/visualization/component/resetLabelSize.png")));
        resetLabelSizeButton.setToolTipText(NbBundle.getMessage(ActionsToolbar.class, "ActionsToolbar.resetLabelSizes"));
        resetLabelSizeButton.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent e) {
                GraphController gc = Lookup.getDefault().lookup(GraphController.class);
                Graph graph = gc.getModel().getGraphVisible();
                for (Node n : graph.getNodes().toArray()) {
                    n.getNodeData().getTextData().setSize(1f);
                }
            }
        });
        add(resetLabelSizeButton);
View Full Code Here

            GraphModel graphModel = Lookup.getDefault().lookup(GraphController.class).getModel();

            //Nodes
            List<NodePartition> nodePartitions = new ArrayList<NodePartition>();
            AttributeTable nodeTable = ac.getModel().getNodeTable();
            Graph graph = graphModel.getGraphVisible();
            for (AttributeColumn column : nodeTable.getColumns()) {
                if (PartitionFactory.isPartitionColumn(column) && PartitionFactory.isNodePartitionColumn(column, graph)) {
                    nodePartitions.add(PartitionFactory.createNodePartition(column));
                } else if (PartitionFactory.isDynamicPartitionColumn(column)) {
                    DynamicModel dynamicModel = model.getDynamicModel();
View Full Code Here

        pj.newProject();
        AttributeController ac = Lookup.getDefault().lookup(AttributeController.class);
        ac.getModel();
        GraphController gc = Lookup.getDefault().lookup(GraphController.class);
        graphModel = gc.getModel();
        Graph graph = gc.getModel().getUndirectedGraph();
        rootGraph = graph;
    }
View Full Code Here

        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"));

        rootGraph.removeNode(n1);
        assertNull(rootGraph.getNode("n1"));
    }
View Full Code Here

        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()));

        graphNewView.removeEdge(graphNewView.getEdge(e1.getId()));
        assertSame(e1, rootGraph.getEdge(e1.getId()));

        newView = graphModel.newView();
        assertNotNull(rootGraph.getEdge(e1.getId()));
        ((Dhns) graphModel).destroyView(newView);
        try {
            Thread.sleep(1000);
        } catch (InterruptedException ex) {
            Exceptions.printStackTrace(ex);
        }
        rootGraph.removeEdge(e1);
        assertNull(rootGraph.getEdge(e1.getId()));

        rootGraph.addEdge(e1);
        newView = graphModel.newView();
        graphNewView = graphModel.getGraph(newView);
        Logger.getLogger("").info("clearedges");
        graphNewView.clearEdges();
        graphNewView = null;
        ((Dhns) graphModel).destroyView(newView);
        try {
            Thread.sleep(2000);
        } catch (InterruptedException ex) {
View Full Code Here

    private TimeInterval visibleInterval;

    public boolean execute() {
        AttributeModel attributeModel = workspace.getLookup().lookup(AttributeModel.class);
        GraphModel graphModel = workspace.getLookup().lookup(GraphModel.class);
        Graph graph = null;
        if (exportVisible) {
            graph = graphModel.getGraphVisible();
        } else {
            graph = graphModel.getGraph();
        }
View Full Code Here

TOP

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

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.