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

Method replaceImageInWindow

Astronomy_/src/main/java/astroj/IJU.java:1196–1252  ·  view source on GitHub ↗
(ImagePlus imp, String imageName)

Source from the content-addressed store, hash-verified

1194 }
1195
1196 public static void replaceImageInWindow(ImagePlus imp, String imageName) {
1197 ImagePlus openImp = WindowManager.getImage(imageName);
1198 ImageProcessor ip = imp.getProcessor();
1199 Frame openFrame = null;
1200 Properties props;
1201 Enumeration<?> enProps;
1202 String key;
1203 FileInfo imf;
1204 if (openImp != null) {
1205 openFrame = WindowManager.getFrame(imageName);
1206
1207 imf = imp.getFileInfo();
1208 openImp.setFileInfo(imf);
1209
1210 //CLEAR PROPERTIES FROM OPENIMAGE
1211 props = openImp.getProperties();
1212 if (props != null) {
1213 enProps = props.propertyNames();
1214 key = "";
1215 while (enProps.hasMoreElements()) {
1216 key = (String) enProps.nextElement();
1217 openImp.setProperty(key, null);
1218 }
1219 }
1220 // COPY NEW PROPERTIES TO OPEN WINDOW IMAGEPLUS
1221 props = imp.getProperties();
1222 if (props != null) {
1223 enProps = props.propertyNames();
1224 key = "";
1225 while (enProps.hasMoreElements()) {
1226 key = (String) enProps.nextElement();
1227 openImp.setProperty(key, props.getProperty(key));
1228 }
1229 }
1230 if (imp.getType() == ImagePlus.COLOR_RGB) {
1231 imp.setDisplayRange(0, 255);
1232 ip.snapshot();
1233 }
1234 if (openFrame != null && openFrame instanceof astroj.AstroStackWindow) {
1235 astroj.AstroStackWindow asw = (astroj.AstroStackWindow) openFrame;
1236 asw.setUpdatesEnabled(false);
1237 IJ.wait(10);
1238 }
1239 openImp.setProcessor(ip);
1240 if (openFrame != null && openFrame instanceof astroj.AstroStackWindow) {
1241 astroj.AstroStackWindow asw = (astroj.AstroStackWindow) openFrame;
1242 asw.setUpdatesEnabled(true);
1243 asw.setAstroProcessor(true);
1244 }
1245 } else {
1246 imp.show();
1247 if (imp.getType() == ImagePlus.COLOR_RGB) {
1248 imp.setDisplayRange(0, 255);
1249 ip.snapshot();
1250 }
1251 }
1252 }
1253

Callers 6

createMasterBiasMethod · 0.95
createMasterDarkMethod · 0.95
createMasterFlatMethod · 0.95
loadMasterBiasFileMethod · 0.95
loadMasterDarkFileMethod · 0.95
loadMasterFlatFileMethod · 0.95

Calls 15

getImageMethod · 0.95
getFrameMethod · 0.95
setFileInfoMethod · 0.95
getPropertiesMethod · 0.95
setPropertyMethod · 0.95
snapshotMethod · 0.95
waitMethod · 0.95
setProcessorMethod · 0.95
setUpdatesEnabledMethod · 0.80
setAstroProcessorMethod · 0.80
getTypeMethod · 0.65
getProcessorMethod · 0.45

Tested by

no test coverage detected