io.github.mianalysis.mia.moduledependencies.Dependencies Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of mia-core Show documentation
Show all versions of mia-core Show documentation
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.
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);
}
}
}
}