use of org.gephi.utils.progress.ProgressTicket in project gephi by gephi.
the class PreviewControllerImpl method render.
private synchronized void render(RenderTarget target, Renderer[] renderers, PreviewModelImpl previewModel) {
if (previewModel != null) {
PreviewProperties properties = previewModel.getProperties();
//Progress
ProgressTicket progressTicket = null;
if (target instanceof AbstractRenderTarget) {
int tasks = 0;
for (Renderer r : renderers) {
if (!mousePressed || r instanceof MouseResponsiveRenderer) {
for (String type : previewModel.getItemTypes()) {
for (Item item : previewModel.getItems(type)) {
if (r.isRendererForitem(item, properties)) {
tasks++;
}
}
}
}
}
progressTicket = ((AbstractRenderTarget) target).getProgressTicket();
Progress.switchToDeterminate(progressTicket, tasks);
}
//Render items
for (Renderer r : renderers) {
if (!mousePressed || r instanceof MouseResponsiveRenderer) {
for (String type : previewModel.getItemTypes()) {
for (Item item : previewModel.getItems(type)) {
if (r.isRendererForitem(item, properties)) {
r.render(item, target, properties);
Progress.progress(progressTicket);
if (target instanceof AbstractRenderTarget) {
if (((AbstractRenderTarget) target).isCancelled()) {
return;
}
}
}
}
}
}
}
}
}
use of org.gephi.utils.progress.ProgressTicket 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.ProgressTicket 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