baseCode.gui
Class ColorMatrix

java.lang.Object
  extended bybaseCode.gui.ColorMatrix
All Implemented Interfaces:
java.lang.Cloneable

public class ColorMatrix
extends java.lang.Object
implements java.lang.Cloneable

Title: ColorMatrix

Description: Creates a color matrix from a matrix of doubles

Copyright (c) 2004

Institution:: Columbia University

Version:
$Id: ColorMatrix.java,v 1.42 2004/09/20 22:19:02 pavlidis Exp $
Author:
Will Braynen

Field Summary
protected  java.awt.Color[] m_colorMap
           
protected  java.awt.Color[][] m_colors
           
protected  double m_displayMax
           
protected  double m_displayMin
          Min and max values to display, which might not be the actual min and max values in the matrix.
protected  AbstractNamedDoubleMatrix m_matrix
           
protected  DoubleMatrixReader m_matrixReader
           
protected  double m_max
           
protected  double m_min
           
protected  java.awt.Color m_missingColor
           
protected  int[] m_rowKeys
          to be able to sort the rows by an arbitrary key
protected  int m_totalColumns
           
protected  int m_totalRows
           
 
Constructor Summary
ColorMatrix(AbstractNamedDoubleMatrix matrix, java.awt.Color[] colorMap, java.awt.Color missingColor)
           
ColorMatrix(DenseDoubleMatrix2DNamed matrix)
           
ColorMatrix(java.lang.String filename)
           
ColorMatrix(java.lang.String filename, java.awt.Color[] colorMap, java.awt.Color missingColor)
           
 
Method Summary
 java.lang.Object clone()
           
protected  int[] createRowKeys()
          To be able to sort the rows by an arbitrary key.
 java.awt.Color getColor(int row, int column)
           
 int getColumnCount()
           
 java.lang.String getColumnName(int column)
           
 java.lang.String[] getColumnNames()
           
 double getDisplayMax()
           
 double getDisplayMin()
           
 AbstractNamedDoubleMatrix getMatrix()
           
 double[] getRow(int row)
           
 double[] getRowByName(java.lang.String rowName)
           
 int getRowCount()
           
 int getRowIndexByName(java.lang.String rowName)
           
 java.lang.String getRowName(int row)
           
 java.lang.String[] getRowNames()
           
protected  int getTrueRowIndex(int row)
           
 double getValue(int row, int column)
           
 void init(AbstractNamedDoubleMatrix matrix)
           
 void loadMatrixFromFile(java.lang.String filename)
          A convenience method for loading data files
 void mapValuesToColors()
           
 void resetRowKeys()
           
 void setColor(int row, int column, java.awt.Color newColor)
           
 void setColorMap(java.awt.Color[] colorMap)
           
 void setDisplayRange(double min, double max)
           
protected  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.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m_displayMin

protected double m_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_displayMax

protected double m_displayMax

m_min

protected double m_min

m_max

protected double m_max

m_colors

protected java.awt.Color[][] m_colors

m_missingColor

protected java.awt.Color m_missingColor

m_colorMap

protected java.awt.Color[] m_colorMap

m_matrix

protected AbstractNamedDoubleMatrix m_matrix

m_matrixReader

protected DoubleMatrixReader m_matrixReader

m_totalRows

protected int m_totalRows

m_totalColumns

protected int m_totalColumns

m_rowKeys

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

Constructor Detail

ColorMatrix

public ColorMatrix(java.lang.String filename)
            throws java.io.IOException
Parameters:
filename - either an absolute path, or if providing a relative path (e.g. data.txt), then keep in mind that it will be relative to the java interpreter, not the class (not my fault -- that's how java treats relative paths)
Throws:
java.io.IOException

ColorMatrix

public ColorMatrix(DenseDoubleMatrix2DNamed matrix)

ColorMatrix

public ColorMatrix(java.lang.String filename,
                   java.awt.Color[] colorMap,
                   java.awt.Color missingColor)
            throws java.io.IOException
Parameters:
filename - data filename
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
Throws:
java.io.IOException

ColorMatrix

public ColorMatrix(AbstractNamedDoubleMatrix matrix,
                   java.awt.Color[] colorMap,
                   java.awt.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

getRowCount

public int getRowCount()

getColumnCount

public int getColumnCount()

getTrueRowIndex

protected int getTrueRowIndex(int row)

getValue

public double getValue(int row,
                       int column)
                throws java.lang.ArrayIndexOutOfBoundsException
Throws:
java.lang.ArrayIndexOutOfBoundsException

getRow

public double[] getRow(int row)
                throws java.lang.ArrayIndexOutOfBoundsException
Throws:
java.lang.ArrayIndexOutOfBoundsException

getRowByName

public double[] getRowByName(java.lang.String rowName)

getColor

public java.awt.Color getColor(int row,
                               int column)
                        throws java.lang.ArrayIndexOutOfBoundsException
Throws:
java.lang.ArrayIndexOutOfBoundsException

setColor

public void setColor(int row,
                     int column,
                     java.awt.Color newColor)
              throws java.lang.ArrayIndexOutOfBoundsException
Throws:
java.lang.ArrayIndexOutOfBoundsException

getRowName

public java.lang.String getRowName(int row)
                            throws java.lang.ArrayIndexOutOfBoundsException
Throws:
java.lang.ArrayIndexOutOfBoundsException

getColumnName

public java.lang.String getColumnName(int column)
                               throws java.lang.ArrayIndexOutOfBoundsException
Throws:
java.lang.ArrayIndexOutOfBoundsException

getRowNames

public java.lang.String[] getRowNames()

getColumnNames

public java.lang.String[] getColumnNames()

getRowIndexByName

public int getRowIndexByName(java.lang.String rowName)

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

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[]

setRowKeys

public void setRowKeys(int[] rowKeys)

resetRowKeys

public void resetRowKeys()

init

public void init(AbstractNamedDoubleMatrix matrix)

loadMatrixFromFile

public void loadMatrixFromFile(java.lang.String filename)
                        throws java.io.IOException
A convenience method for loading data files

Parameters:
filename - the name of the data file
Throws:
java.io.IOException

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.


getMatrix

public AbstractNamedDoubleMatrix getMatrix()
Returns:
a DenseDoubleMatrix2DNamed object

setDisplayRange

public void setDisplayRange(double min,
                            double max)

getDisplayMin

public double getDisplayMin()

getDisplayMax

public double getDisplayMax()

setColorMap

public void setColorMap(java.awt.Color[] colorMap)
                 throws java.lang.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:
java.lang.IllegalArgumentException - if the colorMap array argument contains less than two colors.

mapValuesToColors

public void mapValuesToColors()

clone

public java.lang.Object clone()


Copyright © 2003-2005 Columbia University. All Rights Reserved.