use of org.cytoscape.model.CyNetwork in project cytoscape-impl by cytoscape.
the class NewEmptyNetworkTask method run.
@Override
public void run(final TaskMonitor tm) {
tm.setProgress(0.0);
final String networkCollectionName = rootNetworkList.getSelectedValue();
if (networkCollectionName == null || networkCollectionName.equalsIgnoreCase(CRERATE_NEW_COLLECTION_STRING)) {
// This is a new network collection, create a root network and a subnetwork, which is a base subnetwork
subNetwork = (CySubNetwork) netFactory.createNetwork();
} else {
// Add a new subNetwork to the given collection
subNetwork = this.name2RootMap.get(networkCollectionName).addSubNetwork();
}
tm.setProgress(0.2);
final String networkName = namingUtil.getSuggestedNetworkTitle(name);
subNetwork.getRow(subNetwork).set(CyNetwork.NAME, networkName);
if (networkCollectionName == null || networkCollectionName.equalsIgnoreCase(CRERATE_NEW_COLLECTION_STRING)) {
// Set the name of new root network
final CyNetwork rootNetwork = subNetwork.getRootNetwork();
rootNetwork.getRow(rootNetwork).set(CyNetwork.NAME, networkName);
}
NetworkViewRenderer nvRenderer = null;
try {
nvRenderer = renderers.getSelectedValue();
} catch (ClassCastException cce) {
tm.showMessage(TaskMonitor.Level.WARN, "Unknown renderer: " + renderers.getSelectedValue() + " using default renderer.");
}
if (nvRenderer == null)
nvRenderer = appMgr.getDefaultNetworkViewRenderer();
final CyNetworkViewFactory netViewFactory = nvRenderer.getNetworkViewFactory();
tm.setProgress(0.4);
view = netViewFactory.createNetworkView(subNetwork);
tm.setProgress(0.6);
netMgr.addNetwork(subNetwork, false);
appMgr.setCurrentNetwork(subNetwork);
tm.setProgress(0.8);
// get the current style before registering the view!
final VisualStyle style = vmMgr.getCurrentVisualStyle();
netViewMgr.addNetworkView(view);
tm.setProgress(0.9);
applyVisualStyle(style);
tm.setProgress(1.0);
}
use of org.cytoscape.model.CyNetwork in project cytoscape-impl by cytoscape.
the class RegisterNetworkTask method run.
@Override
public void run(TaskMonitor tm) throws Exception {
tm.setProgress(0.0);
for (CyNetwork network : networks) {
if (!networkManager.networkExists(network.getSUID()))
networkManager.addNetwork(network, false);
}
tm.setProgress(0.1);
if (views != null) {
for (CyNetworkView view : views) {
if (view != null) {
networkViewManager.addNetworkView(view, false);
tm.setProgress(0.2);
if (style != null) {
vmm.setVisualStyle(style, view);
tm.setProgress(0.8);
}
view.updateView();
}
}
}
if (views != null) {
appMgr.setCurrentNetworkView(views.get(0));
appMgr.setSelectedNetworkViews(views);
tm.setProgress(0.9);
} else {
appMgr.setCurrentNetwork(networks.get(0));
}
tm.setProgress(1.0);
}
use of org.cytoscape.model.CyNetwork in project cytoscape-impl by cytoscape.
the class ExportSelectedNetworkTaskFactoryImpl method createTaskIterator.
@Override
public TaskIterator createTaskIterator() {
final CyApplicationManager applicationManager = serviceRegistrar.getService(CyApplicationManager.class);
CyNetworkView view = applicationManager.getCurrentNetworkView();
if (view != null)
return getExportNetworkViewTaskFactory().createTaskIterator(view);
CyNetwork network = applicationManager.getCurrentNetwork();
if (network != null)
return getExportNetworkTaskFactory().createTaskIterator(network);
return null;
}
use of org.cytoscape.model.CyNetwork in project cytoscape-impl by cytoscape.
the class ExportAsWebArchiveTaskFactory method createTaskIterator.
@Override
public TaskIterator createTaskIterator() {
final Set<CyNetwork> networks = networkManager.getNetworkSet();
boolean showWarning = false;
for (final CyNetwork network : networks) {
final int nodeCount = network.getNodeCount();
final int edgeCount = network.getEdgeCount();
if (nodeCount > TH || edgeCount > TH) {
showWarning = true;
break;
}
}
final ExportAsWebArchiveTask exportTask = new ExportAsWebArchiveTask(fullWriterFactory, simpleWriterFactory, zippedWriterFactory, applicationManager, sessionManager);
if (showWarning) {
return new TaskIterator(new ShowWarningTask(exportTask));
} else {
return new TaskIterator(exportTask);
}
}
use of org.cytoscape.model.CyNetwork in project cytoscape-impl by cytoscape.
the class AbstractPropertyTask method getPropertyValue.
public Object getPropertyValue(CyNetwork network, CyIdentifiable target, VisualProperty vp) {
CyNetworkView networkView = getViewForNetwork(network);
Class<? extends CyIdentifiable> vpTargetType = vp.getTargetDataType();
if (target instanceof CyNetwork) {
if (vpTargetType != CyNetwork.class)
throw new RuntimeException("Property '" + vp.getDisplayName() + "' not available for networks");
return networkView.getVisualProperty(vp);
} else if (target instanceof CyNode) {
if (vpTargetType != CyNode.class)
throw new RuntimeException("Property '" + vp.getDisplayName() + "' not available for nodes");
View<CyNode> nodeView = networkView.getNodeView((CyNode) target);
return nodeView.getVisualProperty(vp);
} else if (target instanceof CyEdge) {
if (vpTargetType != CyEdge.class)
throw new RuntimeException("Property '" + vp.getDisplayName() + "' not available for edges");
View<CyEdge> edgeView = networkView.getEdgeView((CyEdge) target);
return edgeView.getVisualProperty(vp);
}
return null;
}
Aggregations