(String arg)
| 14 | private static int x, y; |
| 15 | |
| 16 | public void run(String arg) { |
| 17 | int[] wList = WindowManager.getIDList(); |
| 18 | if (wList==null) { |
| 19 | IJ.showMessage("Stack Inserter", "No windows are open."); |
| 20 | return; |
| 21 | } |
| 22 | if (wList.length==1) { |
| 23 | IJ.showMessage("Stack Inserter", "At least two windows must be open."); |
| 24 | return; |
| 25 | } |
| 26 | String[] titles = new String[wList.length]; |
| 27 | for (int i=0; i<wList.length; i++) { |
| 28 | ImagePlus imp = WindowManager.getImage(wList[i]); |
| 29 | if (imp!=null) |
| 30 | titles[i] = imp.getTitle(); |
| 31 | else |
| 32 | titles[i] = ""; |
| 33 | } |
| 34 | if (index1>=titles.length)index1 = 0; |
| 35 | if (index2>=titles.length)index2 = 0; |
| 36 | GenericDialog gd = new GenericDialog("Stack Inserter"); |
| 37 | gd.addChoice("Source: ", titles, titles[index1]); |
| 38 | gd.addChoice("Destination: ", titles, titles[index2]); |
| 39 | gd.addNumericField("X Location: ", 0, 0); |
| 40 | gd.addNumericField("Y Location: ", 0, 0); |
| 41 | gd.showDialog(); |
| 42 | if (gd.wasCanceled()) |
| 43 | return; |
| 44 | index1 = gd.getNextChoiceIndex(); |
| 45 | index2 = gd.getNextChoiceIndex(); |
| 46 | x = (int)gd.getNextNumber(); |
| 47 | y = (int)gd.getNextNumber(); |
| 48 | String title1 = titles[index1]; |
| 49 | String title2 = titles[index2]; |
| 50 | ImagePlus imp1 = WindowManager.getImage(wList[index1]); |
| 51 | ImagePlus imp2 = WindowManager.getImage(wList[index2]); |
| 52 | if (imp1.getType()!= imp2.getType()) { |
| 53 | IJ.showMessage("Stack Inserter", "The source and destination must be the same type."); |
| 54 | return; |
| 55 | } |
| 56 | if (imp1== imp2) { |
| 57 | IJ.showMessage("Stack Inserter", "The source and destination must be different."); |
| 58 | return; |
| 59 | } |
| 60 | insert(imp1, imp2, x, y); |
| 61 | } |
| 62 | |
| 63 | public void insert(ImagePlus imp1, ImagePlus imp2, int x, int y) { |
| 64 | ImageStack stack1 = imp1.getStack(); |
nothing calls this directly
no test coverage detected