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

Method close

ij/src/main/java/ij/macro/Functions.java:3407–3587  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

3405 }
3406
3407 @AstroImageJ(reason = "Move interactions that need the EventQueue to that thread;" +
3408 "Remove from window manager immediately;" +
3409 "Support MeasurementsWindow;", modified = true)
3410 void close() {
3411 String pattern = null;
3412 boolean keep = false;
3413
3414 if (interp.nextToken() == '(') {
3415 interp.getLeftParen();
3416 if (interp.nextToken() != ')') {
3417 pattern = getString();
3418 }
3419 if (interp.nextToken() == ',') {
3420 interp.getComma();
3421 keep = getString().equalsIgnoreCase("keep");
3422 }
3423 interp.getRightParen();
3424 }
3425 if (pattern == null) {//Wayne close front image
3426 ImagePlus imp = getImage();
3427 ImageWindow win = imp.getWindow();
3428 if (win != null) {
3429 imp.changes = false;
3430 WindowManager.removeWindow(win);
3431 eventCallWait(win::close);
3432 } else {
3433 imp.saveRoi();
3434 WindowManager.setTempCurrentImage(null);
3435 interp.removeBatchModeImage(imp);
3436 }
3437 resetImage();
3438 return;
3439 }
3440
3441 if (pattern != null) {//Norbert
3442 if (pattern.equals("Results"))
3443 resultsPending = false;
3444 WildcardMatch wm = new WildcardMatch();
3445 wm.setCaseSensitive(false);
3446 String otherStr = "\\Others";
3447 boolean others = pattern.equals(otherStr);
3448 boolean hasWildcard = pattern.contains("*") || pattern.contains("?");
3449 if (!others) {
3450 //S c a n N o n - i m a g e s
3451 Window[] windows = WindowManager.getAllNonImageWindows();
3452 String[] textExtension = ".txt .ijm .js .java .py .bs .csv .tsv".split(" ");
3453 boolean isTextPattern = false;
3454 for (int jj = 0; jj < textExtension.length; jj++) {
3455 isTextPattern |= pattern.endsWith(textExtension[jj]);
3456 }
3457
3458 if (!hasWildcard || isTextPattern) {//e.g. "Roi Manager", "Demo*.txt")
3459 for (int win = 0; win < windows.length; win++) {
3460 Window thisWin = windows[win];
3461 if (thisWin instanceof ContrastAdjuster) {//B&C
3462 if (pattern.equalsIgnoreCase("b&c")) {
3463 WindowManager.removeWindow(thisWin);
3464 eventCallWait(() -> ((ContrastAdjuster) thisWin).close());

Callers 1

doFunctionMethod · 0.95

Calls 15

getStringMethod · 0.95
getImageMethod · 0.95
getWindowMethod · 0.95
removeWindowMethod · 0.95
eventCallWaitMethod · 0.95
saveRoiMethod · 0.95
setTempCurrentImageMethod · 0.95
resetImageMethod · 0.95
setCaseSensitiveMethod · 0.95
getAllNonImageWindowsMethod · 0.95
matchMethod · 0.95
fileChangedMethod · 0.95

Tested by

no test coverage detected