use of org.cytoscape.io.read.AbstractCyNetworkReader in project cytoscape-impl by cytoscape.
the class LoadMultipleNetworksTask method run.
@Override
public void run(TaskMonitor taskMonitor) throws Exception {
this.taskMonitor = taskMonitor;
if (readers == null && readers.isEmpty())
throw new IllegalArgumentException("No network reader specified.");
taskMonitor.setTitle("Import Networks");
taskMonitor.setProgress(0.0);
final String rootNetName = rootNetwork != null ? rootNetwork.getRow(rootNetwork).get(CyRootNetwork.NAME, String.class) : null;
final String targetColumn = targetColumnList != null ? targetColumnList.getSelectedValue() : null;
final NetworkViewRenderer renderer = rendererList != null ? rendererList.getSelectedValue() : null;
final float total = readers.size();
int count = 1;
for (Entry<String, CyNetworkReader> entry : readers.entrySet()) {
if (cancelled)
return;
final CyNetworkReader r = entry.getValue();
if (r instanceof AbstractCyNetworkReader) {
AbstractCyNetworkReader ar = (AbstractCyNetworkReader) r;
if (rootNetName != null) {
ListSingleSelection<String> ls = new ListSingleSelection<>(Collections.singletonList(rootNetName));
ls.setSelectedValue(rootNetName);
ar.setRootNetworkList(ls);
} else {
// Force "create new collection"
ar.setRootNetworkList(new ListSingleSelection<>(Collections.emptyList()));
ar.setTargetColumnList(new ListSingleSelection<>(Collections.emptyList()));
}
if (targetColumn != null) {
ListSingleSelection<String> ls = new ListSingleSelection<>(Collections.singletonList(targetColumn));
ls.setSelectedValue(targetColumn);
ar.setTargetColumnList(ls);
}
if (renderer != null) {
ListSingleSelection<NetworkViewRenderer> ls = new ListSingleSelection<>(Collections.singletonList(renderer));
ls.setSelectedValue(renderer);
ar.setNetworkViewRendererList(ls);
}
}
name = entry.getKey();
loadNetwork(r);
taskMonitor.setProgress(count / total);
count++;
}
}
Aggregations