Examples of GraphModel


Examples of org.gephi.graph.api.GraphModel

    }

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

        if (model.isDirected()) {
            DirectedGraph directedGraph = model.getDirectedGraphVisible();
            NodeRanking inDegreeRanking = RankingFactory.getNodeInDegreeRanking(directedGraph);
            if (inDegreeRanking.getMinimumValue() != null && inDegreeRanking.getMaximumValue() != null && !inDegreeRanking.getMinimumValue().equals(inDegreeRanking.getMaximumValue())) {
                rankingList.add(inDegreeRanking);
            }
            NodeRanking outDegreeRanking = RankingFactory.getNodeOutDegreeRanking(directedGraph);
            if (outDegreeRanking.getMinimumValue() != null && outDegreeRanking.getMaximumValue() != null && !outDegreeRanking.getMinimumValue().equals(outDegreeRanking.getMaximumValue())) {
                rankingList.add(outDegreeRanking);
            }
        }

        if (model.isHierarchical()) {
            HierarchicalGraph hierarchicalGraph = model.getHierarchicalGraphVisible();
            NodeRanking childrenRanking = RankingFactory.getNodeChildrenCountRanking(hierarchicalGraph);
            if (childrenRanking.getMinimumValue() != null && childrenRanking.getMaximumValue() != null && !childrenRanking.getMinimumValue().equals(childrenRanking.getMaximumValue())) {
                rankingList.add(childrenRanking);
            }
        }
View Full Code Here

Examples of org.gephi.graph.api.GraphModel

        projectController.newProject();
        Workspace workspace = projectController.getCurrentWorkspace();
        AttributeController attributeController = Lookup.getDefault().lookup(AttributeController.class);
        AttributeModel attributeModel = attributeController.getModel();
        GraphController graphController = Lookup.getDefault().lookup(GraphController.class);
        GraphModel graphModel = graphController.getModel();
        HierarchicalDirectedGraph graph = graphModel.getHierarchicalDirectedGraph();

        Node n1 = graphModel.factory().newNode("n1");
        graph.addNode(n1);
        Node n2 = graphModel.factory().newNode("n2");
        graph.addNode(n2);
        Node n3 = graphModel.factory().newNode("n3");
        graph.addNode(n3);
        Node n4 = graphModel.factory().newNode("n4");
        graph.addNode(n4, n3);

        Edge e1 = graphModel.factory().newEdge(n1, n2, 1f, true);
        graph.addEdge(e1);
        Edge e2 = graphModel.factory().newEdge(n2, n4, 3f, true);
        graph.addEdge(e2);
        Edge e3 = graphModel.factory().newEdge(n2, n1, 1f, true);
        graph.addEdge(e3);

        AttributeColumn nodeCol1 = attributeModel.getNodeTable().addColumn("col1", "Column 1", AttributeType.STRING, AttributeOrigin.DATA, "default value col1");
        AttributeColumn nodeCol2 = attributeModel.getNodeTable().addColumn("col2 listint", AttributeType.LIST_INTEGER);
        attributeModel.getNodeTable().addColumn("col3 listchar", AttributeType.LIST_CHARACTER);
View Full Code Here

