(ImagePlus imp, String imageName)
| 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 |
no test coverage detected