Package gov.nih.mipav.model.scripting
Class ImageVariableTable
- All Implemented Interfaces:
Serializable,Cloneable,Map<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 Summary
FieldsModifier and TypeFieldDescriptionprotected intThe number to use for the next image placeholder variable to be added to the table.protected static final StringThe base image placeholder variable string prefix.private static final longUse serialVersionUID for interoperability. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidchangeImageName(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).Returns the image associated with a image placeholder variable.getImageName(String imageVar) Retrieves the image name linked to an image variable.getImageVariable(String imageName) Returns the image variable that an image name is associated with.booleanisImageStored(String imageName) Checks to see if an image has been stored somewhere in the image table.booleanisImageVariableSet(String imageVar) Checks to see if an image variable has been added to the table.voidremoveImageVariable(String varName) Removes an image variable and its image name from the table.storeImageName(String imageName) Stores a new image name in the variable table, giving it the next available image placeholder variable name.voidstoreImageVariable(String imageVar, 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
-
Field Details
-
serialVersionUID
private static final long serialVersionUIDUse serialVersionUID for interoperability.- See Also:
-
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 currentImageNumberThe 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
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
Returns the image associated with a image placeholder variable.- Parameters:
imageVar- An image placeholder variable (e.g., '$image1').- Returns:
- The associated image.
-
getImageName
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
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
nullif none was found.
-
isImageStored
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:
Trueif the image has been added to the table,falseotherwise.
-
isImageVariableSet
Checks to see if an image variable has been added to the table.- Parameters:
imageVar- The image variable to check for.- Returns:
Trueif the variable has been added to the table,falseotherwise.
-
removeImageVariable
Removes an image variable and its image name from the table.- Parameters:
varName- The name of the image variable to remove.
-
storeImageName
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
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.
-