use of org.gephi.utils.progress.ProgressTicketProvider in project gephi by gephi.
the class FilterThread method run.
@Override
public void run() {
while (running) {
AbstractQueryImpl q;
while ((q = rootQuery.getAndSet(null)) == null && running) {
try {
synchronized (this.lock) {
lock.wait();
}
} catch (InterruptedException ex) {
Exceptions.printStackTrace(ex);
}
}
if (!running) {
return;
}
Query modifiedQuery = null;
for (Iterator<PropertyModifier> itr = modifiersMap.values().iterator(); itr.hasNext(); ) {
PropertyModifier pm = itr.next();
itr.remove();
pm.callback.setValue(pm.value);
modifiedQuery = pm.query;
}
if (modifiedQuery != null) {
model.updateParameters(modifiedQuery);
}
// Progress
ProgressTicket progressTicket = null;
ProgressTicketProvider progressTicketProvider = Lookup.getDefault().lookup(ProgressTicketProvider.class);
if (progressTicketProvider != null) {
String msg = NbBundle.getMessage(FilterThread.class, "FilterThread.progress.taskName", q.getName());
progressTicket = progressTicketProvider.createTicket(msg, null);
Progress.start(progressTicket);
}
if (filtering) {
filter(q);
} else {
select(q);
}
Progress.finish(progressTicket);
/*try {
//System.out.println("filter query " + q.getName());
Thread.sleep(5000);
} catch (InterruptedException ex) {
Exceptions.printStackTrace(ex);
}*/
}
// clear map
Query q = null;
for (PropertyModifier pm : modifiersMap.values()) {
pm.callback.setValue(pm.value);
q = pm.query;
}
modifiersMap.clear();
if (q != null) {
model.updateParameters(q);
}
}
use of org.gephi.utils.progress.ProgressTicketProvider 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());
Graph graph = graphModel.getGraph();
List<Edge> edgesToRemove = new ArrayList<>();
for (Edge edge : graph.getEdges()) {
if (!graphView.hasEdge(edge.getId())) {
edgesToRemove.add(edge);
}
}
if (!edgesToRemove.isEmpty()) {
graph.removeAllEdges(edgesToRemove);
}
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