Пример #1
0
 void drawAllROIs(Graphics g) {
   RoiManager rm = RoiManager.getInstance();
   if (rm == null) {
     rm = Interpreter.getBatchModeRoiManager();
     if (rm != null && rm.getList().getItemCount() == 0) rm = null;
   }
   if (rm == null) {
     // if (showAllList!=null)
     //	overlay = showAllList;
     showAllROIs = false;
     repaint();
     return;
   }
   initGraphics(g, null, showAllColor);
   Hashtable rois = rm.getROIs();
   java.awt.List list = rm.getList();
   boolean drawLabels = rm.getDrawLabels();
   currentRoi = null;
   int n = list.getItemCount();
   if (IJ.debugMode) IJ.log("paint: drawing " + n + " \"Show All\" ROIs");
   if (labelRects == null || labelRects.length != n) labelRects = new Rectangle[n];
   if (!drawLabels) showAllList = new Overlay();
   else showAllList = null;
   if (imp == null) return;
   int currentImage = imp.getCurrentSlice();
   int channel = 0, slice = 0, frame = 0;
   boolean hyperstack = imp.isHyperStack();
   if (hyperstack) {
     channel = imp.getChannel();
     slice = imp.getSlice();
     frame = imp.getFrame();
   }
   drawNames = Prefs.useNamesAsLabels;
   for (int i = 0; i < n; i++) {
     String label = list.getItem(i);
     Roi roi = (Roi) rois.get(label);
     if (roi == null) continue;
     if (showAllList != null) showAllList.add(roi);
     if (i < 200 && drawLabels && roi == imp.getRoi()) currentRoi = roi;
     if (Prefs.showAllSliceOnly && imp.getStackSize() > 1) {
       if (hyperstack && roi.getPosition() == 0) {
         int c = roi.getCPosition();
         int z = roi.getZPosition();
         int t = roi.getTPosition();
         if ((c == 0 || c == channel) && (z == 0 || z == slice) && (t == 0 || t == frame))
           drawRoi(g, roi, drawLabels ? i : -1);
       } else {
         int position = roi.getPosition();
         if (position == 0) position = getSliceNumber(roi.getName());
         if (position == 0 || position == currentImage) drawRoi(g, roi, drawLabels ? i : -1);
       }
     } else drawRoi(g, roi, drawLabels ? i : -1);
   }
   ((Graphics2D) g).setStroke(Roi.onePixelWide);
   drawNames = false;
 }
Пример #2
0
 boolean roiManagerSelect(int x, int y) {
   RoiManager rm = RoiManager.getInstance();
   if (rm == null) return false;
   Hashtable rois = rm.getROIs();
   java.awt.List list = rm.getList();
   int n = list.getItemCount();
   if (labelRects == null || labelRects.length != n) return false;
   boolean stackMode = imp != null && imp.getStackSize() > 1 && Prefs.showAllSliceOnly;
   for (int i = 0; i < n; i++) {
     if (labelRects[i] != null && labelRects[i].contains(x, y)) {
       if (stackMode) {
         int slice = getSliceNumber(list.getItem(i));
         if (slice != imp.getCurrentSlice()) continue;
       }
       // rm.select(i);
       // this needs to run on a separate thread, at least on OS X
       // "update2" does not clone the ROI so the "Show All"
       // outline moves as the user moves the RO.
       new ij.macro.MacroRunner("roiManager('select', " + i + "); roiManager('update2');");
       return true;
     }
   }
   return false;
 }