(String arg)
| 41 | private ImagePlus outputImage; |
| 42 | |
| 43 | public void run(String arg) { |
| 44 | if (arg.equals("stack")) { |
| 45 | virtualStack = IJ.getImage(); |
| 46 | if (virtualStack.getStackSize()==1) { |
| 47 | error("This command requires a stack or virtual stack."); |
| 48 | return; |
| 49 | } |
| 50 | } |
| 51 | String macroPath = IJ.getDirectory("macros")+MACRO_FILE_NAME; |
| 52 | macro = IJ.openAsString(macroPath); |
| 53 | if (macro==null || macro.startsWith("Error: ")) { |
| 54 | IJ.showStatus(macro.substring(7) + ": "+macroPath); |
| 55 | macro = ""; |
| 56 | } |
| 57 | if (!showDialog()) return; |
| 58 | String inputPath = null; |
| 59 | if (virtualStack==null) { |
| 60 | inputPath = inputDir.getText(); |
| 61 | if (inputPath.equals("")) { |
| 62 | error("Please choose an input folder"); |
| 63 | return; |
| 64 | } |
| 65 | inputPath = addSeparator(inputPath); |
| 66 | File f1 = new File(inputPath); |
| 67 | if (!f1.exists() || !f1.isDirectory()) { |
| 68 | error("Input does not exist or is not a folder\n \n"+inputPath); |
| 69 | return; |
| 70 | } |
| 71 | } |
| 72 | String outputPath = outputDir.getText(); |
| 73 | outputPath = addSeparator(outputPath); |
| 74 | File f2 = new File(outputPath); |
| 75 | if (!outputPath.equals("") && (!f2.exists() || !f2.isDirectory())) { |
| 76 | error("Output does not exist or is not a folder\n \n"+outputPath); |
| 77 | return; |
| 78 | } |
| 79 | if (macro.equals("")) { |
| 80 | error("There is no macro code in the text area"); |
| 81 | return; |
| 82 | } |
| 83 | ImageJ ij = IJ.getInstance(); |
| 84 | if (ij!=null) ij.getProgressBar().setBatchMode(true); |
| 85 | IJ.resetEscape(); |
| 86 | if (virtualStack!=null) |
| 87 | processVirtualStack(outputPath); |
| 88 | else |
| 89 | processFolder(inputPath, outputPath); |
| 90 | IJ.showProgress(1,1); |
| 91 | if (virtualStack==null) |
| 92 | Prefs.set("batch.input", inputDir.getText()); |
| 93 | Prefs.set("batch.output", outputDir.getText()); |
| 94 | Prefs.set("batch.format", format); |
| 95 | macro = gd.getTextArea1().getText(); |
| 96 | if (!macro.equals("")) |
| 97 | IJ.saveString(macro, IJ.getDirectory("macros")+MACRO_FILE_NAME); |
| 98 | } |
| 99 | |
| 100 | boolean showDialog() { |
nothing calls this directly
no test coverage detected