Class ImageVariableTable

java.lang.Object
java.util.Dictionary<String,String>
java.util.Hashtable<String,String>
gov.nih.mipav.model.scripting.ImageVariableTable
All Implemented Interfaces:
Serializable, Cloneable, Map<String,String>

public class ImageVariableTable extends Hashtable<String,String>

Stores image names, which are referenced by placeholder variable strings (e.g., '$image1'). Every image name is unique (enforced by ViewUserInterface), so each image name should map to exactly one image placeholder in this table (and vice-versa).

USAGE NOTE: A new instance of this class should be created each time a new script is recorded or executed.

See Also:
  • Field Details

    • serialVersionUID

      private static final long serialVersionUID
      Use serialVersionUID for interoperability.
      See Also:
    • imageVariablePrefix

      protected static final String imageVariablePrefix
      The base image placeholder variable string prefix. Should be prepended to a number for each image used in a script.
      See Also:
    • currentImageNumber

      protected int currentImageNumber
      The number to use for the next image placeholder variable to be added to the table. Starts at 1.
  • Constructor Details

    • ImageVariableTable

      public ImageVariableTable()
      Creates a new ImageVariableTable object.
  • Method Details

    • changeImageName

      public void changeImageName(String oldName, String newName)
      Finds an image name in the table and changes it to a new value with the same variable placeholder (does nothing if the value is not in the table).
      Parameters:
      oldName - The old image name to replace.
      newName - The new image name to give to the variable.
    • getImage

      public ModelImage getImage(String imageVar)
      Returns the image associated with a image placeholder variable.
      Parameters:
      imageVar - An image placeholder variable (e.g., '$image1').
      Returns:
      The associated image.
    • getImageName

      public String getImageName(String imageVar)
      Retrieves the image name linked to an image variable.
      Parameters:
      imageVar - The image variable to look up.
      Returns:
      The image name associated with the given image variable.
    • getImageVariable

      public String getImageVariable(String imageName)
      Returns the image variable that an image name is associated with.
      Parameters:
      imageName - The name of the image to look for in the image table.
      Returns:
      The image placeholder variable associated with the given image name, or null if none was found.
    • isImageStored

      public boolean isImageStored(String imageName)
      Checks to see if an image has been stored somewhere in the image table.
      Parameters:
      imageName - The name of the image to check for.
      Returns:
      True if the image has been added to the table, false otherwise.
    • isImageVariableSet

      public boolean isImageVariableSet(String imageVar)
      Checks to see if an image variable has been added to the table.
      Parameters:
      imageVar - The image variable to check for.
      Returns:
      True if the variable has been added to the table, false otherwise.
    • removeImageVariable

      public void removeImageVariable(String varName)
      Removes an image variable and its image name from the table.
      Parameters:
      varName - The name of the image variable to remove.
    • storeImageName

      public String storeImageName(String imageName)
      Stores a new image name in the variable table, giving it the next available image placeholder variable name.
      Parameters:
      imageName - The name of the image to add to the table.
      Returns:
      The image placeholder variable assigned to the image name (e.g., '$image2').
      See Also:
    • storeImageVariable

      public void storeImageVariable(String imageVar, String imageName)
      Associates an image (through its name) with an image placholder variable.
      Parameters:
      imageVar - The name of the variable (e.g., '$image1').
      imageName - The image name.