All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.github.mianalysis.mia.moduledependencies.Dependencies Maven / Gradle / Ivy

Go to download

ModularImageAnalysis (MIA) is an ImageJ plugin which provides a modular framework for assembling image and object analysis workflows. Detected objects can be transformed, filtered, measured and related. Analysis workflows are batch-enabled by default, allowing easy processing of high-content datasets.

There is a newer version: 1.6.12
Show newest version
package io.github.mianalysis.mia.moduledependencies;

import java.util.HashMap;
import java.util.HashSet;
import java.util.List;

import org.scijava.InstantiableException;
import org.scijava.plugin.PluginInfo;

import io.github.mianalysis.mia.MIA;
import io.github.mianalysis.mia.process.ClassHunter;

public class Dependencies {
    private HashMap> dependencies = null;

    public boolean compatible(String moduleName, boolean rescan) {
        // Check if dependencies have already been searched for
        if (dependencies == null || rescan)
            updateDependencies();

        boolean compatible = true;

        if (dependencies.containsKey(moduleName))
            for (Dependency dependency : dependencies.get(moduleName))
                if (!dependency.test())
                    compatible = false;
        
        return compatible;

    }

    public HashSet getDependencies(String moduleName, boolean rescan) {
        // Check if dependencies have already been searched for
        if (dependencies == null || rescan)
            updateDependencies();

        return dependencies.get(moduleName);

    }

    public void updateDependencies() {
        dependencies = new HashMap<>();
        
        List> plugins = ClassHunter.getPlugins(Dependency.class);
        for (PluginInfo plugin : plugins) {
            try {
                Dependency dependency = plugin.createInstance();
                dependencies.putIfAbsent(dependency.getModuleName(), new HashSet());
                dependencies.get(dependency.getModuleName()).add(dependency);
            } catch (InstantiableException e) {
                MIA.log.writeError(e);
            }
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy