use of org.cytoscape.filter.internal.view.FilterElement in project cytoscape-impl by cytoscape.
the class TransformerWorker method doWork.
@Override
public void doWork(ProgressMonitor monitor) {
if (controller == null) {
return;
}
final CyApplicationManager applicationManager = serviceRegistrar.getService(CyApplicationManager.class);
CyNetworkView networkView = applicationManager.getCurrentNetworkView();
CyNetwork network;
if (networkView != null) {
network = networkView.getModel();
} else {
network = applicationManager.getCurrentNetwork();
}
if (network == null) {
return;
}
ProgressMonitor filterMonitor = new SubProgressMonitor(monitor, 0.0, 0.4);
ProgressMonitor chainMonitor = new SubProgressMonitor(monitor, 0.4, 0.98);
monitor.setProgress(0.0);
monitor.setStatusMessage(null);
Sink sink = new Sink(network);
long startTime = System.currentTimeMillis();
try {
List<Transformer<CyNetwork, CyIdentifiable>> transformers = controller.getTransformers(view);
FilterElement selected = (FilterElement) controller.getStartWithComboBoxModel().getSelectedItem();
TransformerSource<CyNetwork, CyIdentifiable> source = createSource(network, selected, filterMonitor);
for (Transformer<?, ?> transformer : transformers) {
if (transformer instanceof MemoizableTransformer) {
((MemoizableTransformer) transformer).startCaching();
}
}
try {
transformerManager.execute(network, source, transformers, sink, chainMonitor);
} finally {
for (Transformer<?, ?> transformer : transformers) {
if (transformer instanceof MemoizableTransformer) {
((MemoizableTransformer) transformer).clearCache();
}
}
}
if (networkView != null) {
networkView.updateView();
}
} finally {
long duration = System.currentTimeMillis() - startTime;
monitor.setProgress(1.0);
monitor.setStatusMessage(String.format("Selected %d %s and %d %s in %dms", sink.nodeCount, sink.nodeCount == 1 ? "node" : "nodes", sink.edgeCount, sink.edgeCount == 1 ? "edge" : "edges", duration));
}
}
Aggregations