Search in sources :

Example 56 with Graph

use of org.gephi.graph.api.Graph in project gephi by gephi.

the class IntraEdgesBuilder method getBuilders.

@Override
public FilterBuilder[] getBuilders(Workspace workspace) {
    List<FilterBuilder> builders = new ArrayList<>();
    GraphModel gm = Lookup.getDefault().lookup(GraphController.class).getGraphModel(workspace);
    Graph graph = gm.getGraph();
    AppearanceModel am = Lookup.getDefault().lookup(AppearanceController.class).getModel(workspace);
    //Force refresh
    am.getNodeFunctions(graph);
    for (Column nodeCol : gm.getNodeTable()) {
        if (!nodeCol.isProperty()) {
            if (am.getNodePartition(graph, nodeCol) != null) {
                IntraEdgesFilterBuilder builder = new IntraEdgesFilterBuilder(nodeCol, am);
                builders.add(builder);
            }
        }
    }
    return builders.toArray(new FilterBuilder[0]);
}
Also used : Graph(org.gephi.graph.api.Graph) AppearanceModel(org.gephi.appearance.api.AppearanceModel) Column(org.gephi.graph.api.Column) FilterBuilder(org.gephi.filters.spi.FilterBuilder) GraphModel(org.gephi.graph.api.GraphModel) ArrayList(java.util.ArrayList) AppearanceController(org.gephi.appearance.api.AppearanceController) GraphController(org.gephi.graph.api.GraphController)

Example 57 with Graph

use of org.gephi.graph.api.Graph in project gephi by gephi.

the class PartitionBuilder method getBuilders.

@Override
public FilterBuilder[] getBuilders(Workspace workspace) {
    List<FilterBuilder> builders = new ArrayList<>();
    GraphModel gm = Lookup.getDefault().lookup(GraphController.class).getGraphModel(workspace);
    Graph graph = gm.getGraph();
    AppearanceModel am = Lookup.getDefault().lookup(AppearanceController.class).getModel(workspace);
    //Force refresh
    am.getNodeFunctions(graph);
    for (Column nodeCol : gm.getNodeTable()) {
        if (!nodeCol.isProperty()) {
            if (am.getNodePartition(graph, nodeCol) != null) {
                PartitionFilterBuilder builder = new PartitionFilterBuilder(nodeCol, am);
                builders.add(builder);
            }
        }
    }
    for (Column edgeCol : gm.getEdgeTable()) {
        if (!edgeCol.isProperty()) {
            if (am.getEdgePartition(graph, edgeCol) != null) {
                PartitionFilterBuilder builder = new PartitionFilterBuilder(edgeCol, am);
                builders.add(builder);
            }
        }
    }
    return builders.toArray(new FilterBuilder[0]);
}
Also used : Graph(org.gephi.graph.api.Graph) AppearanceModel(org.gephi.appearance.api.AppearanceModel) Column(org.gephi.graph.api.Column) FilterBuilder(org.gephi.filters.spi.FilterBuilder) GraphModel(org.gephi.graph.api.GraphModel) ArrayList(java.util.ArrayList) AppearanceController(org.gephi.appearance.api.AppearanceController) GraphController(org.gephi.graph.api.GraphController)

Example 58 with Graph

use of org.gephi.graph.api.Graph in project gephi by gephi.

the class FilterThread method filter.

private void filter(AbstractQueryImpl query) {
    FilterProcessor processor = new FilterProcessor();
    GraphModel graphModel = model.getGraphModel();
    Graph result = processor.process((AbstractQueryImpl) query, graphModel);
    if (running) {
        GraphView view = result.getView();
        graphModel.setVisibleView(view);
        if (model.getCurrentResult() != null) {
            graphModel.destroyView(model.getCurrentResult());
        }
        model.setCurrentResult(view);
    } else {
        //destroy view
        graphModel.destroyView(result.getView());
    }
}
Also used : Graph(org.gephi.graph.api.Graph) GraphModel(org.gephi.graph.api.GraphModel) GraphView(org.gephi.graph.api.GraphView)

Example 59 with Graph

use of org.gephi.graph.api.Graph in project gephi by gephi.

the class FilterControllerImpl method exportToColumn.

