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

Method showDialog

ij/src/main/java/ij/plugin/Duplicator.java:492–554  ·  view source on GitHub ↗
(ImagePlus imp, String dialogTitle, String prompt)

Source from the content-addressed store, hash-verified

490 }
491
492 String showDialog(ImagePlus imp, String dialogTitle, String prompt) {
493 int stackSize = imp.getStackSize();
494 String options = Macro.getOptions();
495 boolean isRoi = imp.getRoi()!=null;
496 boolean isMacro = options!=null;
497 duplicateStack = stackSize>1 && duplicateStack && !isMacro;
498 legacyMacro = options!=null && (options.contains("duplicate")||!options.contains("use"));
499 String title = getNewTitle();
500 if (title==null) title=defaultTitle;
501 GenericDialog gd = new GenericDialog(dialogTitle);
502 this.gd = gd;
503 gd.addStringField(prompt, title, 15);
504 if (isRoi)
505 gd.addCheckbox("Ignore selection", ignoreSelection);
506 if (stackSize>1) {
507 gd.addCheckbox("Duplicate stack", duplicateStack);
508 gd.setInsets(2, 30, 3);
509 gd.addStringField("Range:", "1-"+stackSize);
510 if (!isMacro) {
511 stackCheckbox = (Checkbox)(gd.getCheckboxes().elementAt(gd.getCheckboxes().size()-1));
512 stackCheckbox.addItemListener(this);
513 Vector v = gd.getStringFields();
514 titleField = (TextField)v.elementAt(0);
515 rangeField = (TextField)v.elementAt(1);
516 titleField.addTextListener(this);
517 rangeField.addTextListener(this);
518 }
519 }
520 gd.setSmartRecording(true);
521 gd.showDialog();
522 if (gd.wasCanceled())
523 return null;
524 title = gd.getNextString();
525 if (isRoi)
526 ignoreSelection = gd.getNextBoolean();
527 if (stackSize>1) {
528 duplicateStack = gd.getNextBoolean();
529 if (duplicateStack) {
530 String[] range = Tools.split(gd.getNextString(), " -");
531 double d1=1, d2=stackSize;
532 if (range!=null && range.length>0) {
533 d1 = gd.parseDouble(range[0]);
534 d2 = range.length==2?gd.parseDouble(range[1]):Double.NaN;
535 }
536 first = Double.isNaN(d1)?1:(int)d1;
537 last = Double.isNaN(d2)?stackSize:(int)d2;
538 if (first<1) first = 1;
539 if (last>stackSize) last = stackSize;
540 if (first>last) {first=1; last=stackSize;}
541 } else {
542 first = 1;
543 last = stackSize;
544 }
545 }
546 if (!isMacro) {
547 staticDuplicateStack = duplicateStack;
548 if (!ignoreNextSelection) staticIgnoreSelection=ignoreSelection;
549 }

Callers 1

runMethod · 0.95

Calls 15

getOptionsMethod · 0.95
getNewTitleMethod · 0.95
addStringFieldMethod · 0.95
addCheckboxMethod · 0.95
setInsetsMethod · 0.95
getCheckboxesMethod · 0.95
getStringFieldsMethod · 0.95
setSmartRecordingMethod · 0.95
showDialogMethod · 0.95
wasCanceledMethod · 0.95
getNextStringMethod · 0.95
getNextBooleanMethod · 0.95

Tested by

no test coverage detected