Package gov.nih.mipav.model.scripting
Class ScriptRunner
- java.lang.Object
-
- gov.nih.mipav.model.scripting.ScriptRunner
-
public class ScriptRunner extends java.lang.ObjectExecutes a script with a set of images.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private classScriptRunner.ScriptThreadA 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 protected ImageVariableTableimageTableThe table containing image-placeholder-to-image-name mappings for the script we want to run.protected booleanisRunningIndicates whether a script is currently being run by mipav.protected java.lang.StringscriptFileThe path to the script we want to execute.protected static ScriptRunnersingletonReferenceThe reference to the only occurrance of this class.protected VOITablevoiTableThe table containing VOIs to be used in the script.
-
Constructor Summary
Constructors Modifier Constructor Description protectedScriptRunner()Creates a new ScriptRunner object.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidfillImageTable(java.util.Vector<java.lang.String> imageNameList)Populate the image table based on a list of image names we want to use in the execution of the script.ModelImagegetImage(java.lang.String imageVar)Retrieves an image from the image table being used by the current script we are running.ImageVariableTablegetImageTable()Returns a reference to the image table being used to run the current script.static ScriptRunnergetReference()Returns a reference to the script recorder.VOITablegetVOITable()Returns a reference to the VOI table being used to run the current script.protected voidhandleParserException(ParserException pe)Handle a script parser exception by printing out the location of the problem and stopping script execution.booleanisRunning()Returns whether we are currently running a script.booleanrunScript(java.lang.String file, java.util.Vector<java.lang.String> imageNameList, java.util.Vector<java.lang.String> voiPathList)Execute a script, using a set of images.voidsetImageTable(ImageVariableTable table)Changes the image variable table for the current script execution.voidsetRunning(boolean running)Changes the flag indicating whether a script is currently being run.java.lang.StringstoreImage(java.lang.String imageName)Convenience method used to store the name of an image in the image table being used by the current script.
-
-
-
Field Detail
-
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 java.lang.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.
-
-
Method Detail
-
getReference
public static final ScriptRunner getReference()
Returns a reference to the script recorder.- Returns:
- A reference to the script recorder.
-
getImage
public ModelImage getImage(java.lang.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
nullif 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
nullif no script is being run at the moment.
-
isRunning
public boolean isRunning()
Returns whether we are currently running a script.- Returns:
Trueif a script is being run,falseotherwise.
-
runScript
public boolean runScript(java.lang.String file, java.util.Vector<java.lang.String> imageNameList, java.util.Vector<java.lang.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:
Trueif execution of the script was successful,falseotherwise.
-
storeImage
public java.lang.String storeImage(java.lang.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(java.util.Vector<java.lang.String> imageNameList) throws ParserExceptionPopulate 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.
-
-