Package gov.nih.mipav.model.scripting
Class ScriptRecorder
java.lang.Object
gov.nih.mipav.model.scripting.ScriptRecorder
A singleton class used to add lines to the script currently being recorded (if one is being recorded at all).
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected ImageVariableTableThe table containing image-placeholder-to-image-name mappings for the script we are currently recording.protected static final StringThe line separator to use for scripts.static final intStatus indicating that the script recorder is currently paused.protected intThe current status of the recorder, either PAUSED, RECORDING, or STOPPED.static final intStatus indicating that the script recorder is currently recording.protected VectorA list of listeners who want to know about lines added to the script.protected StringThe contents of the current script being recorded.protected static ScriptRecorderThe reference to the only occurrance of this class.static final String[]Strings describing the various recorder statuses.static final intStatus indicating that the script recorder is currently stopped (either never started, or recording is over). -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddCommentLine(String line) Appends a comment line to the current script (if one is being recorded).voidaddLine(ScriptableActionInterface scriptAction) Add a line to the current script by requesting a script action to generate its script line.voidaddLine(String action, ParameterTable parameterList) Appends a line of text to the current script (if one is being recorded) using a script action and list of parameters.voidAdds a class to the recorder's list of listeners.Returns a reference to the image table being used to run the current script.intReturns the current status of the script recorder.static final ScriptRecorderReturns a reference to the script recorder.Returns the current script.protected voidNotifies any ScriptRecorderListeners of the current script text, after it has changed in some manner.protected voidNotifies any ScriptRecorderListeners of the current recording status of the script recorder.voidPauses the recording of the script we are currently recording.voidRemoves a listener from the recorder.voidErases the current script.protected voidsetRecorderStatus(int status) Changes the current status of the script recorder and notifies any recorder listeners of the change.voidChanges the script being recorded by this class.booleanStarts the recording of a new script (if one isn't already being recorded).voidStops script recording.storeImage(String imageName) Convenience method used to store the name of an image in the image table being recorded/used in the current script.
-
Field Details
-
LINE_SEPARATOR
The line separator to use for scripts.- See Also:
-
singletonReference
The reference to the only occurrance of this class. -
PAUSED
public static final int PAUSEDStatus indicating that the script recorder is currently paused.- See Also:
-
RECORDING
public static final int RECORDINGStatus indicating that the script recorder is currently recording.- See Also:
-
STOPPED
public static final int STOPPEDStatus indicating that the script recorder is currently stopped (either never started, or recording is over).- See Also:
-
statusStrings
Strings describing the various recorder statuses. -
script
The contents of the current script being recorded. -
recorderStatus
protected int recorderStatusThe current status of the recorder, either PAUSED, RECORDING, or STOPPED. -
recordingListeners
A list of listeners who want to know about lines added to the script. -
imageTable
The table containing image-placeholder-to-image-name mappings for the script we are currently recording.
-
-
Constructor Details
-
ScriptRecorder
protected ScriptRecorder()Creates a new ScriptRecorder object. May only be called bygetReference()since this is a singleton class.
-
-
Method Details
-
getReference
Returns a reference to the script recorder.- Returns:
- A reference to the script recorder.
-
addLine
Add a line to the current script by requesting a script action to generate its script line.- Parameters:
scriptAction- The script action to add to the current script we are recording.
-
addCommentLine
Appends a comment line to the current script (if one is being recorded).- Parameters:
line- A comment to be added to the script (should not include an end-line character).
-
addLine
Appends a line of text to the current script (if one is being recorded) using a script action and list of parameters.- Parameters:
action- The action to put into the new script line.parameterList- The list of parameters to include in the new script line.
-
resetScript
public void resetScript()Erases the current script. -
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.
-
getScript
Returns the current script.- Returns:
- The script being recorded.
-
getRecorderStatus
public int getRecorderStatus()Returns the current status of the script recorder.- Returns:
- Either PAUSED, RECORDING, or STOPPED.
-
setRecorderStatus
protected void setRecorderStatus(int status) Changes the current status of the script recorder and notifies any recorder listeners of the change.- Parameters:
status- The new status for the script recorder.
-
setScript
Changes the script being recorded by this class. Used by the script recorder dialog to read in a script from disk or allow the user to manually edit the script.- Parameters:
newScript- The new script text.
-
startRecording
public boolean startRecording()Starts the recording of a new script (if one isn't already being recorded). Any script text which was previously recorded and stored in the recorder is erased (unless we are resuming from a recorder pause).- Returns:
Trueif recording was started successfully,falseotherwise.
-
pauseRecording
public void pauseRecording()Pauses the recording of the script we are currently recording. -
stopRecording
public void stopRecording()Stops script recording. CallgetScript()to get the recorded script. -
storeImage
Convenience method used to store the name of an image in the image table being recorded/used in 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).
-
addScriptRecordingListener
Adds a class to the recorder's list of listeners.- Parameters:
listener- A class which wants to be notified about changes in the recorder's status and script text.
-
removeScriptRecordingListener
Removes a listener from the recorder.- Parameters:
listener- A class which no longer wants to know about changes in the recorder's state.
-
notifyListenersOfScriptChange
protected void notifyListenersOfScriptChange()Notifies any ScriptRecorderListeners of the current script text, after it has changed in some manner. -
notifyListenersOfScriptStatus
protected void notifyListenersOfScriptStatus()Notifies any ScriptRecorderListeners of the current recording status of the script recorder.
-