Search in sources :

Example 1 with ProgressTicket

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;
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
Also used : ProgressTicket(org.gephi.utils.progress.ProgressTicket)

Example 2 with ProgressTicket

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);
    }
}
Also used : ProgressTicketProvider(org.gephi.utils.progress.ProgressTicketProvider) Query(org.gephi.filters.api.Query) ProgressTicket(org.gephi.utils.progress.ProgressTicket)

Example 3 with ProgressTicket

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

ProgressTicket (org.gephi.utils.progress.ProgressTicket)3 ProgressTicketProvider (org.gephi.utils.progress.ProgressTicketProvider)2 Query (org.gephi.filters.api.Query)1 Graph (org.gephi.graph.api.Graph)1 GraphController (org.gephi.graph.api.GraphController)1 GraphModel (org.gephi.graph.api.GraphModel)1 GraphView (org.gephi.graph.api.GraphView)1 ProjectController (org.gephi.project.api.ProjectController)1 Workspace (org.gephi.project.api.Workspace)1 WorkspaceInformation (org.gephi.project.api.WorkspaceInformation)1