public synchronized void setHierarchy(PathObjectHierarchy hierarchy) { if (this == hierarchy) return; rootObject = hierarchy.getRootObject(); tmaGrid = hierarchy.tmaGrid; fireHierarchyChangedEvent(rootObject); }
public synchronized void clearAll() { getRootObject().clearPathObjects(); tmaGrid = null; fireHierarchyChangedEvent(getRootObject()); }
public synchronized boolean addPathObject(PathObject pathObject, boolean avoidDuplicates, boolean fireUpdate) { if (pathObject == getRootObject() || !pathObject.hasROI()) return false; return addPathObjectToList(getRootObject(), pathObject, avoidDuplicates, fireUpdate); }
public synchronized int nObjects() { int count = PathObjectTools.countDescendants(getRootObject()); return count; }
public synchronized void fireHierarchyChangedEvent(Object source) { fireHierarchyChangedEvent(source, getRootObject()); }
/** * Check if a hierarchy contains a specified PathObject. * The actual check if carried out by seeing in the PathObject is descended from the root object of the hierarchy. * * @param hierarchy * @param pathObject * @return */ public static boolean hierarchyContainsObject(final PathObjectHierarchy hierarchy, final PathObject pathObject) { if (pathObject == null) return false; PathObject testObject = pathObject; while (testObject != null && (!(testObject instanceof PathRootObject))) testObject = testObject.getParent(); return testObject == hierarchy.getRootObject(); }
private void constructCache() { w.lock(); try { // logger.info("Skipping cache reconstruction..."); long startTime = System.currentTimeMillis(); isActive = true; map.clear(); addToCache(hierarchy.getRootObject(), true); long endTime = System.currentTimeMillis(); logger.trace("Cache reconstructed in " + (endTime - startTime)/1000.); } finally { w.unlock(); } // cacheCounter += (endTime - startTime); // logger.info("Cache count: " + (cacheCounter)/1000.); }
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; }
/** * Determine if a PathObject is within this hierarchy. * The actual test is to check the highest parent object of the PathObject is equal to the root object for this hierarchy. * * @param pathObject * @return */ private synchronized boolean inHierarchy(PathObject pathObject) { // made private as only called here if (pathObject == null) return false; while (pathObject.getParent() != null) pathObject = pathObject.getParent(); return pathObject.equals(getRootObject()); }
public List<PathObject> getObjects(List<PathObject> pathObjects, Class<? extends PathObject> cls) { if (pathObjects == null) pathObjects = new ArrayList<>(); // If we want annotations, it can be much faster to get them from the tile cache than to sift through a potentially large number of detections if (PathAnnotationObject.class == cls && tileCache != null && tileCache.isActive()) { pathObjects.addAll(tileCache.getObjectsForRegion(cls, null, null, true)); return pathObjects; } addPathObjectsRecursively(getRootObject(), pathObjects, cls); return pathObjects; }
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()); }
for (PathObject pathObject : hierarchy.getRootObject().getChildObjects()) { if (pathObject instanceof TMACoreObject) continue;
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()); }
hierarchy.getRootObject().addPathObjects(pathObjects); } catch (IOException e) { e.printStackTrace();