use of org.cytoscape.io.read.CyTransformerReader in project cytoscape-impl by cytoscape.
the class FilterIO method readTransformers.
@SuppressWarnings({ "unchecked", "rawtypes" })
public void readTransformers(File file, AbstractPanel panel) throws IOException {
try (BufferedInputStream stream = new BufferedInputStream(new FileInputStream(file))) {
CyTransformerReader reader = serviceRegistrar.getService(CyTransformerReader.class);
NamedTransformer<CyNetwork, CyIdentifiable>[] transformers = (NamedTransformer<CyNetwork, CyIdentifiable>[]) reader.read(stream);
AbstractPanelController controller = panel.getController();
controller.addNamedTransformers(panel, transformers);
}
}
use of org.cytoscape.io.read.CyTransformerReader in project cytoscape-impl by cytoscape.
the class CreateFilterTask method run.
@Override
public void run(TaskMonitor taskMonitor) {
if (name == null || name.isEmpty()) {
taskMonitor.showMessage(Level.ERROR, "name is missing");
return;
}
CyTransformerReader transformerReader = serviceRegistrar.getService(CyTransformerReader.class);
NamedTransformer<CyNetwork, CyIdentifiable> transformer = jsonTunable.getTransformer(name, transformerReader);
if (transformer == null) {
taskMonitor.showMessage(Level.ERROR, "Error parsing JSON");
return;
}
boolean valid = TransformerJsonTunable.validate(transformer, taskMonitor);
if (!valid) {
return;
}
TransformerContainer<CyNetwork, CyIdentifiable> container = containerTunable.getContainer(serviceRegistrar);
if (container == null) {
taskMonitor.showMessage(Level.ERROR, "container type not found: '" + containerTunable.getValue() + "'");
return;
}
container.addNamedTransformer(transformer);
}
use of org.cytoscape.io.read.CyTransformerReader in project cytoscape-impl by cytoscape.
the class ApplyFilterTask method run.
@Override
public void run(TaskMonitor taskMonitor) throws IOException {
if (network == null)
network = serviceRegistrar.getService(CyApplicationManager.class).getCurrentNetwork();
CyTransformerReader transformerReader = serviceRegistrar.getService(CyTransformerReader.class);
NamedTransformer<CyNetwork, CyIdentifiable> transformer = json.getTransformer("ApplyFilterTask", transformerReader);
if (transformer == null) {
taskMonitor.showMessage(Level.ERROR, "Error parsing JSON");
return;
}
boolean valid = TransformerJsonTunable.validate(transformer, taskMonitor);
if (!valid) {
return;
}
applyFilter(serviceRegistrar, network, transformer);
}
Aggregations