void drawRoiLabel(Graphics g, int index, Roi roi) { Rectangle r = roi.getBounds(); int x = screenX(r.x); int y = screenY(r.y); double mag = getMagnification(); int width = (int) (r.width * mag); int height = (int) (r.height * mag); int size = width > 40 && height > 40 ? 12 : 9; if (font != null) { g.setFont(font); size = font.getSize(); } else if (size == 12) g.setFont(largeFont); else g.setFont(smallFont); boolean drawingList = index >= LIST_OFFSET; if (drawingList) index -= LIST_OFFSET; String label = "" + (index + 1); if (drawNames && roi.getName() != null) label = roi.getName(); FontMetrics metrics = g.getFontMetrics(); int w = metrics.stringWidth(label); x = x + width / 2 - w / 2; y = y + height / 2 + Math.max(size / 2, 6); int h = metrics.getAscent() + metrics.getDescent(); if (bgColor != null) { g.setColor(bgColor); g.fillRoundRect(x - 1, y - h + 2, w + 1, h - 3, 5, 5); } if (!drawingList && labelRects != null && index < labelRects.length) labelRects[index] = new Rectangle(x - 1, y - h + 2, w + 1, h); g.setColor(labelColor); g.drawString(label, x, y - 2); g.setColor(defaultColor); }
void fitSpline() { Roi roi = imp.getRoi(); if (roi == null) { noRoi("Spline"); return; } int type = roi.getType(); boolean segmentedSelection = type == Roi.POLYGON || type == Roi.POLYLINE; if (!(segmentedSelection || type == Roi.FREEROI || type == Roi.TRACED_ROI || type == Roi.FREELINE)) { IJ.error("Spline", "Polygon or polyline selection required"); return; } if (roi instanceof EllipseRoi) return; PolygonRoi p = (PolygonRoi) roi; if (!segmentedSelection) { if (p.subPixelResolution()) p = trimFloatPolygon(p, p.getUncalibratedLength()); else p = trimPolygon(p, p.getUncalibratedLength()); } String options = Macro.getOptions(); if (options != null && options.indexOf("straighten") != -1) p.fitSplineForStraightening(); else if (options != null && options.indexOf("remove") != -1) p.removeSplineFit(); else p.fitSpline(); imp.draw(); LineWidthAdjuster.update(); }
/** Sets the cursor based on the current tool and cursor location. */ public void setCursor(int sx, int sy, int ox, int oy) { xMouse = ox; yMouse = oy; mouseExited = false; Roi roi = imp.getRoi(); ImageWindow win = imp.getWindow(); if (win == null) return; if (IJ.spaceBarDown()) { setCursor(handCursor); return; } int id = Toolbar.getToolId(); switch (Toolbar.getToolId()) { case Toolbar.MAGNIFIER: setCursor(moveCursor); break; case Toolbar.HAND: setCursor(handCursor); break; default: // selection tool if (id == Toolbar.SPARE1 || id >= Toolbar.SPARE2) { if (Prefs.usePointerCursor) setCursor(defaultCursor); else setCursor(crosshairCursor); } else if (roi != null && roi.getState() != roi.CONSTRUCTING && roi.isHandle(sx, sy) >= 0) setCursor(handCursor); else if (Prefs.usePointerCursor || (roi != null && roi.getState() != roi.CONSTRUCTING && roi.contains(ox, oy))) setCursor(defaultCursor); else setCursor(crosshairCursor); } }
void addToRoiManager(ImagePlus imp) { if (IJ.macroRunning() && Interpreter.isBatchModeRoiManager()) IJ.error("run(\"Add to Manager\") may not work in batch mode macros"); Frame frame = WindowManager.getFrame("ROI Manager"); if (frame == null) IJ.run("ROI Manager..."); if (imp == null) return; Roi roi = imp.getRoi(); if (roi == null) return; frame = WindowManager.getFrame("ROI Manager"); if (frame == null || !(frame instanceof RoiManager)) IJ.error("ROI Manager not found"); RoiManager rm = (RoiManager) frame; boolean altDown = IJ.altKeyDown(); IJ.setKeyUp(IJ.ALL_KEYS); if (altDown && !IJ.macroRunning()) IJ.setKeyDown(KeyEvent.VK_SHIFT); if (roi.getState() == Roi.CONSTRUCTING) { // wait (up to 2 sec.) until ROI finished long start = System.currentTimeMillis(); while (true) { IJ.wait(10); if (roi.getState() != Roi.CONSTRUCTING) break; if ((System.currentTimeMillis() - start) > 2000) { IJ.beep(); IJ.error("Add to Manager", "Selection is not complete"); return; } } } rm.runCommand("add"); IJ.setKeyUp(IJ.ALL_KEYS); }
void runMacro(String arg) { Roi roi = imp.getRoi(); if (IJ.macroRunning()) { String options = Macro.getOptions(); if (options != null && (options.indexOf("grid=") != -1 || options.indexOf("interpolat") != -1)) { IJ.run("Rotate... ", options); // run Image>Transform>Rotate return; } } if (roi == null) { noRoi("Rotate>Selection"); return; } roi = (Roi) roi.clone(); if (arg.equals("rotate")) { double d = Tools.parseDouble(angle); if (Double.isNaN(d)) angle = "15"; String value = IJ.runMacroFile("ij.jar:RotateSelection", angle); if (value != null) angle = value; } else if (arg.equals("enlarge")) { String value = IJ.runMacroFile("ij.jar:EnlargeSelection", enlarge); if (value != null) enlarge = value; Roi.previousRoi = roi; } }
public void deleteHandle(double ox, double oy) { if (imp == null) return; if (nPoints <= 1) { imp.deleteRoi(); return; } boolean splineFit = xSpline != null; xSpline = null; FloatPolygon points = getFloatPolygon(); modState = NO_MODS; if (previousRoi != null) previousRoi.modState = NO_MODS; int pointToDelete = getClosestPoint(ox, oy, points); FloatPolygon points2 = new FloatPolygon(); for (int i = 0; i < points.npoints; i++) { if (i != pointToDelete) points2.addPoint(points.xpoints[i], points.ypoints[i]); } if (type == POINT) imp.setRoi(new PointRoi(points2.xpoints, points2.ypoints, points2.npoints)); else { if (subPixelResolution()) { Roi roi2 = new PolygonRoi(points2, type); roi2.setDrawOffset(getDrawOffset()); imp.setRoi(roi2); } else imp.setRoi( new PolygonRoi(toInt(points2.xpoints), toInt(points2.ypoints), points2.npoints, type)); if (splineFit) ((PolygonRoi) imp.getRoi()).fitSpline(splinePoints); } }
public int setup(String arg, ImagePlus imp) { this.arg = arg; this.imp = imp; IJ.register(ParticleAnalyzer.class); if (imp == null) { IJ.noImage(); return DONE; } if (imp.getBitDepth() == 24 && !isThresholdedRGB(imp)) { IJ.error( "Particle Analyzer", "RGB images must be thresholded using\n" + "Image>Adjust>Color Threshold."); return DONE; } if (!showDialog()) return DONE; int baseFlags = DOES_ALL + NO_CHANGES + NO_UNDO; int flags = IJ.setupDialog(imp, baseFlags); processStack = (flags & DOES_STACKS) != 0; slice = 0; saveRoi = imp.getRoi(); if (saveRoi != null && saveRoi.getType() != Roi.RECTANGLE && saveRoi.isArea()) polygon = saveRoi.getPolygon(); imp.startTiming(); nextFontSize = defaultFontSize; nextLineWidth = 1; return flags; }
void createEllipse(ImagePlus imp) { IJ.showStatus("Fitting ellipse"); Roi roi = imp.getRoi(); if (roi == null) { noRoi("Fit Ellipse"); return; } if (roi.isLine()) { IJ.error("Fit Ellipse", "\"Fit Ellipse\" does not work with line selections"); return; } ImageProcessor ip = imp.getProcessor(); ip.setRoi(roi); int options = Measurements.CENTROID + Measurements.ELLIPSE; ImageStatistics stats = ImageStatistics.getStatistics(ip, options, null); double dx = stats.major * Math.cos(stats.angle / 180.0 * Math.PI) / 2.0; double dy = -stats.major * Math.sin(stats.angle / 180.0 * Math.PI) / 2.0; double x1 = stats.xCentroid - dx; double x2 = stats.xCentroid + dx; double y1 = stats.yCentroid - dy; double y2 = stats.yCentroid + dy; double aspectRatio = stats.minor / stats.major; imp.killRoi(); imp.setRoi(new EllipseRoi(x1, y1, x2, y2, aspectRatio)); }
void lineToArea(ImagePlus imp) { Roi roi = imp.getRoi(); if (roi == null || !roi.isLine()) { IJ.error("Line to Area", "Line selection required"); return; } Undo.setup(Undo.ROI, imp); Roi roi2 = null; if (roi.getType() == Roi.LINE) { FloatPolygon p = roi.getFloatPolygon(); roi2 = new PolygonRoi(p, Roi.POLYGON); } else { ImageProcessor ip2 = new ByteProcessor(imp.getWidth(), imp.getHeight()); ip2.setColor(255); roi.drawPixels(ip2); // new ImagePlus("ip2", ip2.duplicate()).show(); ip2.setThreshold(255, 255, ImageProcessor.NO_LUT_UPDATE); ThresholdToSelection tts = new ThresholdToSelection(); roi2 = tts.convert(ip2); } transferProperties(roi, roi2); roi2.setStrokeWidth(0); Color c = roi2.getStrokeColor(); if (c != null) // remove any transparency roi2.setStrokeColor(new Color(c.getRed(), c.getGreen(), c.getBlue())); imp.setRoi(roi2); Roi.previousRoi = (Roi) roi.clone(); }
public void mouseMoved(MouseEvent e) { // if (ij==null) return; int sx = e.getX(); int sy = e.getY(); int ox = offScreenX(sx); int oy = offScreenY(sy); flags = e.getModifiers(); setCursor(sx, sy, ox, oy); IJ.setInputEvent(e); Roi roi = imp.getRoi(); if (roi != null && (roi.getType() == Roi.POLYGON || roi.getType() == Roi.POLYLINE || roi.getType() == Roi.ANGLE) && roi.getState() == roi.CONSTRUCTING) { PolygonRoi pRoi = (PolygonRoi) roi; pRoi.handleMouseMove(ox, oy); } else { if (ox < imageWidth && oy < imageHeight) { ImageWindow win = imp.getWindow(); // Cursor must move at least 12 pixels before text // displayed using IJ.showStatus() is overwritten. if ((sx - sx2) * (sx - sx2) + (sy - sy2) * (sy - sy2) > 144) showCursorStatus = true; if (win != null && showCursorStatus) win.mouseMoved(ox, oy); } else IJ.showStatus(""); } }
void createMask(ImagePlus imp) { Roi roi = imp.getRoi(); boolean useInvertingLut = Prefs.useInvertingLut; Prefs.useInvertingLut = false; if (roi == null || !(roi.isArea() || roi.getType() == Roi.POINT)) { createMaskFromThreshold(imp); Prefs.useInvertingLut = useInvertingLut; return; } ImagePlus maskImp = null; Frame frame = WindowManager.getFrame("Mask"); if (frame != null && (frame instanceof ImageWindow)) maskImp = ((ImageWindow) frame).getImagePlus(); if (maskImp == null) { ImageProcessor ip = new ByteProcessor(imp.getWidth(), imp.getHeight()); if (!Prefs.blackBackground) ip.invertLut(); maskImp = new ImagePlus("Mask", ip); maskImp.show(); } ImageProcessor ip = maskImp.getProcessor(); ip.setRoi(roi); ip.setValue(255); ip.fill(ip.getMask()); maskImp.updateAndDraw(); Prefs.useInvertingLut = useInvertingLut; }
/** * Saves statistics for one particle in a results table. This is a method subclasses may want to * override. */ protected void saveResults(ImageStatistics stats, Roi roi) { analyzer.saveResults(stats, roi); if (recordStarts) { rt.addValue("XStart", stats.xstart); rt.addValue("YStart", stats.ystart); } if (addToManager) { if (roiManager == null) { if (Macro.getOptions() != null && Interpreter.isBatchMode()) roiManager = Interpreter.getBatchModeRoiManager(); if (roiManager == null) { Frame frame = WindowManager.getFrame("ROI Manager"); if (frame == null) IJ.run("ROI Manager..."); frame = WindowManager.getFrame("ROI Manager"); if (frame == null || !(frame instanceof RoiManager)) { addToManager = false; return; } roiManager = (RoiManager) frame; } if (resetCounter) roiManager.runCommand("reset"); } if (imp.getStackSize() > 1) roi.setPosition(imp.getCurrentSlice()); if (lineWidth != 1) roi.setStrokeWidth(lineWidth); roiManager.add(imp, roi, rt.getCounter()); } if (showResults) rt.addResults(); }
private void enlarge(ImagePlus imp) { Roi roi = imp.getRoi(); if (roi != null) { Undo.setup(Undo.ROI, imp); roi = (Roi) roi.clone(); (new RoiEnlarger()).run(""); } else noRoi("Enlarge"); }
void toBoundingBox(ImagePlus imp) { Roi roi = imp.getRoi(); if (roi == null) { noRoi("To Bounding Box"); return; } Rectangle r = roi.getBounds(); imp.killRoi(); imp.setRoi(new Roi(r.x, r.y, r.width, r.height)); }
// Added by Marcel Boeglin 2013.09.22 private Overlay projectHyperStackRois(Overlay overlay) { if (overlay == null) return null; int t1 = imp.getFrame(); int channels = projImage.getNChannels(); int slices = 1; int frames = projImage.getNFrames(); Overlay overlay2 = new Overlay(); Roi roi; int c, z, t; int size = channels * slices * frames; for (Roi r : overlay.toArray()) { c = r.getCPosition(); z = r.getZPosition(); t = r.getTPosition(); roi = (Roi) r.clone(); if (size == channels) { // current time frame if (z >= startSlice && z <= stopSlice && t == t1 || c == 0) { roi.setPosition(c); overlay2.add(roi); } } else if (size == frames * channels) { // all time frames if (z >= startSlice && z <= stopSlice) roi.setPosition(c, 1, t); else if (z == 0) roi.setPosition(c, 0, t); else continue; overlay2.add(roi); } } return overlay2; }
void invert(ImagePlus imp) { Roi roi = imp.getRoi(); if (roi == null || !roi.isArea()) { IJ.error("Inverse", "Area selection required"); return; } ShapeRoi s1, s2; if (roi instanceof ShapeRoi) s1 = (ShapeRoi) roi; else s1 = new ShapeRoi(roi); s2 = new ShapeRoi(new Roi(0, 0, imp.getWidth(), imp.getHeight())); imp.setRoi(s1.xor(s2)); }
/** @deprecated replaced by ImagePlus.setOverlay(Shape, Color, BasicStroke) */ public void setDisplayList(Shape shape, Color color, BasicStroke stroke) { if (shape == null) { setOverlay(null); return; } Roi roi = new ShapeRoi(shape); roi.setStrokeColor(color); roi.setStroke(stroke); Overlay list = new Overlay(); list.add(roi); setOverlay(list); }
public int setup(String arg, ImagePlus imp) { this.imp = imp; if (imp != null) { bitDepth = imp.getBitDepth(); Roi roi = imp.getRoi(); Rectangle r = roi != null ? roi.getBounds() : null; canEnlarge = r == null || (r.x == 0 && r.y == 0 && r.width == imp.getWidth() && r.height == imp.getHeight()); } return flags; }
void lineWidth() { int width = (int) IJ.getNumber("Line Width:", Line.getWidth()); if (width == IJ.CANCELED) return; Line.setWidth(width); LineWidthAdjuster.update(); ImagePlus imp = WindowManager.getCurrentImage(); if (imp != null && imp.isProcessor()) { ImageProcessor ip = imp.getProcessor(); ip.setLineWidth(Line.getWidth()); Roi roi = imp.getRoi(); if (roi != null && roi.isLine()) imp.draw(); } }
void setRoiModState(MouseEvent e, Roi roi, int handle) { if (roi == null || (handle >= 0 && roi.modState == Roi.NO_MODS)) return; if (roi.state == Roi.CONSTRUCTING) return; int tool = Toolbar.getToolId(); if (tool > Toolbar.FREEROI && tool != Toolbar.WAND && tool != Toolbar.POINT) { roi.modState = Roi.NO_MODS; return; } if (e.isShiftDown()) roi.modState = Roi.ADD_TO_ROI; else if (e.isAltDown()) roi.modState = Roi.SUBTRACT_FROM_ROI; else roi.modState = Roi.NO_MODS; // IJ.log("setRoiModState: "+roi.modState+" "+ roi.state); }
void toBoundingBox(ImagePlus imp) { Roi roi = imp.getRoi(); if (roi == null) { noRoi("To Bounding Box"); return; } Undo.setup(Undo.ROI, imp); Rectangle r = roi.getBounds(); imp.deleteRoi(); Roi roi2 = new Roi(r.x, r.y, r.width, r.height); transferProperties(roi, roi2); imp.setRoi(roi2); }
void lineToArea(ImagePlus imp) { Roi roi = imp.getRoi(); if (roi == null || !roi.isLine()) { IJ.error("Line to Area", "Line selection required"); return; } if (roi.getType() == Roi.LINE && roi.getStrokeWidth() == 1) { IJ.error("Line to Area", "Straight line width must be > 1"); return; } ImageProcessor ip2 = new ByteProcessor(imp.getWidth(), imp.getHeight()); ip2.setColor(255); if (roi.getType() == Roi.LINE) ip2.fillPolygon(roi.getPolygon()); else { roi.drawPixels(ip2); // BufferedImage bi = new BufferedImage(imp.getWidth(), imp.getHeight(), // BufferedImage.TYPE_BYTE_GRAY); // Graphics g = bi.getGraphics(); // Roi roi2 = (Roi)roi.clone(); // roi2.setStrokeColor(Color.white); // roi2.drawOverlay(g); // ip2 = new ByteProcessor(bi); } // new ImagePlus("ip2", ip2.duplicate()).show(); ip2.setThreshold(255, 255, ImageProcessor.NO_LUT_UPDATE); ThresholdToSelection tts = new ThresholdToSelection(); Roi roi2 = tts.convert(ip2); imp.setRoi(roi2); Roi.previousRoi = (Roi) roi.clone(); }
void convexHull(ImagePlus imp) { Roi roi = imp.getRoi(); int type = roi != null ? roi.getType() : -1; if (!(type == Roi.FREEROI || type == Roi.TRACED_ROI || type == Roi.POLYGON || type == Roi.POINT)) { IJ.error("Convex Hull", "Polygonal or point selection required"); return; } if (roi instanceof EllipseRoi) return; Polygon p = roi.getConvexHull(); if (p != null) imp.setRoi(new PolygonRoi(p.xpoints, p.ypoints, p.npoints, roi.POLYGON)); }
// Added by Marcel Boeglin 2013.09.23 private Overlay projectStackRois(Overlay overlay) { if (overlay == null) return null; Overlay overlay2 = new Overlay(); Roi roi; int s; for (Roi r : overlay.toArray()) { s = r.getPosition(); roi = (Roi) r.clone(); if (s >= startSlice && s <= stopSlice || s == 0) { roi.setPosition(s); overlay2.add(roi); } } return overlay2; }
public void mouseDragged(MouseEvent e) { int x = e.getX(); int y = e.getY(); xMouse = offScreenX(x); yMouse = offScreenY(y); flags = e.getModifiers(); // IJ.log("mouseDragged: "+flags); if (flags == 0) // workaround for Mac OS 9 bug flags = InputEvent.BUTTON1_MASK; if (Toolbar.getToolId() == Toolbar.HAND || IJ.spaceBarDown()) scroll(x, y); else { IJ.setInputEvent(e); Roi roi = imp.getRoi(); if (roi != null) roi.handleMouseDrag(x, y, flags); } }
protected void handleRoiMouseDown(MouseEvent e) { int sx = e.getX(); int sy = e.getY(); int ox = offScreenX(sx); int oy = offScreenY(sy); Roi roi = imp.getRoi(); int handle = roi != null ? roi.isHandle(sx, sy) : -1; boolean multiPointMode = roi != null && (roi instanceof PointRoi) && handle == -1 && Toolbar.getToolId() == Toolbar.POINT && Toolbar.getMultiPointMode(); if (multiPointMode) { imp.setRoi(((PointRoi) roi).addPoint(ox, oy)); return; } setRoiModState(e, roi, handle); if (roi != null) { if (handle >= 0) { roi.mouseDownInHandle(handle, sx, sy); return; } Rectangle r = roi.getBounds(); int type = roi.getType(); if (type == Roi.RECTANGLE && r.width == imp.getWidth() && r.height == imp.getHeight() && roi.getPasteMode() == Roi.NOT_PASTING && !(roi instanceof ImageRoi)) { imp.killRoi(); return; } if (roi.contains(ox, oy)) { if (roi.modState == Roi.NO_MODS) roi.handleMouseDown(sx, sy); else { imp.killRoi(); imp.createNewRoi(sx, sy); } return; } if ((type == Roi.POLYGON || type == Roi.POLYLINE || type == Roi.ANGLE) && roi.getState() == roi.CONSTRUCTING) return; int tool = Toolbar.getToolId(); if ((tool == Toolbar.POLYGON || tool == Toolbar.POLYLINE || tool == Toolbar.ANGLE) && !(IJ.shiftKeyDown() || IJ.altKeyDown())) { imp.killRoi(); return; } } imp.createNewRoi(sx, sy); }
void drawRoi(Graphics g, Roi roi, int index) { int type = roi.getType(); ImagePlus imp2 = roi.getImage(); roi.setImage(imp); Color saveColor = roi.getStrokeColor(); if (saveColor == null) roi.setStrokeColor(defaultColor); if (roi instanceof TextRoi) ((TextRoi) roi).drawText(g); else roi.drawOverlay(g); roi.setStrokeColor(saveColor); if (index >= 0) { if (roi == currentRoi) g.setColor(Roi.getColor()); else g.setColor(defaultColor); drawRoiLabel(g, index, roi); } if (imp2 != null) roi.setImage(imp2); else roi.setImage(null); }
public void run(String arg) { imp = IJ.getImage(); Roi roi = imp.getRoi(); if (roi != null && !roi.isArea()) imp.killRoi(); // ignore any line selection ImageProcessor ip = imp.getProcessor(); if (!showDialog(ip)) return; if (ip.getWidth() > 1 && ip.getHeight() > 1) ip.setInterpolate(interpolate); else ip.setInterpolate(false); ip.setBackgroundValue(bgValue); imp.startTiming(); try { if (newWindow && imp.getStackSize() > 1 && processStack) createNewStack(imp, ip); else scale(ip); } catch (OutOfMemoryError o) { IJ.outOfMemory("Scale"); } IJ.showProgress(1.0); }
void enlargeCanvas() { imp.unlock(); if (imp.getStackSize() == 1) Undo.setup(Undo.COMPOUND_FILTER, imp); IJ.run("Select All"); IJ.run("Rotate...", "angle=" + angle); Roi roi = imp.getRoi(); Rectangle r = roi.getBounds(); if (r.width < imp.getWidth()) r.width = imp.getWidth(); if (r.height < imp.getHeight()) r.height = imp.getHeight(); IJ.showStatus("Rotate: Enlarging..."); IJ.run( "Canvas Size...", "width=" + r.width + " height=" + r.height + " position=Center " + (fillWithBackground ? "" : "zero")); IJ.showStatus("Rotating..."); }
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; }