Package ubic.basecode.graphics
Class ColorMatrix<A,B>
- java.lang.Object
-
- ubic.basecode.graphics.ColorMatrix<A,B>
-
-
Field Summary
Fields Modifier and Type Field Description protected Color[]colorMapprotected Color[][]colorsprotected doubledisplayMaxprotected doubledisplayMinMin and max values to display, which might not be the actual min and max values in the matrix.protected DoubleMatrixReaderm_matrixReaderprotected int[]m_rowKeysto be able to sort the rows by an arbitrary keyprotected intm_totalColumnsprotected intm_totalRowsprotected doublemaxprotected DoubleMatrix<A,B>maxtrixprotected doubleminprotected ColormissingColor
-
Constructor Summary
Constructors Constructor Description ColorMatrix(DoubleMatrix<A,B> matrix)ColorMatrix(DoubleMatrix<A,B> matrix, Color[] colorMap, Color missingColor)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description ColorMatrix<A,B>clone()protected int[]createRowKeys()To be able to sort the rows by an arbitrary key.ColorgetColor(int row, int column)Color[]getColorMap()Color[][]getColors()intgetColumnCount()BgetColumnName(int column)String[]getColumnNames()doublegetDisplayMax()doublegetDisplayMin()DoubleMatrix<A,B>getMatrix()doublegetMax()DoubleMatrix<A,B>getMaxtrix()doublegetMin()ColorgetMissingColor()double[]getRow(int row)double[]getRowByName(A rowName)intgetRowCount()intgetRowIndexByName(A rowName)ObjectgetRowName(int row)String[]getRowNames()protected intgetTrueRowIndex(int row)doublegetValue(int row, int column)voidmapValuesToColors()static <R,C>
ColorMatrix<R,C>newInstance(DoubleMatrix<R,C> matrix)voidresetRowKeys()voidsetColor(int row, int column, Color newColor)voidsetColorMap(Color[] colorMap)voidsetDisplayRange(double min, double max)Standardized display rangeprotected voidsetRow(int row, double[] values)Changes values in a row, clipping if there are more values than columns.voidsetRowKeys(int[] rowKeys)voidstandardize()Normalizes the elements of a matrix to variance one and mean zero, ignoring missing values todo move this to matrixstats or something.
-
-
-
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_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 Detail
-
ColorMatrix
public ColorMatrix(DoubleMatrix<A,B> matrix)
-
ColorMatrix
public ColorMatrix(DoubleMatrix<A,B> matrix, Color[] colorMap, Color missingColor)
- Parameters:
matrix- the matrixcolorMap- 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
-
newInstance
public static <R,C> ColorMatrix<R,C> newInstance(DoubleMatrix<R,C> matrix)
-
clone
public ColorMatrix<A,B> clone()
-
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. Createsm_rowKeysarray and initializes it in ascending order from 0 tom_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 changevalues- new row values
-
-