Module ij
Package ij.plugin

Class Macro_Runner

java.lang.Object
ij.plugin.Macro_Runner
All Implemented Interfaces:
PlugIn

public class Macro_Runner
extends java.lang.Object
implements PlugIn
This class runs macros and scripts installed in the Plugins menu as well as macros and scripts opened using the Plugins/Macros/Run command.
  • Constructor Summary

    Constructors 
    Constructor Description
    Macro_Runner()  
  • Method Summary

    Modifier and Type Method Description
    static boolean downloadJar​(java.lang.String url)  
    static java.lang.String getFilePath()
    Returns the file path of the most recently loaded macro or script.
    void run​(java.lang.String name)
    Opens and runs the specified macro file (.txt or .ijm) or script file (.js, .bsh or .py) on the current thread.
    static java.lang.String runBeanShell​(java.lang.String script, java.lang.String arg)
    Runs a BeanShell script on the current thread, passing a string argument, which the script can retrieve using the getArgument() function.
    java.lang.String runJavaScript​(java.lang.String script, java.lang.String arg)
    Runs a JavaScript script on the current thread, passing a string argument, which the script can retrieve using the getArgument() function.
    java.lang.String runMacro​(java.lang.String macro, java.lang.String arg)
    Runs the specified macro on the current thread.
    java.lang.String runMacroFile​(java.lang.String name, java.lang.String arg)
    Opens and runs the specified macro or script on the current thread.
    java.lang.String runMacroFromIJJar​(java.lang.String name, java.lang.String arg)  
    static java.lang.String runMacroFromJar​(java.lang.String name, java.lang.String arg)
    Runs the specified macro from a JAR file in the plugins folder, passing it the specified argument.
    static java.lang.String runPython​(java.lang.String script, java.lang.String arg)
    Runs a Python script on the current thread, passing a string argument, which the script can retrieve using the getArgument() function.
    static void setFilePath​(java.lang.String path)  

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

  • Method Details

    • run

      public void run​(java.lang.String name)
      Opens and runs the specified macro file (.txt or .ijm) or script file (.js, .bsh or .py) on the current thread. Displays a file open dialog if name is an empty string. The macro or script is assumed to be in the ImageJ plugins folder if name is not a full path.
      Specified by:
      run in interface PlugIn
    • runMacroFile

      public java.lang.String runMacroFile​(java.lang.String name, java.lang.String arg)
      Opens and runs the specified macro or script on the current thread. The file is assumed to be in the ImageJ/macros folder unless 'name' is a full path. The macro or script can use the getArgument() function to retrieve the string argument.
    • runMacro

      public java.lang.String runMacro​(java.lang.String macro, java.lang.String arg)
      Runs the specified macro on the current thread. Macros can retrieve the optional string argument by calling the getArgument() macro function. Returns the string value returned by the macro, null if the macro does not return a value, or "[aborted]" if the macro was aborted due to an error.
    • runMacroFromJar

      public static java.lang.String runMacroFromJar​(java.lang.String name, java.lang.String arg)
      Runs the specified macro from a JAR file in the plugins folder, passing it the specified argument. Returns the String value returned by the macro, null if the macro does not return a value, or "[aborted]" if the macro was aborted due to an error. The macro can reside anywhere in the plugins folder, in or out of a JAR file, so name conflicts are possible. To avoid name conflicts, it is a good idea to incorporate the plugin or JAR file name in the macro name (e.g., "Image_5D_Macro1.ijm").
    • runMacroFromIJJar

      public java.lang.String runMacroFromIJJar​(java.lang.String name, java.lang.String arg)
    • runJavaScript

      public java.lang.String runJavaScript​(java.lang.String script, java.lang.String arg)
      Runs a JavaScript script on the current thread, passing a string argument, which the script can retrieve using the getArgument() function. Returns, as a string, the last expression evaluated by the script.
    • runBeanShell

      public static java.lang.String runBeanShell​(java.lang.String script, java.lang.String arg)
      Runs a BeanShell script on the current thread, passing a string argument, which the script can retrieve using the getArgument() function. Returns, as a string, the last expression evaluated by the script. Uses the plugin at http://imagej.nih.gov/ij/plugins/bsh/ to run the script.
    • runPython

      public static java.lang.String runPython​(java.lang.String script, java.lang.String arg)
      Runs a Python script on the current thread, passing a string argument, which the script can retrieve using the getArgument() function. Returns, as a string, the value of the variable 'result'. For example, a Python script containing the line "result=123" will return the string "123". Uses the plugin at http://imagej.nih.gov/ij/plugins/jython/ to run the script.
    • downloadJar

      public static boolean downloadJar​(java.lang.String url)
    • getFilePath

      public static java.lang.String getFilePath()
      Returns the file path of the most recently loaded macro or script.
    • setFilePath

      public static void setFilePath​(java.lang.String path)