void drawOutline(ImageProcessor ip, Roi roi, int count) { if (showChoice == OVERLAY_OUTLINES || showChoice == OVERLAY_MASKS) { if (overlay == null) { overlay = new Overlay(); overlay.drawLabels(true); overlay.setLabelFont(new Font("SansSerif", Font.PLAIN, fontSize)); } Roi roi2 = (Roi) roi.clone(); roi2.setStrokeColor(Color.cyan); if (lineWidth != 1) roi2.setStrokeWidth(lineWidth); if (showChoice == OVERLAY_MASKS) roi2.setFillColor(Color.cyan); overlay.add(roi2); } else { Rectangle r = roi.getBounds(); int nPoints = ((PolygonRoi) roi).getNCoordinates(); int[] xp = ((PolygonRoi) roi).getXCoordinates(); int[] yp = ((PolygonRoi) roi).getYCoordinates(); int x = r.x, y = r.y; if (!inSituShow) ip.setValue(0.0); ip.moveTo(x + xp[0], y + yp[0]); for (int i = 1; i < nPoints; i++) ip.lineTo(x + xp[i], y + yp[i]); ip.lineTo(x + xp[0], y + yp[0]); if (showChoice != BARE_OUTLINES) { String s = ResultsTable.d2s(count, 0); ip.moveTo(r.x + r.width / 2 - ip.getStringWidth(s) / 2, r.y + r.height / 2 + fontSize / 2); if (!inSituShow) ip.setValue(1.0); ip.drawString(s); } } }
/** * 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(); }