Skip to content

Commit bc0713d

Browse files
committed
Fix loading of IJ1 macros outside BAR/scrips
1 parent 6142122 commit bc0713d

File tree

3 files changed

+17
-3
lines changed

3 files changed

+17
-3
lines changed

BAR/src/main/java/bar/Runner.java

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,8 +203,22 @@ else if (fsm.isDone())
203203
* the argument string to be retrieved through the IJ1 built-in
204204
* macro function {@code getArgument()}
205205
*/
206+
public void runBARMacro(final String path, final String arg) {
207+
runIJ1Macro("scripts/BAR/" + path, arg);
208+
}
209+
210+
/**
211+
* Legacy method that supports IJ1 macros that do not use script parameters.
212+
* Ported from {@link Macro_Runner#runMacroFromJar(String, String)}.
213+
*
214+
* @param path
215+
* the path to the IJ1 macro in the BAR jar file
216+
* @param arg
217+
* the argument string to be retrieved through the IJ1 built-in
218+
* macro function {@code getArgument()}
219+
*/
206220
public void runIJ1Macro(final String path, final String arg) {
207-
final String macro = readContents("/scripts/" + path, true);
221+
final String macro = readContents(path, true);
208222
setStatus((macro == null) ? EXCEPTION : (new Macro_Runner()).runMacro(macro, arg));
209223
}
210224

BAR/src/main/resources/scripts/BAR/Analysis/Multichannel_ZT-axis_Profile.bsh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ void customRoutine(double[] values) {
6161
rt.setValue(colHeading, i, values[i]);
6262
rt.show("Results");
6363
runner = new Runner(context);
64-
runner.runIJ1Macro("BAR/Data_Analysis/Distribution_Plotter.ijm", colHeading);
64+
runner.runBARMacro("Data_Analysis/Distribution_Plotter.ijm", colHeading);
6565
if (!runner.scriptLoaded())
6666
uiService.showDialog("Profile distributions not plotted.\nCheck console for details", "Error");
6767
}

BAR/src/main/resources/scripts/BAR/Data_Analysis/NN_Distances.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
def plot_distributions():
1818
from bar import Runner
1919
runner = Runner(context)
20-
runner.runIJ1Macro("BAR/Data_Analysis/Distribution_Plotter.ijm", "NN distance")
20+
runner.runBARMacro("Data_Analysis/Distribution_Plotter.ijm", "NN distance")
2121
if not runner.scriptLoaded():
2222
uiService.showDialog("Distribution of NN distances not plotted.\n"
2323
+ "Check console for details", "Error")

0 commit comments

Comments
 (0)