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[]
colorMap
protected Color[][]
colors
protected double
displayMax
protected double
displayMin
Min and max values to display, which might not be the actual min and max values in the matrix.protected DoubleMatrixReader
m_matrixReader
protected int[]
m_rowKeys
to be able to sort the rows by an arbitrary keyprotected int
m_totalColumns
protected int
m_totalRows
protected double
max
protected DoubleMatrix<A,B>
maxtrix
protected double
min
protected Color
missingColor
-
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.Color
getColor(int row, int column)
Color[]
getColorMap()
Color[][]
getColors()
int
getColumnCount()
B
getColumnName(int column)
String[]
getColumnNames()
double
getDisplayMax()
double
getDisplayMin()
DoubleMatrix<A,B>
getMatrix()
double
getMax()
DoubleMatrix<A,B>
getMaxtrix()
double
getMin()
Color
getMissingColor()
double[]
getRow(int row)
double[]
getRowByName(A rowName)
int
getRowCount()
int
getRowIndexByName(A rowName)
Object
getRowName(int row)
String[]
getRowNames()
protected int
getTrueRowIndex(int row)
double
getValue(int row, int column)
void
mapValuesToColors()
static <R,C>
ColorMatrix<R,C>newInstance(DoubleMatrix<R,C> matrix)
void
resetRowKeys()
void
setColor(int row, int column, Color newColor)
void
setColorMap(Color[] colorMap)
void
setDisplayRange(double min, double max)
Standardized display rangeprotected void
setRow(int row, double[] values)
Changes values in a row, clipping if there are more values than columns.void
setRowKeys(int[] rowKeys)
void
standardize()
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_rowKeys
array 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
-
-