use of qupath.lib.plugins.CommandLinePluginRunner in project qupath by qupath.
the class QPEx method runPlugin.
@SuppressWarnings({ "unchecked", "rawtypes" })
public static boolean runPlugin(final String className, final ImageData<?> imageData, final String args) throws InterruptedException {
if (imageData == null)
return false;
boolean completed = false;
String pluginName = className;
boolean cancelled = false;
try {
Class<?> cPlugin = QP.class.getClassLoader().loadClass(className);
Constructor<?> cons = cPlugin.getConstructor();
final PathPlugin plugin = (PathPlugin) cons.newInstance();
pluginName = plugin.getName();
PluginRunner runner;
// TODO: Give potential of passing a plugin runner
var qupath = getQuPath();
if (isBatchMode() || imageData != qupath.getImageData()) {
runner = new CommandLinePluginRunner(imageData);
completed = plugin.runPlugin(runner, args);
cancelled = runner.isCancelled();
} else {
completed = qupath.runPlugin(plugin, args, false);
cancelled = !completed;
// runner = new PluginRunnerFX(qupath);
}
} catch (Exception e) {
logger.error("Error running plugin {}: {}", className, e.getLocalizedMessage());
logger.error("", e);
}
// Notify caller that this failed
if (cancelled)
throw new InterruptedException(pluginName + " cancelled!");
// }
return completed;
}
Aggregations