Class ScriptRunner

java.lang.Object
gov.nih.mipav.model.scripting.ScriptRunner

public class ScriptRunner extends Object
Executes a script with a set of images.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    private class 
    A separate thread used to execute a given script (the image and voi table should already be set up before the thread is started).
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    The table containing image-placeholder-to-image-name mappings for the script we want to run.
    protected boolean
    Indicates whether a script is currently being run by mipav.
    protected String
    The path to the script we want to execute.
    protected static ScriptRunner
    The reference to the only occurrance of this class.
    protected VOITable
    The table containing VOIs to be used in the script.
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    Creates a new ScriptRunner object.
  • Method Summary

    Modifier and Type
    Method
    Description
    protected void
    fillImageTable(Vector<String> imageNameList)
    Populate the image table based on a list of image names we want to use in the execution of the script.
    getImage(String imageVar)
    Retrieves an image from the image table being used by the current script we are running.
    Returns a reference to the image table being used to run the current script.
    static final ScriptRunner
    Returns a reference to the script recorder.
    Returns a reference to the VOI table being used to run the current script.
    protected void
    Handle a script parser exception by printing out the location of the problem and stopping script execution.
    boolean
    Returns whether we are currently running a script.
    boolean
    runScript(String file, Vector<String> imageNameList, Vector<String> voiPathList)
    Execute a script, using a set of images.
    void
    Changes the image variable table for the current script execution.
    void
    setRunning(boolean running)
    Changes the flag indicating whether a script is currently being run.
    storeImage(String imageName)
    Convenience method used to store the name of an image in the image table being used by the current script.

    Methods inherited from class java.lang.Object

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

    • singletonReference

      protected static ScriptRunner singletonReference
      The reference to the only occurrance of this class.
    • imageTable

      protected ImageVariableTable imageTable
      The table containing image-placeholder-to-image-name mappings for the script we want to run.
    • isRunning

      protected boolean isRunning
      Indicates whether a script is currently being run by mipav.
    • scriptFile

      protected String scriptFile
      The path to the script we want to execute.
    • voiTable

      protected VOITable voiTable
      The table containing VOIs to be used in the script.
  • Constructor Details

    • ScriptRunner

      protected ScriptRunner()
      Creates a new ScriptRunner object.
  • Method Details

    • getReference

      public static final ScriptRunner getReference()
      Returns a reference to the script recorder.
      Returns:
      A reference to the script recorder.
    • getImage

      public ModelImage getImage(String imageVar)
      Retrieves an image from the image table being used by the current script we are running.
      Parameters:
      imageVar - The image placeholder variable associated with the image we want.
      Returns:
      The image associated with the given image variable.
    • getImageTable

      public ImageVariableTable getImageTable()
      Returns a reference to the image table being used to run the current script.
      Returns:
      The image table which should be used to run the current script, or null if no script is being run at the moment.
    • getVOITable

      public VOITable getVOITable()
      Returns a reference to the VOI table being used to run the current script.
      Returns:
      The VOI table which should be used to run the current script, or null if no script is being run at the moment.
    • isRunning

      public boolean isRunning()
      Returns whether we are currently running a script.
      Returns:
      True if a script is being run, false otherwise.
    • runScript

      public boolean runScript(String file, Vector<String> imageNameList, Vector<String> voiPathList)
      Execute a script, using a set of images.
      Parameters:
      file - The path to the script file we want to run.
      imageNameList - The list of the names of images to use while executing the script.
      voiPathList - A list of VOI paths, in the order returned by Parser.getImageVarsUsedInScript().
      Returns:
      True if execution of the script was successful, false otherwise.
    • storeImage

      public String storeImage(String imageName)
      Convenience method used to store the name of an image in the image table being used by the current script.
      Parameters:
      imageName - The name of the image to store.
      Returns:
      The image variable placeholder which has been assigned to the image name (may not be a new variable if the name is already in the table).
    • fillImageTable

      protected void fillImageTable(Vector<String> imageNameList) throws ParserException
      Populate the image table based on a list of image names we want to use in the execution of the script.
      Parameters:
      imageNameList - A list of image names, in the order they should be used in the script.
      Throws:
      ParserException - If there is a problem encountered while reading the image variables used in the script.
    • handleParserException

      protected void handleParserException(ParserException pe)
      Handle a script parser exception by printing out the location of the problem and stopping script execution.
      Parameters:
      pe - The parser exception to handle.
    • setRunning

      public void setRunning(boolean running)
      Changes the flag indicating whether a script is currently being run.
      Parameters:
      running - Whether we are running a script.
    • setImageTable

      public void setImageTable(ImageVariableTable table)
      Changes the image variable table for the current script execution.
      Parameters:
      table - A new image variable table.