Class ScriptRecorder

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

public class ScriptRecorder extends Object
A singleton class used to add lines to the script currently being recorded (if one is being recorded at all).
  • Field Details

    • LINE_SEPARATOR

      protected static final String LINE_SEPARATOR
      The line separator to use for scripts.
      See Also:
    • singletonReference

      protected static ScriptRecorder singletonReference
      The reference to the only occurrance of this class.
    • PAUSED

      public static final int PAUSED
      Status indicating that the script recorder is currently paused.
      See Also:
    • RECORDING

      public static final int RECORDING
      Status indicating that the script recorder is currently recording.
      See Also:
    • STOPPED

      public static final int STOPPED
      Status indicating that the script recorder is currently stopped (either never started, or recording is over).
      See Also:
    • statusStrings

      public static final String[] statusStrings
      Strings describing the various recorder statuses.
    • script

      protected String script
      The contents of the current script being recorded.
    • recorderStatus

      protected int recorderStatus
      The current status of the recorder, either PAUSED, RECORDING, or STOPPED.
    • recordingListeners

      protected Vector recordingListeners
      A list of listeners who want to know about lines added to the script.
    • imageTable

      protected ImageVariableTable 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 by getReference() since this is a singleton class.
  • Method Details

    • getReference

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

      public void addLine(ScriptableActionInterface scriptAction)
      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

      public void addCommentLine(String line)
      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

      public void addLine(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.
      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

      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.
    • getScript

      public String 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

      public void setScript(String newScript)
      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:
      True if recording was started successfully, false otherwise.
    • pauseRecording

      public void pauseRecording()
      Pauses the recording of the script we are currently recording.
    • stopRecording

      public void stopRecording()
      Stops script recording. Call getScript() to get the recorded script.
    • storeImage

      public String storeImage(String imageName)
      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

      public void addScriptRecordingListener(ScriptRecordingListener listener)
      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

      public void removeScriptRecordingListener(ScriptRecordingListener listener)
      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.