MCPcopy Create free account
hub / github.com/AstroImageJ/astroimagej / translate

Method translate

ij/src/main/java/ij/plugin/Selection.java:1097–1128  ·  view source on GitHub ↗
(ImagePlus imp)

Source from the content-addressed store, hash-verified

1095 }
1096
1097 private void translate(ImagePlus imp) {
1098 if (!imp.okToDeleteRoi())
1099 return;
1100 Roi roi = imp.getRoi();
1101 String options = Macro.getOptions();
1102 if (options!=null && options.contains("interpolation=")) {
1103 IJ.run("Translate...", options); // run Image>Transform>Translate
1104 return;
1105 }
1106 if (roi==null) {
1107 noRoi("Translate");
1108 return;
1109 }
1110 double dx = translateX;
1111 double dy = translateY;
1112 GenericDialog gd = new GenericDialog("Translate");
1113 gd.addNumericField("X offset (pixels): ", dx, 0);
1114 gd.addNumericField("Y offset (pixels): ", dy, 0);
1115 gd.showDialog();
1116 if (gd.wasCanceled())
1117 return;
1118 dx = gd.getNextNumber();
1119 dy = gd.getNextNumber();
1120 Rectangle2D r = roi.getFloatBounds();
1121 roi.setLocation(r.getX()+dx, r.getY()+dy);
1122 if (imp!=null)
1123 imp.draw();
1124 if (options==null) {
1125 translateX = dx;
1126 translateY = dy;
1127 }
1128 }
1129
1130 void noRoi(String command) {
1131 IJ.error(command, "This command requires a selection");

Callers 5

runMethod · 0.95
getProcessorMethod · 0.45
getProcessorMethod · 0.45
rotateShapeMethod · 0.45
scaleShapeMethod · 0.45

Calls 15

getOptionsMethod · 0.95
runMethod · 0.95
noRoiMethod · 0.95
addNumericFieldMethod · 0.95
showDialogMethod · 0.95
wasCanceledMethod · 0.95
getNextNumberMethod · 0.95
getFloatBoundsMethod · 0.95
setLocationMethod · 0.95
okToDeleteRoiMethod · 0.80
getXMethod · 0.65
getYMethod · 0.65

Tested by

no test coverage detected