Class ColorMatrix<A,​B>

  • All Implemented Interfaces:
    Cloneable

    public class ColorMatrix<A,​B>
    extends Object
    implements Cloneable
    Creates a color matrix from a matrix of doubles
    Author:
    Will Braynen
    • Field Detail

      • colorMap

        protected Color[] colorMap
      • colors

        protected Color[][] colors
      • displayMax

        protected double displayMax
      • displayMin

        protected double displayMin
        Min and max values to display, which might not be the actual min and max values in the matrix. For instance, we might want to clip values, or show a bigger color range for equal comparison with other rows or matrices.
      • m_rowKeys

        protected int[] m_rowKeys
        to be able to sort the rows by an arbitrary key
      • m_totalRows

        protected int m_totalRows
      • m_totalColumns

        protected int m_totalColumns
      • max

        protected double max
      • min

        protected double min
      • missingColor

        protected Color missingColor
    • Constructor Detail

      • ColorMatrix

        public ColorMatrix​(DoubleMatrix<A,​B> matrix,
                           Color[] colorMap,
                           Color missingColor)
        Parameters:
        matrix - the matrix
        colorMap - the simplest color map is one with just two colors: { minColor, maxColor }
        missingColor - values missing from the matrix or non-numeric entries will be displayed using this color
    • Method Detail

      • getColorMap

        public Color[] getColorMap()
      • getColors

        public Color[][] getColors()
      • getColumnCount

        public int getColumnCount()
      • getColumnNames

        public String[] getColumnNames()
      • getDisplayMax

        public double getDisplayMax()
      • getDisplayMin

        public double getDisplayMin()
      • getMatrix

        public DoubleMatrix<A,​B> getMatrix()
        Returns:
        a DenseDoubleMatrix2DNamed object
      • getMax

        public double getMax()
      • getMin

        public double getMin()
      • getMissingColor

        public Color getMissingColor()
      • getRowByName

        public double[] getRowByName​(A rowName)
      • getRowCount

        public int getRowCount()
      • getRowIndexByName

        public int getRowIndexByName​(A rowName)
      • getRowNames

        public String[] getRowNames()
      • mapValuesToColors

        public void mapValuesToColors()
      • resetRowKeys

        public void resetRowKeys()
      • setColorMap

        public void setColorMap​(Color[] colorMap)
                         throws IllegalArgumentException
        Parameters:
        colorMap - an array of colors which define the midpoints in the color map; this can be one of the constants defined in the ColorMap class, like ColorMap.REDGREEN_COLORMAP and ColorMap.BLACKBODY_COLORMAP
        Throws:
        IllegalArgumentException - if the colorMap array argument contains less than two colors.
      • setDisplayRange

        public void setDisplayRange​(double min,
                                    double max)
        Standardized display range
      • setRowKeys

        public void setRowKeys​(int[] rowKeys)
        Parameters:
        rowKeys -
      • standardize

        public void standardize()
        Normalizes the elements of a matrix to variance one and mean zero, ignoring missing values todo move this to matrixstats or something.
      • createRowKeys

        protected int[] createRowKeys()
        To be able to sort the rows by an arbitrary key. Creates m_rowKeys array and initializes it in ascending order from 0 to m_totalRows -1, so that by default it matches the physical order of the columns: [0,1,2,...,m_totalRows-1]
        Returns:
        int[]
      • getTrueRowIndex

        protected int getTrueRowIndex​(int row)
      • setRow

        protected void setRow​(int row,
                              double[] values)
        Changes values in a row, clipping if there are more values than columns.
        Parameters:
        row - row whose values we want to change
        values - new row values