@Override
public void exportToColumn(String title, Query query) {
    Graph result;
    if (model.getCurrentQuery() == query) {
        GraphView view = model.getCurrentResult();
        if (view == null) {
            return;
        }
        result = model.getGraphModel().getGraph(view);
    } else {
        FilterProcessor processor = new FilterProcessor();
        GraphModel graphModel = model.getGraphModel();
        result = (Graph) processor.process((AbstractQueryImpl) query, graphModel);
    }
    Column nodeCol = result.getModel().getNodeTable().getColumn("filter_" + title);
    if (nodeCol == null) {
        nodeCol = result.getModel().getNodeTable().addColumn("filter_" + title, title, Boolean.class, Origin.DATA, Boolean.FALSE, false);
    }
    Column edgeCol = result.getModel().getEdgeTable().getColumn("filter_" + title);
    if (edgeCol == null) {
        edgeCol = result.getModel().getEdgeTable().addColumn("filter_" + title, title, Boolean.class, Origin.DATA, Boolean.FALSE, false);
    }
    result.writeLock();
    try {
        for (Node n : result.getNodes()) {
            n.setAttribute(nodeCol, Boolean.TRUE);
        }
        for (Edge e : result.getEdges()) {
            e.setAttribute(edgeCol, Boolean.TRUE);
        }
    } finally {
        result.readUnlockAll();
        result.writeUnlock();
    }
//StatusDisplayer.getDefault().setStatusText(NbBundle.getMessage(FilterControllerImpl.class, "FilterController.exportToColumn.status", title));
}
Also used : Graph(org.gephi.graph.api.Graph) Column(org.gephi.graph.api.Column) GraphModel(org.gephi.graph.api.GraphModel) Node(org.gephi.graph.api.Node) GraphView(org.gephi.graph.api.GraphView) Edge(org.gephi.graph.api.Edge)

Example 60 with Graph

use of org.gephi.graph.api.Graph in project gephi by gephi.

the class FilterControllerImpl method exportToNewWorkspace.

@Override
public void exportToNewWorkspace(Query query) {
    Graph result;
    if (model.getCurrentQuery() == query) {
        GraphView view = model.getCurrentResult();
        if (view == null) {
            return;
        }
        result = model.getGraphModel().getGraph(view);
    } else {
        FilterProcessor processor = new FilterProcessor();
        GraphModel graphModel = model.getGraphModel();
        result = (Graph) processor.process((AbstractQueryImpl) query, graphModel);
    }
    final Graph graphView = result;
    new Thread(new Runnable() {

        @Override
        public void run() {
            ProgressTicketProvider progressProvider = Lookup.getDefault().lookup(ProgressTicketProvider.class);
            ProgressTicket ticket = null;
            if (progressProvider != null) {
                String msg = NbBundle.getMessage(FilterControllerImpl.class, "FilterController.exportToNewWorkspace.task");
                ticket = progressProvider.createTicket(msg, null);
            }
            Progress.start(ticket);
            ProjectController pc = Lookup.getDefault().lookup(ProjectController.class);
            Workspace newWorkspace = pc.newWorkspace(pc.getCurrentProject());
            GraphModel graphModel = Lookup.getDefault().lookup(GraphController.class).getGraphModel(newWorkspace);
            graphModel.bridge().copyNodes(graphView.getNodes().toArray());
            Progress.finish(ticket);
            String workspaceName = newWorkspace.getLookup().lookup(WorkspaceInformation.class).getName();
        //StatusDisplayer.getDefault().setStatusText(NbBundle.getMessage(FilterControllerImpl.class, "FilterController.exportToNewWorkspace.status", workspaceName));
        }
    }, "Export filter to workspace").start();
}
Also used : GraphView(org.gephi.graph.api.GraphView) ProjectController(org.gephi.project.api.ProjectController) WorkspaceInformation(org.gephi.project.api.WorkspaceInformation) ProgressTicketProvider(org.gephi.utils.progress.ProgressTicketProvider) Graph(org.gephi.graph.api.Graph) GraphModel(org.gephi.graph.api.GraphModel) ProgressTicket(org.gephi.utils.progress.ProgressTicket) GraphController(org.gephi.graph.api.GraphController) Workspace(org.gephi.project.api.Workspace)

Aggregations

Graph (org.gephi.graph.api.Graph)104 GraphModel (org.gephi.graph.api.GraphModel)57 Node (org.gephi.graph.api.Node)50 DirectedGraph (org.gephi.graph.api.DirectedGraph)43 Test (org.testng.annotations.Test)36 GraphController (org.gephi.graph.api.GraphController)27 UndirectedGraph (org.gephi.graph.api.UndirectedGraph)24 Edge (org.gephi.graph.api.Edge)21 Column (org.gephi.graph.api.Column)9 ArrayList (java.util.ArrayList)8 Function (org.gephi.appearance.api.Function)6 GraphView (org.gephi.graph.api.GraphView)6 AttributeFunction (org.gephi.appearance.api.AttributeFunction)5 AppearanceController (org.gephi.appearance.api.AppearanceController)4 AppearanceModel (org.gephi.appearance.api.AppearanceModel)4 IOException (java.io.IOException)3 HashMap (java.util.HashMap)3 TransformerUI (org.gephi.appearance.spi.TransformerUI)3 GraphElementsController (org.gephi.datalab.api.GraphElementsController)3 DataTablesController (org.gephi.datalab.api.datatables.DataTablesController)3