Search in sources :

Example 6 with GraphView

use of org.gephi.graph.api.GraphView 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 7 with GraphView

use of org.gephi.graph.api.GraphView 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

GraphView (org.gephi.graph.api.GraphView)7 Graph (org.gephi.graph.api.Graph)6 GraphModel (org.gephi.graph.api.GraphModel)6 Edge (org.gephi.graph.api.Edge)3 GraphController (org.gephi.graph.api.GraphController)3 Node (org.gephi.graph.api.Node)3 ItemEvent (java.awt.event.ItemEvent)1 ItemListener (java.awt.event.ItemListener)1 Column (org.gephi.graph.api.Column)1 Interval (org.gephi.graph.api.Interval)1 Subgraph (org.gephi.graph.api.Subgraph)1 TimeFormat (org.gephi.graph.api.TimeFormat)1 ProjectController (org.gephi.project.api.ProjectController)1 Workspace (org.gephi.project.api.Workspace)1 WorkspaceInformation (org.gephi.project.api.WorkspaceInformation)1 ProgressTicket (org.gephi.utils.progress.ProgressTicket)1 ProgressTicketProvider (org.gephi.utils.progress.ProgressTicketProvider)1 VisualizationController (org.gephi.visualization.api.VisualizationController)1