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

Method showHSDialog

ij/src/main/java/ij/plugin/Duplicator.java:609–688  ·  view source on GitHub ↗
(ImagePlus imp, String newTitle)

Source from the content-addressed store, hash-verified

607 }
608
609 String showHSDialog(ImagePlus imp, String newTitle) {
610 int nChannels = imp.getNChannels();
611 int nSlices = imp.getNSlices();
612 int nFrames = imp.getNFrames();
613 boolean composite = imp.isComposite() && nChannels==imp.getStackSize();
614 String options = Macro.getOptions();
615 boolean isMacro = options!=null;
616 GenericDialog gd = new GenericDialog("Duplicate");
617 gd.addStringField("Title:", newTitle, 15);
618 gd.setInsets(12, 20, 8);
619 gd.addCheckbox("Duplicate hyperstack", (duplicateStack&&!isMacro)||composite);
620 int nRangeFields = 0;
621 if (nChannels>1) {
622 gd.setInsets(2, 30, 3);
623 gd.addStringField("Channels (c):", "1-"+nChannels);
624 nRangeFields++;
625 }
626 if (nSlices>1) {
627 gd.setInsets(2, 30, 3);
628 gd.addStringField("Slices (z):", "1-"+nSlices);
629 nRangeFields++;
630 }
631 if (nFrames>1) {
632 gd.setInsets(2, 30, 3);
633 gd.addStringField("Frames (t):", "1-"+nFrames);
634 nRangeFields++;
635 }
636 if (!isMacro) {
637 stackCheckbox = (Checkbox)(gd.getCheckboxes().elementAt(gd.getCheckboxes().size()-1));
638 stackCheckbox.addItemListener(this);
639 Vector v = gd.getStringFields();
640 rangeFields = new TextField[3];
641 for (int i=0; i<nRangeFields; i++) {
642 rangeFields[i] = (TextField)v.elementAt(i+1);
643 rangeFields[i].addTextListener(this);
644 }
645 }
646 gd.setSmartRecording(true);
647 gd.showDialog();
648 if (gd.wasCanceled())
649 return null;
650 newTitle = gd.getNextString();
651 duplicateStack = gd.getNextBoolean();
652 if (nChannels>1) {
653 String[] range = Tools.split(gd.getNextString(), " -");
654 double c1 = gd.parseDouble(range[0]);
655 double c2 = range.length==2?gd.parseDouble(range[1]):Double.NaN;
656 firstC = Double.isNaN(c1)?1:(int)c1;
657 lastC = Double.isNaN(c2)?firstC:(int)c2;
658 if (firstC<1) firstC = 1;
659 if (lastC>nChannels) lastC = nChannels;
660 if (firstC>lastC) {firstC=1; lastC=nChannels;}
661 } else
662 firstC = lastC = 1;
663 if (nSlices>1) {
664 String[] range = Tools.split(gd.getNextString(), " -");
665 double z1 = gd.parseDouble(range[0]);
666 double z2 = range.length==2?gd.parseDouble(range[1]):Double.NaN;

Callers 1

duplicateHyperstackMethod · 0.95

Calls 15

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

Tested by

no test coverage detected