Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * Assign a selected annotation to be a child of whichever TMA core contains its centroid.
- *
- * This can be useful whenever an annotation is drawn *slightly* overlapping the core,
- * and so is not automatically assigned to be a child of the core - but it should be.
- *
- * @author Pete Bankhead
- */
- // Ensure annotation is selected!
- annotation = getSelectedObject()
- if (annotation == null || !annotation.isAnnotation()) {
- println("Ensure an annotation is selected!")
- return
- }
- // Get the hierarchy for later
- hierarchy = getCurrentHierarchy()
- // Little sanity check - make sure the annotation is directly below the hierarchy root
- if (annotation.getParent() != hierarchy.getRootObject()) {
- println("Selected annotation is not a direct child of the root object!")
- return
- }
- // Get the annotation centroid location
- roi = annotation.getROI()
- x = roi.getCentroidX()
- y = roi.getCentroidY()
- // Loop through the TMA cores
- for (core in getTMACoreList()) {
- // Check if the core ROI contains the annotation centroid
- if (core.getROI().contains(x, y)) {
- // Add annotation to the core
- core.addPathObject(annotation)
- println("Annotation added to " + core)
- // Call off the search
- break
- }
- }
- // Fire general update event to ensure everything gets synchronized & shown
- hierarchy.fireHierarchyChangedEvent(this)/*
- * Assign a selected annotation to be a child of whichever TMA core contains its centroid.
- *
- * This can be useful whenever an annotation is drawn *slightly* overlapping the core,
- * and so is not automatically assigned to be a child of the core - but it should be.
- */
- // Ensure annotation is selected!
- annotation = getSelectedObject()
- if (annotation == null || !annotation.isAnnotation()) {
- println("Ensure an annotation is selected!")
- return
- }
- // Get the hierarchy for later
- hierarchy = getCurrentHierarchy()
- // Little sanity check - make sure the annotation is directly below the hierarchy root
- if (annotation.getParent() != hierarchy.getRootObject()) {
- println("Selected annotation is not a direct child of the root object!")
- return
- }
- // Get the annotation centroid location
- roi = annotation.getROI()
- x = roi.getCentroidX()
- y = roi.getCentroidY()
- // Loop through the TMA cores
- for (core in getTMACoreList()) {
- // Check if the core ROI contains the annotation centroid
- if (core.getROI().contains(x, y)) {
- // Add annotation to the core
- core.addPathObject(annotation)
- println("Annotation added to " + core)
- // Call off the search
- break
- }
- }
- // Fire general update event to ensure everything gets synchronized & shown
- hierarchy.fireHierarchyChangedEvent(this)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement