1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
|
package ij.plugin.filter;
import ij.*;
import ij.process.*;
import ij.gui.*;
import ij.measure.Calibration;
import java.awt.*;
import java.awt.image.*;
/** Implements the Flip and Rotate commands in the Image/Transform submenu. */
public class Transformer implements PlugInFilter {
ImagePlus imp;
String arg;
public int setup(String arg, ImagePlus imp) {
this.arg = arg;
this.imp = imp;
if (arg.equals("fliph") || arg.equals("flipv"))
return IJ.setupDialog(imp, DOES_ALL+NO_UNDO);
else
return DOES_ALL+NO_UNDO+NO_CHANGES;
}
public void run(ImageProcessor ip) {
if (arg.equals("fliph")) {
ip.flipHorizontal();
return;
}
if (arg.equals("flipv")) {
ip.flipVertical();
return;
}
if (arg.equals("right") || arg.equals("left")) {
StackProcessor sp = new StackProcessor(imp.getStack(), ip);
ImageStack s2 = null;
if (arg.equals("right"))
s2 = sp.rotateRight();
else
s2 = sp.rotateLeft();
Calibration cal = imp.getCalibration();
imp.setStack(null, s2);
double pixelWidth = cal.pixelWidth;
cal.pixelWidth = cal.pixelHeight;
cal.pixelHeight = pixelWidth;
return;
}
}
}
|