Package gov.nih.mipav.model.structures
Class MatrixHolder
- java.lang.Object
-
- gov.nih.mipav.model.structures.ModelSerialCloneable
-
- gov.nih.mipav.model.structures.MatrixHolder
-
- All Implemented Interfaces:
java.io.Serializable
,java.lang.Cloneable
public class MatrixHolder extends ModelSerialCloneable
Class that stores matrices (owned by ModelImage) with accessor functions to the matrix map/adding and changing matrices.- Author:
- linkb
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description private TransMatrix
compositeMatrix
The composite matrix formed by multiplying (in reverse order) all stored matrices.private java.util.LinkedHashMap<java.lang.String,TransMatrix>
matrixMap
Linked hash map that will store all of the images associated matrices.private static long
serialVersionUID
-
Constructor Summary
Constructors Constructor Description MatrixHolder(int nDims)
Default constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addMatrix(TransMatrix mat)
Adds a matrix to the map. matrices will be keyed by their type and sequential numberingvoid
clearMatrices()
Removes all matrices from the map.java.lang.Object
clone()
Copies the object.boolean
containsType(int type)
Determines if the map contains a matrix of the given type (checks for String.contains()).TransMatrix
getCompositeMatrix(boolean useDICOM)
Gets the composite (dynamically built) matrix made by multiplying in forward order the image's matrices.java.util.Vector<TransMatrix>
getMatrices()
Gets a cloned copy of the image's matrices stored in a vector.TransMatrix
getMatrix(java.lang.Object key)
Accessor that gets a matrix based on the key (for the linkedhashmap)java.util.LinkedHashMap<java.lang.String,TransMatrix>
getMatrixMap()
Gets the matrix map.TransMatrix[]
getNIFTICompositeMatrices()
Returns up to two composite TransMatrices that are NIFTI specificvoid
removeMatrix(java.lang.Object key)
Safe method for removing matrices from the imagevoid
replaceMatrices(java.util.Vector<TransMatrix> matrixVector)
Helper function for XML type images which may have several associated matrices.void
replaceMatrix(java.lang.String key, TransMatrix newMatrix)
Replaces the matrix at the given key (or inserts if that key is not present, which should not happen).java.lang.String
toString()
-
Methods inherited from class gov.nih.mipav.model.structures.ModelSerialCloneable
nativeClone
-
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
compositeMatrix
private TransMatrix compositeMatrix
The composite matrix formed by multiplying (in reverse order) all stored matrices.
-
matrixMap
private java.util.LinkedHashMap<java.lang.String,TransMatrix> matrixMap
Linked hash map that will store all of the images associated matrices.
-
-
Method Detail
-
addMatrix
public void addMatrix(TransMatrix mat)
Adds a matrix to the map. matrices will be keyed by their type and sequential numbering- Parameters:
mat
- DOCUMENT ME!
-
getNIFTICompositeMatrices
public TransMatrix[] getNIFTICompositeMatrices()
Returns up to two composite TransMatrices that are NIFTI specific- Returns:
- 0,1, or 2 TransMatrices (related to NIFTI)
-
clearMatrices
public void clearMatrices()
Removes all matrices from the map.
-
clone
public java.lang.Object clone()
Copies the object.- Overrides:
clone
in classModelSerialCloneable
- Returns:
- Object A copy of the file info.
-
containsType
public boolean containsType(int type)
Determines if the map contains a matrix of the given type (checks for String.contains()).- Parameters:
type
- transformID to check- Returns:
- whether the map contains this type of transform
-
getCompositeMatrix
public TransMatrix getCompositeMatrix(boolean useDICOM)
Gets the composite (dynamically built) matrix made by multiplying in forward order the image's matrices.- Parameters:
useDICOM
- whether to include the scanner anatomical matrix (if available)- Returns:
- the composite TransMatrix
-
getMatrix
public TransMatrix getMatrix(java.lang.Object key)
Accessor that gets a matrix based on the key (for the linkedhashmap)- Parameters:
key
- key to the matrix- Returns:
- the matrix associated with the key, null otherwise
-
getMatrices
public java.util.Vector<TransMatrix> getMatrices()
Gets a cloned copy of the image's matrices stored in a vector.- Returns:
- Vector of image's matrices
-
getMatrixMap
public java.util.LinkedHashMap<java.lang.String,TransMatrix> getMatrixMap()
Gets the matrix map.- Returns:
- the matrix map
-
removeMatrix
public void removeMatrix(java.lang.Object key)
Safe method for removing matrices from the image- Parameters:
key
- DOCUMENT ME!
-
replaceMatrices
public void replaceMatrices(java.util.Vector<TransMatrix> matrixVector)
Helper function for XML type images which may have several associated matrices.- Parameters:
matrixVector
- Vector of matrices to replace the current matrices in the map
-
replaceMatrix
public void replaceMatrix(java.lang.String key, TransMatrix newMatrix)
Replaces the matrix at the given key (or inserts if that key is not present, which should not happen).- Parameters:
key
- the key for the matrixnewMatrix
- the new matrix
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-