Examples of org.gephi.graph.api.GraphModel

                if (model == null) {
                    model = new PartitionModelImpl();
                    workspace.add(model);
                }
                refreshPartitions = true;
                GraphModel gm = Lookup.getDefault().lookup(GraphController.class).getModel(workspace);
                trachViewChange(gm);
                AttributeModel attributeModel = Lookup.getDefault().lookup(AttributeController.class).getModel(workspace);
                attributeModel.addAttributeListener(PartitionControllerImpl.this);
            }

            public void unselect(Workspace workspace) {
                GraphModel gm = Lookup.getDefault().lookup(GraphController.class).getModel(workspace);
                untrackViewChange(gm);
                model = null;
                AttributeModel attributeModel = workspace.getLookup().lookup(AttributeModel.class);
                attributeModel.removeAttributeListener(PartitionControllerImpl.this);
            }

            public void close(Workspace workspace) {
            }

            public void disable() {
                untrackViewChange(null);
            }
        });
        if (pc.getCurrentWorkspace() != null) {
            refreshPartitions = true;
            model = pc.getCurrentWorkspace().getLookup().lookup(PartitionModelImpl.class);
            if (model == null) {
                model = new PartitionModelImpl();
                Workspace workspace = pc.getCurrentWorkspace();
                pc.getCurrentWorkspace().add(model);
                GraphModel gm = Lookup.getDefault().lookup(GraphController.class).getModel(workspace);
                trachViewChange(gm);

                AttributeModel attributeModel = Lookup.getDefault().lookup(AttributeController.class).getModel(workspace);
                attributeModel.addAttributeListener(PartitionControllerImpl.this);
            }
View Full Code Here

Examples of org.gephi.graph.api.GraphModel

        if (model.getSelectedPartitioning() == PartitionModel.NODE_PARTITIONING) {
            Thread t = new Thread(new Runnable() {

                public void run() {
                    if (partition != null) {
                        GraphModel graphModel = Lookup.getDefault().lookup(GraphController.class).getModel();

                        DynamicModel dynamicModel = model.getDynamicModel();
                        TimeInterval timeInterval = dynamicModel != null ? dynamicModel.getVisibleInterval() : null;
                        Estimator estimator = AttributeUtils.getDefault().isDynamicNumberColumn(partition.getColumn()) ? model.getNumberEstimator() : model.getEstimator();
                        PartitionFactory.buildNodePartition((NodePartition) partition, graphModel.getGraphVisible(), timeInterval, estimator);
                    }
                    model.setNodePartition(partition);
                    if (model.getNodeTransformerBuilder() == null) {
                        //Select the first transformer
                        TransformerBuilder[] builders = Lookup.getDefault().lookupAll(TransformerBuilder.class).toArray(new TransformerBuilder[0]);
                        for (int i = 0; i < builders.length; i++) {
                            TransformerBuilder t = builders[i];
                            if (t instanceof TransformerBuilder.Node) {
                                model.setNodeBuilder(t);
                                break;
                            }
                        }
                    }
                    model.setWaiting(false);
                }
            }, "Partition Model refresh");
            t.start();
        } else {
            Thread t = new Thread(new Runnable() {

                public void run() {
                    if (partition != null) {
                        GraphModel graphModel = Lookup.getDefault().lookup(GraphController.class).getModel();

                        DynamicModel dynamicModel = model.getDynamicModel();
                        TimeInterval timeInterval = dynamicModel != null ? dynamicModel.getVisibleInterval() : null;
                        Estimator estimator = AttributeUtils.getDefault().isDynamicNumberColumn(partition.getColumn()) ? model.getNumberEstimator() : model.getEstimator();
                        PartitionFactory.buildEdgePartition((EdgePartition) partition, graphModel.getGraphVisible(), timeInterval, estimator);
                    }
                    model.setEdgePartition(partition);
                    if (model.getEdgeTransformerBuilder() == null) {
                        //Select the first transformer
                        TransformerBuilder[] builders = Lookup.getDefault().lookupAll(TransformerBuilder.class).toArray(new TransformerBuilder[0]);
View Full Code Here

Examples of org.gephi.graph.api.GraphModel

    public void refreshPartitions() {
        if (refreshPartitions) {
            refreshPartitions = false;
            AttributeController ac = Lookup.getDefault().lookup(AttributeController.class);
            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

Examples of org.gephi.graph.api.GraphModel

    public boolean isGroupable(Partition partition) {
        if (partition instanceof NodePartition) {
            if (partition.getPartsCount() > 0) {
                NodePartition nodePartition = (NodePartition) partition;
                Node n0 = nodePartition.getParts()[0].getObjects()[0];
                GraphModel graphModel = Lookup.getDefault().lookup(GraphController.class).getModel();
                HierarchicalGraph graph = graphModel.getHierarchicalGraphVisible();
                if (graph.contains(n0) && graph.getParent(n0) == null) {
                    return true;
                }
            }
        }
View Full Code Here

Examples of org.gephi.graph.api.GraphModel

    public boolean isUngroupable(Partition partition) {
        if (partition instanceof NodePartition) {
            if (partition.getPartsCount() > 0) {
                NodePartition nodePartition = (NodePartition) partition;
                Node n0 = nodePartition.getParts()[0].getObjects()[0];
                GraphModel graphModel = Lookup.getDefault().lookup(GraphController.class).getModel();
                HierarchicalGraph graph = graphModel.getHierarchicalGraphVisible();
                if (graph.contains(n0) && graph.getParent(n0) != null) {
                    return true;
                }
            }
        }
View Full Code Here

Examples of org.gephi.graph.api.GraphModel

        return false;
    }

    public void group(Partition partition) {
        NodePartition nodePartition = (NodePartition) partition;
        GraphModel graphModel = Lookup.getDefault().lookup(GraphController.class).getModel();
        HierarchicalGraph graph = graphModel.getHierarchicalGraphVisible();
        for (Part<Node> p : nodePartition.getParts()) {
            Node[] nodes = p.getObjects();
            List<Node> validNodes = new ArrayList<Node>();
            for (Node n : nodes) {
                if (graph.contains(n)) {
View Full Code Here

Examples of org.gephi.graph.api.GraphModel

        }
    }

    public void ungroup(Partition partition) {
        NodePartition nodePartition = (NodePartition) partition;
        GraphModel graphModel = Lookup.getDefault().lookup(GraphController.class).getModel();
        HierarchicalGraph graph = graphModel.getHierarchicalGraphVisible();
        for (Part<Node> p : nodePartition.getParts()) {
            Node[] nodes = p.getObjects();
            List<Node> validNodes = new ArrayList<Node>();
            for (Node n : nodes) {
                if (graph.contains(n)) {
View Full Code Here

Examples of org.gephi.graph.api.GraphModel

            public void initialize(Workspace workspace) {
            }

            public void select(Workspace workspace) {
                GraphController gc = Lookup.getDefault().lookup(GraphController.class);
                GraphModel gm = gc.getModel();
                contextPanel.refreshModel(gm);
            }

            public void unselect(Workspace workspace) {
            }

            public void close(Workspace workspace) {
            }

            public void disable() {
                contextPanel.refreshModel(null);
            }
        });
        if (pc.getCurrentWorkspace() != null) {
            GraphModel gm = pc.getCurrentWorkspace().getLookup().lookup(GraphModel.class);
            contextPanel.refreshModel(gm);
        }
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.