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