Class ColorMatrix<A,B>

java.lang.Object
ubic.basecode.graphics.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 Details

    • 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_matrixReader

      protected DoubleMatrixReader m_matrixReader
    • 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
    • maxtrix

      protected DoubleMatrix<A,B> maxtrix
    • min

      protected double min
    • missingColor

      protected Color missingColor
  • Constructor Details

    • ColorMatrix

      public ColorMatrix(DoubleMatrix<A,B> matrix)
    • 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 Details

    • newInstance

      public static <R, C> ColorMatrix<R,C> newInstance(DoubleMatrix<R,C> matrix)
    • clone

      public ColorMatrix<A,B> clone()
      Overrides:
      clone in class Object
    • getColor

      public Color getColor(int row, int column) throws ArrayIndexOutOfBoundsException
      Throws:
      ArrayIndexOutOfBoundsException
    • getColorMap

      public Color[] getColorMap()
    • getColors

      public Color[][] getColors()
    • getColumnCount

      public int getColumnCount()
    • getColumnName

      public B getColumnName(int column) throws ArrayIndexOutOfBoundsException
      Throws:
      ArrayIndexOutOfBoundsException
    • 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()
    • getMaxtrix

      public DoubleMatrix<A,B> getMaxtrix()
    • getMin

      public double getMin()
    • getMissingColor

      public Color getMissingColor()
    • getRow

      public double[] getRow(int row) throws ArrayIndexOutOfBoundsException
      Throws:
      ArrayIndexOutOfBoundsException
    • getRowByName

      public double[] getRowByName(A rowName)
    • getRowCount

      public int getRowCount()
    • getRowIndexByName

      public int getRowIndexByName(A rowName)
    • getRowName

      public Object getRowName(int row) throws ArrayIndexOutOfBoundsException
      Throws:
      ArrayIndexOutOfBoundsException
    • getRowNames

      public String[] getRowNames()
    • getValue

      public double getValue(int row, int column) throws ArrayIndexOutOfBoundsException
      Throws:
      ArrayIndexOutOfBoundsException
    • mapValuesToColors

      public void mapValuesToColors()
    • resetRowKeys

      public void resetRowKeys()
    • setColor

      public void setColor(int row, int column, Color newColor) throws ArrayIndexOutOfBoundsException
      Parameters:
      row -
      column -
      newColor -
      Throws:
      ArrayIndexOutOfBoundsException
    • 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