Search in sources :

Example 1 with CyTransformerReader

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);
    }
}
Also used : AbstractPanelController(org.cytoscape.filter.internal.view.AbstractPanelController) NamedTransformer(org.cytoscape.filter.model.NamedTransformer) BufferedInputStream(java.io.BufferedInputStream) CyNetwork(org.cytoscape.model.CyNetwork) FileInputStream(java.io.FileInputStream) CyTransformerReader(org.cytoscape.io.read.CyTransformerReader) CyIdentifiable(org.cytoscape.model.CyIdentifiable)

Example 2 with CyTransformerReader

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);
}
Also used : CyNetwork(org.cytoscape.model.CyNetwork) CyTransformerReader(org.cytoscape.io.read.CyTransformerReader) CyIdentifiable(org.cytoscape.model.CyIdentifiable)

Example 3 with CyTransformerReader

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);
}
Also used : CyApplicationManager(org.cytoscape.application.CyApplicationManager) CyNetwork(org.cytoscape.model.CyNetwork) CyTransformerReader(org.cytoscape.io.read.CyTransformerReader) CyIdentifiable(org.cytoscape.model.CyIdentifiable)

Aggregations

CyTransformerReader (org.cytoscape.io.read.CyTransformerReader)3 CyIdentifiable (org.cytoscape.model.CyIdentifiable)3 CyNetwork (org.cytoscape.model.CyNetwork)3 BufferedInputStream (java.io.BufferedInputStream)1 FileInputStream (java.io.FileInputStream)1 CyApplicationManager (org.cytoscape.application.CyApplicationManager)1 AbstractPanelController (org.cytoscape.filter.internal.view.AbstractPanelController)1 NamedTransformer (org.cytoscape.filter.model.NamedTransformer)1