use of qupath.lib.plugins.PathTask in project qupath by qupath.
the class FindConvexHullDetectionsPlugin method addRunnableTasks.
@Override
protected void addRunnableTasks(ImageData<T> imageData, PathObject parentObject, List<Runnable> tasks) {
boolean deleteImmediately = Boolean.TRUE.equals(params.getBooleanParameterValue("deleteImmediately"));
tasks.add(new PathTask() {
private List<PathObject> toRemove;
private int nRemoved;
@Override
public void run() {
toRemove = getConvexHullDetections(imageData.getHierarchy(), parentObject, params.getIntParameterValue("nIterations"));
nRemoved = toRemove.size();
}
@Override
public void taskComplete(boolean wasCancelled) {
if (wasCancelled)
return;
if (toRemove != null && !toRemove.isEmpty()) {
if (deleteImmediately)
imageData.getHierarchy().removeObjects(toRemove, false);
else {
imageData.getHierarchy().getSelectionModel().deselectObject(parentObject);
imageData.getHierarchy().getSelectionModel().selectObjects(toRemove);
}
toRemove = null;
nObjectsRemoved.addAndGet(nRemoved);
}
}
@Override
public String getLastResultsDescription() {
String process = deleteImmediately ? "Removed " : "Selected ";
if (Boolean.TRUE.equals(params.getBooleanParameterValue("deleteImmediately")))
if (nRemoved == 1)
return process + " 1 object";
return process + nRemoved + " objects";
}
});
}
Aggregations