/** * Trigger an update for the specified hierarchy. * * This should be called after any (non-standard) modifications are made to the hierarchy * to ensure that all listeners are notified (including for any GUI). * * @param hierarchy */ public static void fireHierarchyUpdate(final PathObjectHierarchy hierarchy) { if (hierarchy != null) hierarchy.fireHierarchyChangedEvent(QP.class); }
public synchronized void setHierarchy(PathObjectHierarchy hierarchy) { if (this == hierarchy) return; rootObject = hierarchy.getRootObject(); tmaGrid = hierarchy.tmaGrid; fireHierarchyChangedEvent(rootObject); }
public synchronized void fireHierarchyChangedEvent(Object source) { fireHierarchyChangedEvent(source, getRootObject()); }
@Override public void taskComplete() { if (!Thread.currentThread().isInterrupted()) { if (params.getBooleanParameterValue("deleteTiles")) parentObject.clearPathObjects(); if (pathAnnotations != null && !pathAnnotations.isEmpty()) parentObject.addPathObjects(pathAnnotations); imageData.getHierarchy().fireHierarchyChangedEvent(parentObject); } pathAnnotations = null; }
synchronized void clearTMAGrid() { if (tmaGrid == null) return; removeObjects(new ArrayList<>(tmaGrid.getTMACoreList()), true); // for (TMACoreObject core : tmaGrid.getTMACoreList()) // removeObject(core, true); // this.tmaGrid = null; // Notify listeners of changes fireHierarchyChangedEvent(getRootObject()); }
public synchronized boolean addPathObjects(Collection<PathObject> pathObjects, boolean avoidDuplicates) { boolean changes = false; int n = pathObjects.size(); int counter = 0; for (PathObject pathObject : pathObjects) { if (n > 10000) { if (counter % 1000 == 0) logger.info("Adding {} of {}", counter, n); } else if (n > 1000 && counter % 100 == 0) logger.info("Adding {} of {}", counter, n); changes = addPathObjectToList(getRootObject(), pathObject, avoidDuplicates, false) || changes; counter++; } if (changes) fireHierarchyChangedEvent(getRootObject()); // fireChangeEvent(getRootObject()); return changes; }
public synchronized void clearAll() { getRootObject().clearPathObjects(); tmaGrid = null; fireHierarchyChangedEvent(getRootObject()); }
@Override public boolean runPlugin(final PluginRunner<BufferedImage> pluginRunner, final String arg) { boolean tempRegionStore = false; if (regionStore == null) { regionStore = pluginRunner.getRegionStore(); tempRegionStore = regionStore != null; } boolean success = super.runPlugin(pluginRunner, arg); pluginRunner.getHierarchy().fireHierarchyChangedEvent(this); if (tempRegionStore) { regionStore = null; } return success; }
private synchronized void updateTMAHierarchy() { if (tmaGrid == null) return; // Assign annotations to cores List<PathObject> pathObjectChildren = new ArrayList<>(rootObject.getChildObjects()); rootObject.clearPathObjects(); // Add cores to the start of the object list rootObject.addPathObjects(tmaGrid.getTMACoreList()); // Add back any other objects for (PathObject pathObject : pathObjectChildren) addPathObject(pathObject, false, false); // Notify listeners of changes fireHierarchyChangedEvent(getRootObject()); }
boolean checkAllTestsComplete() { if (map.isEmpty() && getParent() != null) { if (countdown == null) { hierarchy.removeObject(this, true); } else if (countdown.decrementAndGet() == 0) { PathObject parent = getParent(); List<PathObject> parallelObjects = new ArrayList<>(); for (PathObject temp : parent.getChildObjects()) { if (temp instanceof ParallelTileObject) { parallelObjects.add(temp); } } parent.removePathObjects(parallelObjects); for (PathObject temp : parallelObjects) parent.addPathObjects(temp.getChildObjects()); if (parent.hasChildren() && parent instanceof PathROIObject) ((PathROIObject)parent).setLocked(true); hierarchy.fireHierarchyChangedEvent(parent); } return true; // getParent().removePathObject(this); // getParent().addPathObjects(getPathObjectList()); } return false; }
public synchronized boolean removeObject(PathObject pathObject, boolean keepChildren, boolean fireEvent) { // Check the object is within the hierarchy & has a valid parent (from which it can be removed) PathObject pathObjectParent = pathObject.getParent(); if (!inHierarchy(pathObject) || pathObjectParent == null) { logger.warn(pathObject + " could not be removed from the hierarchy"); return false; } // Can't keep children if there aren't any keepChildren = keepChildren && pathObject.hasChildren(); pathObjectParent.removePathObject(pathObject); // Assign the children to the parent object, if necessary if (keepChildren) { // We create a new array list because getPathObjectList returns an unmodifiable collection // List<PathObject> list = new ArrayList<>(pathObject.getPathObjectList()); pathObjectParent.addPathObjects(pathObject.getChildObjects()); // pathObject.clearPathObjects(); // Clear child objects, just in case } if (fireEvent) { if (keepChildren) fireObjectRemovedEvent(this, pathObject, pathObjectParent); else fireHierarchyChangedEvent(this, pathObjectParent); } return true; }
imageData.getHierarchy().fireHierarchyChangedEvent(parentObject);
tasks.add(DetectionPluginTools.createRunnableTask(createDetector(imageData, params), params, imageData, tile)); imageData.getHierarchy().fireHierarchyChangedEvent(this);
@Override public void taskComplete() { parentObject.clearPathObjects(); parentObject.addPathObjects(tiles); imageData.getHierarchy().fireHierarchyChangedEvent(this, parentObject); if (params.getBooleanParameterValue("removeParentAnnotation") && params.getBooleanParameterValue("makeAnnotations") && parentObject.isAnnotation()) { imageData.getHierarchy().removeObject(parentObject, true); } }
hierarchy.fireHierarchyChangedEvent(null);