Class 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 numbering
      void 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 specific
      void removeMatrix​(java.lang.Object key)
      Safe method for removing matrices from the image
      void 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 java.lang.Object

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

      • 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.
    • Constructor Detail

      • MatrixHolder

        public MatrixHolder​(int nDims)
        Default constructor.
        Parameters:
        nDims - dimensions of image
    • 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 class ModelSerialCloneable
        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 matrix
        newMatrix - the new matrix
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object