Squiz Matrix  4.12.2
 All Data Structures Namespaces Functions Variables Pages
Rotator.java
1 package ij.plugin.filter;
2 import ij.*;
3 import ij.gui.*;
4 import ij.process.*;
5 import java.awt.*;
6 
8 public class Rotator implements PlugInFilter {
9  private static double angle = 15.0;
10  private static boolean interpolate = true;
11  private static boolean firstTime;
12  private static boolean canceled;
13  private ImagePlus imp;
14 
15  public int setup(String arg, ImagePlus imp) {
16  this.imp = imp;
17  IJ.register(Rotator.class);
18  firstTime = true;
19  canceled = false;
20  return IJ.setupDialog(imp, DOES_ALL);
21  }
22 
23  public void run(ImageProcessor ip) {
24  if (canceled)
25  return;
26  if (firstTime) {
27  GenericDialog gd = new GenericDialog("Rotate", IJ.getInstance());
28  gd.addNumericField("Angle (degrees): ", angle, 1);
29  gd.addCheckbox("Interpolate", interpolate);
30  gd.showDialog();
31  canceled = gd.wasCanceled();
32  if (canceled)
33  return;
34  angle = gd.getNextNumber();
35  if (gd.invalidNumber()) {
36  IJ.error("Angle is invalid.");
37  return;
38  }
39  interpolate = gd.getNextBoolean();
40  imp.startTiming();
41  firstTime = false;
42  }
43  ip.setInterpolate(interpolate);
44  ip.rotate(angle);
45  }
46 
47 }