Search in sources :

Example 1 with CopyExistingViewTask

use of org.cytoscape.task.internal.view.CopyExistingViewTask in project cytoscape-impl by cytoscape.

the class CloneNetworkTask method run.

public void run(TaskMonitor tm) {
    tm.setProgress(0.0);
    // nogui?
    if (network != null)
        parentNetwork = network;
    if (parentNetwork == null) {
        tm.showMessage(TaskMonitor.Level.ERROR, "No network to clone");
        return;
    }
    // Create copied network model
    final CyNetwork newNet = cloneNetwork(parentNetwork);
    tm.setProgress(0.5);
    final Collection<CyNetworkView> views = networkViewManager.getNetworkViews(parentNetwork);
    // TODO What if the network has more than one view
    final CyNetworkView origView = views.size() != 0 ? views.iterator().next() : null;
    if (origView != null) {
        final VisualStyle style = vmm.getVisualStyle(origView);
        final CyNetworkView newView = netViewFactory.createNetworkView(newNet);
        tm.setProgress(0.6);
        // Let the CopyExistingViewTask respond to the Observer (if any)
        final CopyExistingViewTask copyExistingViewTask = new CopyExistingViewTask(renderingEngineMgr, newView, origView, style, new2OrigNodeMap, new2OrigEdgeMap, false);
        final RegisterNetworkTask registerNetworkTask = new RegisterNetworkTask(newView, style, networkManager, vmm, appMgr, networkViewManager);
        insertTasksAfterCurrentTask(copyExistingViewTask, registerNetworkTask);
    } else {
        final RegisterNetworkTask registerNetworkTask = new RegisterNetworkTask(newNet, networkManager, vmm, appMgr, networkViewManager);
        insertTasksAfterCurrentTask(registerNetworkTask);
        result = nullNetworkViewFactory.createNetworkView(newNet);
    }
    tm.setProgress(1.0);
}
Also used : CopyExistingViewTask(org.cytoscape.task.internal.view.CopyExistingViewTask) CyNetwork(org.cytoscape.model.CyNetwork) VisualStyle(org.cytoscape.view.vizmap.VisualStyle) CyNetworkView(org.cytoscape.view.model.CyNetworkView)

Aggregations

CyNetwork (org.cytoscape.model.CyNetwork)1 CopyExistingViewTask (org.cytoscape.task.internal.view.CopyExistingViewTask)1 CyNetworkView (org.cytoscape.view.model.CyNetworkView)1 VisualStyle (org.cytoscape.view.vizmap.VisualStyle)1