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

Method run

ij/src/main/java/ij/plugin/Zoom.java:82–130  ·  view source on GitHub ↗
(String arg)

Source from the content-addressed store, hash-verified

80 }
81
82 public void run(String arg) {
83 ImagePlus imp = WindowManager.getCurrentImage();
84 if (imp==null) {
85 IJ.noImage();
86 return;
87 }
88 ImageCanvas ic = imp.getCanvas();
89 if (ic==null) return;
90 if (ic instanceof PlotCanvas && !((PlotCanvas)ic).isFrozen()) {
91 ((PlotCanvas)ic).zoom(arg);
92 return;
93 }
94 Point loc = ic.getCursorLoc();
95 if (!ic.cursorOverImage()) {
96 Rectangle srcRect = ic.getSrcRect();
97 loc.x = srcRect.x + srcRect.width/2;
98 loc.y = srcRect.y + srcRect.height/2;
99 }
100 int x = ic.screenX(loc.x);
101 int y = ic.screenY(loc.y);
102 if (arg.equals("in")) {
103 waitUntilActivated(imp);
104 ic.zoomIn(x, y);
105 if (ic.getMagnification()<=1.0)
106 imp.repaintWindow();
107 Recorder.recordCall("Zoom.in(imp);");
108 } else if (arg.equals("out")) {
109 waitUntilActivated(imp);
110 ic.zoomOut(x, y);
111 if (ic.getMagnification()<1.0)
112 imp.repaintWindow();
113 Recorder.recordCall("Zoom.out(imp);");
114 } else if (arg.equals("orig")) {
115 unzoom(imp);
116 Recorder.recordCall("Zoom.unzoom(imp);");
117 } else if (arg.equals("100%")) {
118 waitUntilActivated(imp);
119 ic.zoom100Percent();
120 } else if (arg.equals("to")) {
121 zoomToSelection(imp, ic);
122 Recorder.recordCall("Zoom.toSelection(imp);");
123 } else if (arg.equals("set")) {
124 setZoom(imp, -1, -1, -1);
125 } else if (arg.equals("max")) {
126 maximize(imp);
127 Recorder.recordCall("Zoom.maximize(imp);");
128 } else if (arg.equals("scale"))
129 scaleToFit(imp);
130 }
131
132 void zoomToSelection(ImagePlus imp, ImageCanvas ic) {
133 waitUntilActivated(imp);

Callers

nothing calls this directly

Calls 15

getCurrentImageMethod · 0.95
noImageMethod · 0.95
getCanvasMethod · 0.95
getCursorLocMethod · 0.95
cursorOverImageMethod · 0.95
getSrcRectMethod · 0.95
screenXMethod · 0.95
screenYMethod · 0.95
waitUntilActivatedMethod · 0.95
zoomInMethod · 0.95
getMagnificationMethod · 0.95
repaintWindowMethod · 0.95

Tested by

no test coverage detected