Exemplo n.º 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;
 }
Exemplo n.º 2
0
 void drawZoomIndicator(Graphics g) {
   int x1 = 10;
   int y1 = 10;
   double aspectRatio = (double) imageHeight / imageWidth;
   int w1 = 64;
   if (aspectRatio > 1.0) w1 = (int) (w1 / aspectRatio);
   int h1 = (int) (w1 * aspectRatio);
   if (w1 < 4) w1 = 4;
   if (h1 < 4) h1 = 4;
   int w2 = (int) (w1 * ((double) srcRect.width / imageWidth));
   int h2 = (int) (h1 * ((double) srcRect.height / imageHeight));
   if (w2 < 1) w2 = 1;
   if (h2 < 1) h2 = 1;
   int x2 = (int) (w1 * ((double) srcRect.x / imageWidth));
   int y2 = (int) (h1 * ((double) srcRect.y / imageHeight));
   if (zoomIndicatorColor == null) zoomIndicatorColor = new Color(128, 128, 255);
   g.setColor(zoomIndicatorColor);
   ((Graphics2D) g).setStroke(Roi.onePixelWide);
   g.drawRect(x1, y1, w1, h1);
   if (w2 * h2 <= 200 || w2 < 10 || h2 < 10) g.fillRect(x1 + x2, y1 + y2, w2, h2);
   else g.drawRect(x1 + x2, y1 + y2, w2, h2);
 }
Exemplo n.º 3
0
 void drawOverlay(Graphics g) {
   if (imp != null && imp.getHideOverlay()) return;
   Color labelColor = overlay.getLabelColor();
   if (labelColor == null) labelColor = Color.white;
   initGraphics(g, labelColor, Roi.getColor());
   int n = overlay.size();
   if (IJ.debugMode) IJ.log("paint: drawing " + n + " ROI display list");
   int currentImage = imp != null ? imp.getCurrentSlice() : -1;
   if (imp.getStackSize() == 1) currentImage = -1;
   int channel = 0, slice = 0, frame = 0;
   boolean hyperstack = imp.isHyperStack();
   if (hyperstack) {
     channel = imp.getChannel();
     slice = imp.getSlice();
     frame = imp.getFrame();
   }
   drawNames = overlay.getDrawNames();
   boolean drawLabels = drawNames || overlay.getDrawLabels();
   for (int i = 0; i < n; i++) {
     if (overlay == null) break;
     Roi roi = overlay.get(i);
     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 + LIST_OFFSET : -1);
     } else {
       int position = roi.getPosition();
       if (position == 0 || position == currentImage)
         drawRoi(g, roi, drawLabels ? i + LIST_OFFSET : -1);
     }
   }
   ((Graphics2D) g).setStroke(Roi.onePixelWide);
   drawNames = false;
 }