Package gov.nih.mipav.model.scripting
Class ScriptRunner
java.lang.Object
gov.nih.mipav.model.scripting.ScriptRunner
Executes a script with a set of images.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate classA 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
FieldsModifier and TypeFieldDescriptionprotected ImageVariableTableThe table containing image-placeholder-to-image-name mappings for the script we want to run.protected booleanIndicates whether a script is currently being run by mipav.protected StringThe path to the script we want to execute.protected static ScriptRunnerThe reference to the only occurrance of this class.protected VOITableThe table containing VOIs to be used in the script. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidfillImageTable(Vector<String> imageNameList) Populate the image table based on a list of image names we want to use in the execution of the script.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 ScriptRunnerReturns a reference to the script recorder.Returns a reference to the VOI table being used to run the current script.protected voidHandle a script parser exception by printing out the location of the problem and stopping script execution.booleanReturns whether we are currently running a script.booleanExecute 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.storeImage(String imageName) Convenience method used to store the name of an image in the image table being used by the current script.
-
Field Details
-
singletonReference
The reference to the only occurrance of this class. -
imageTable
The table containing image-placeholder-to-image-name mappings for the script we want to run. -
isRunning
protected boolean isRunningIndicates whether a script is currently being run by mipav. -
scriptFile
The path to the script we want to execute. -
voiTable
The table containing VOIs to be used in the script.
-
-
Constructor Details
-
ScriptRunner
protected ScriptRunner()Creates a new ScriptRunner object.
-
-
Method Details
-
getReference
Returns a reference to the script recorder.- Returns:
- A reference to the script recorder.
-
getImage
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
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
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
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
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
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
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
Changes the image variable table for the current script execution.- Parameters:
table- A new image variable table.
-