Class ImageVariableTable

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Cloneable, java.util.Map<java.lang.String,​java.lang.String>

    public class ImageVariableTable
    extends java.util.Hashtable<java.lang.String,​java.lang.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:
    ScriptRecorder, Serialized Form
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected int currentImageNumber
      The number to use for the next image placeholder variable to be added to the table.
      protected static java.lang.String imageVariablePrefix
      The base image placeholder variable string prefix.
      private static long serialVersionUID
      Use serialVersionUID for interoperability.
    • Constructor Summary

      Constructors 
      Constructor Description
      ImageVariableTable()
      Creates a new ImageVariableTable object.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void changeImageName​(java.lang.String oldName, java.lang.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).
      ModelImage getImage​(java.lang.String imageVar)
      Returns the image associated with a image placeholder variable.
      java.lang.String getImageName​(java.lang.String imageVar)
      Retrieves the image name linked to an image variable.
      java.lang.String getImageVariable​(java.lang.String imageName)
      Returns the image variable that an image name is associated with.
      boolean isImageStored​(java.lang.String imageName)
      Checks to see if an image has been stored somewhere in the image table.
      boolean isImageVariableSet​(java.lang.String imageVar)
      Checks to see if an image variable has been added to the table.
      void removeImageVariable​(java.lang.String varName)
      Removes an image variable and its image name from the table.
      java.lang.String storeImageName​(java.lang.String imageName)
      Stores a new image name in the variable table, giving it the next available image placeholder variable name.
      void storeImageVariable​(java.lang.String imageVar, java.lang.String imageName)
      Associates an image (through its name) with an image placholder variable.
      • Methods inherited from class java.util.Hashtable

        clear, clone, compute, computeIfAbsent, computeIfPresent, contains, containsKey, containsValue, elements, entrySet, equals, forEach, get, getOrDefault, hashCode, isEmpty, keys, keySet, merge, put, putAll, putIfAbsent, rehash, remove, remove, replace, replace, replaceAll, size, toString, values
      • Methods inherited from class java.lang.Object

        finalize, getClass, notify, notifyAll, wait, wait, wait
    • Field Detail

      • serialVersionUID

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

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

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

      • ImageVariableTable

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

      • changeImageName

        public void changeImageName​(java.lang.String oldName,
                                    java.lang.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​(java.lang.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 java.lang.String getImageName​(java.lang.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 java.lang.String getImageVariable​(java.lang.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​(java.lang.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​(java.lang.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​(java.lang.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 java.lang.String storeImageName​(java.lang.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:
        ModelImage.getImageName()
      • storeImageVariable

        public void storeImageVariable​(java.lang.String imageVar,
                                       java.lang.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.