(String arg)
| 25 | private static boolean rotateAroundImageCenter; |
| 26 | |
| 27 | public void run(String arg) { |
| 28 | ImagePlus imp = IJ.getImage(); |
| 29 | Roi roi = imp.getRoi(); |
| 30 | if (roi==null) { |
| 31 | IJ.error("Rotate", "This command requires a selection"); |
| 32 | return; |
| 33 | } |
| 34 | double angle = showDialog(defaultAngle); |
| 35 | if (Double.isNaN(angle)) |
| 36 | return; |
| 37 | if (!IJ.macroRunning()) |
| 38 | defaultAngle = angle; |
| 39 | FloatPolygon center = roi.getRotationCenter(); |
| 40 | double xcenter = center.xpoints[0]; |
| 41 | double ycenter = center.ypoints[0]; |
| 42 | if (rotateAroundImageCenter) { |
| 43 | xcenter = imp.getWidth()/2.0; |
| 44 | ycenter = imp.getHeight()/2.0; |
| 45 | } |
| 46 | Roi roi2 = rotate(roi, angle, xcenter, ycenter); |
| 47 | if (roi2==null && (roi instanceof ImageRoi)) |
| 48 | return; |
| 49 | if (!rotateAroundImageCenter) |
| 50 | roi2.setRotationCenter(xcenter,ycenter); |
| 51 | Undo.setup(Undo.ROI, imp); |
| 52 | roi = (Roi)roi.clone(); |
| 53 | imp.setRoi(roi2); |
| 54 | Roi.setPreviousRoi(roi); |
| 55 | } |
| 56 | |
| 57 | public double showDialog(double angle) { |
| 58 | GenericDialog gd = new GenericDialog("Rotate Selection"); |
nothing calls this directly
no test coverage detected