(String arg)
| 86 | private static boolean saveOutput = true; |
| 87 | |
| 88 | public void run(String arg) { |
| 89 | if (arg.equals("stack")) { |
| 90 | virtualStack = IJ.getImage(); |
| 91 | if (virtualStack.getStackSize()==1) { |
| 92 | error("This command requires a stack or virtual stack."); |
| 93 | return; |
| 94 | } |
| 95 | } |
| 96 | String macroPath = IJ.getDirectory("macros")+MACRO_FILE_NAME; |
| 97 | macro = IJ.openAsString(macroPath); |
| 98 | if (macro==null || macro.startsWith("Error: ")) { |
| 99 | IJ.showStatus(macro.substring(7) + ": "+macroPath); |
| 100 | macro = ""; |
| 101 | } |
| 102 | if (!showDialog()) return; |
| 103 | String inputPath = null; |
| 104 | if (virtualStack==null) { |
| 105 | inputPath = inputDir.getText(); |
| 106 | if (inputPath.equals("")) { |
| 107 | error("Please choose an input folder"); |
| 108 | return; |
| 109 | } |
| 110 | inputPath = addSeparator(inputPath); |
| 111 | File f1 = new File(inputPath); |
| 112 | if (!f1.exists() || !f1.isDirectory()) { |
| 113 | error("Input does not exist or is not a folder\n \n"+inputPath); |
| 114 | return; |
| 115 | } |
| 116 | } |
| 117 | String outputPath = outputDir.getText(); |
| 118 | outputPath = addSeparator(outputPath); |
| 119 | File f2 = new File(outputPath); |
| 120 | if (!outputPath.equals("") && (!f2.exists() || !f2.isDirectory())) { |
| 121 | error("Output does not exist or is not a folder\n \n"+outputPath); |
| 122 | return; |
| 123 | } |
| 124 | if (macro.equals("")) { |
| 125 | error("There is no macro code in the text area"); |
| 126 | return; |
| 127 | } |
| 128 | ImageJ ij = IJ.getInstance(); |
| 129 | if (ij!=null) ij.getProgressBar().setBatchMode(true); |
| 130 | IJ.resetEscape(); |
| 131 | if (virtualStack!=null) |
| 132 | processVirtualStack(outputPath); |
| 133 | else |
| 134 | processFolder(inputPath, outputPath); |
| 135 | IJ.showProgress(1,1); |
| 136 | if (virtualStack==null) |
| 137 | Prefs.set("batch.input", inputDir.getText()); |
| 138 | Prefs.set("batch.output", outputDir.getText()); |
| 139 | Prefs.set("batch.format", format); |
| 140 | macro = gd.getTextArea1().getText(); |
| 141 | if (!macro.equals("")) |
| 142 | IJ.saveString(macro, IJ.getDirectory("macros")+MACRO_FILE_NAME); |
| 143 | } |
| 144 | |
| 145 | boolean showDialog() { |
nothing calls this directly
no test coverage detected