void interpolate() {
   Roi roi = imp.getRoi();
   if (roi == null) {
     noRoi("Interpolate");
     return;
   }
   if (roi.getType() == Roi.POINT) return;
   if (IJ.isMacro() && Macro.getOptions() == null) Macro.setOptions("interval=1");
   GenericDialog gd = new GenericDialog("Interpolate");
   gd.addNumericField("Interval:", 1.0, 1, 4, "pixel");
   gd.addCheckbox("Smooth", IJ.isMacro() ? false : smooth);
   gd.showDialog();
   if (gd.wasCanceled()) return;
   double interval = gd.getNextNumber();
   smooth = gd.getNextBoolean();
   Undo.setup(Undo.ROI, imp);
   FloatPolygon poly = roi.getInterpolatedPolygon(interval, smooth);
   int t = roi.getType();
   int type = roi.isLine() ? Roi.FREELINE : Roi.FREEROI;
   if (t == Roi.POLYGON && interval > 1.0) type = Roi.POLYGON;
   if ((t == Roi.RECTANGLE || t == Roi.OVAL || t == Roi.FREEROI) && interval >= 5.0)
     type = Roi.POLYGON;
   if ((t == Roi.LINE || t == Roi.FREELINE) && interval >= 5.0) type = Roi.POLYLINE;
   if (t == Roi.POLYLINE && interval >= 1.0) type = Roi.POLYLINE;
   ImageCanvas ic = imp.getCanvas();
   if (poly.npoints <= 150 && ic != null && ic.getMagnification() >= 12.0)
     type = roi.isLine() ? Roi.POLYLINE : Roi.POLYGON;
   Roi p = new PolygonRoi(poly, type);
   if (roi.getStroke() != null) p.setStrokeWidth(roi.getStrokeWidth());
   p.setStrokeColor(roi.getStrokeColor());
   p.setName(roi.getName());
   transferProperties(roi, p);
   imp.setRoi(p);
 }
Beispiel #2
0
 void checkForCalibrationConflict(ImagePlus imp, Calibration cal) {
   Calibration gcal = imp.getGlobalCalibration();
   if (gcal == null || !showConflictMessage || IJ.isMacro()) return;
   if (cal.pixelWidth == gcal.pixelWidth && cal.getUnit().equals(gcal.getUnit())) return;
   GenericDialog gd = new GenericDialog(imp.getTitle());
   gd.addMessage("The calibration of this image conflicts\nwith the current global calibration.");
   gd.addCheckbox("Disable_Global Calibration", true);
   gd.addCheckbox("Disable_these Messages", false);
   gd.showDialog();
   if (gd.wasCanceled()) return;
   boolean disable = gd.getNextBoolean();
   if (disable) {
     imp.setGlobalCalibration(null);
     imp.setCalibration(cal);
     WindowManager.repaintImageWindows();
   }
   boolean dontShow = gd.getNextBoolean();
   if (dontShow) showConflictMessage = false;
 }