baseCode.gui
Class JMatrixDisplay

java.lang.Object
  extended byjava.awt.Component
      extended byjava.awt.Container
          extended byjavax.swing.JComponent
              extended byjavax.swing.JPanel
                  extended bybaseCode.gui.JMatrixDisplay
All Implemented Interfaces:
javax.accessibility.Accessible, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable

public class JMatrixDisplay
extends javax.swing.JPanel

Title: JMatrixDisplay

Description: a visual component for displaying a color matrix

Copyright: Copyright (c) 2004

Institution:: Columbia University

Version:
$Id: JMatrixDisplay.java,v 1.39 2004/09/20 22:19:02 pavlidis Exp $
Author:
Will Braynen
See Also:
Serialized Form

Nested Class Summary
 
Nested classes inherited from class javax.swing.JPanel
javax.swing.JPanel.AccessibleJPanel
 
Nested classes inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Nested classes inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
protected  java.awt.Dimension m_cellSize
           
protected  int m_columnLabelHeight
           
protected  int m_defaultResolution
           
protected  int m_fontGutter
           
protected  int m_fontSize
           
protected  java.awt.image.BufferedImage m_image
           
protected  boolean m_isShowLabels
           
protected  java.awt.Font m_labelFont
           
protected  int m_labelGutter
           
protected  int m_maxFontSize
           
protected  int m_ratioWidth
           
protected  int m_resolution
           
protected  int m_rowLabelWidth
           
protected  int m_textSize
           
 
Fields inherited from class javax.swing.JComponent
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
JMatrixDisplay(ColorMatrix matrix)
           
JMatrixDisplay(DenseDoubleMatrix2DNamed matrix)
           
JMatrixDisplay(java.lang.String filename)
           
 
Method Summary
protected  void drawColumnNames(java.awt.Graphics g)
          Draws column names vertically (turned 90 degrees counter-clockwise)
protected  void drawMatrix(java.awt.Graphics g, boolean leaveRoomForLabels)
          Gets called from #paintComponent and #saveImage
protected  void drawRowNames(java.awt.Graphics g)
          Draws row names (horizontally)
 java.awt.Color getColor(int row, int column)
           
 java.awt.Color[] getColorMap()
           
 ColorMatrix getColorMatrix()
           
 int getColumnCount()
           
 java.lang.String getColumnName(int column)
           
 java.lang.String[] getColumnNames()
           
 double getDisplayMax()
           
 double getDisplayMin()
           
 double getDisplayRange()
           
 AbstractNamedDoubleMatrix getMatrix()
           
 double getMax()
           
 double getMin()
           
 java.awt.Color getMissingColor()
           
 double[] getRow(int row)
           
 double[] getRowByName(java.lang.String rowName)
           
 int getRowCount()
           
 int getRowHeight()
           
 int getRowIndexByName(java.lang.String rowName)
           
 java.lang.String getRowName(int row)
           
 java.lang.String[] getRowNames()
           
protected  java.awt.Dimension getSize(boolean withLabels)
           
 boolean getStandardizedEnabled()
           
 double getValue(int row, int column)
           
 void init(ColorMatrix matrix)
           
protected  void initSize()
          Sets the display size
protected  void paintComponent(java.awt.Graphics g)
          JComponent method used to render this component
 void resetRowKeys()
           
 void saveImage(java.lang.String outPngFilename)
          Saves the image to a png file.
 void saveImage(java.lang.String outPngFilename, boolean showLabels)
           
 void saveImage(java.lang.String outPngFilename, boolean showLabels, boolean standardize)
           
 void setCellSize(java.awt.Dimension d)
           
 void setColorMap(java.awt.Color[] colorMap)
           
 void setDisplayRange(double min, double max)
           
 void setLabelsVisible(boolean isShowLabels)
          If this display component has already been added to the GUI, it will be resized to fit or exclude the row names
 void setMatrix(ColorMatrix matrix)
           
 void setRowHeight(int height)
           
 void setRowKeys(int[] rowKeys)
           
 void setStandardizedEnabled(boolean showStandardizedMatrix)
           
 
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getGraphics, getHeight, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPreferredSize, getPropertyChangeListeners, getPropertyChangeListeners, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFont, setForeground, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setLayout, transferFocusBackward, transferFocusDownCycle, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

m_isShowLabels

protected boolean m_isShowLabels

m_image

protected java.awt.image.BufferedImage m_image

m_ratioWidth

protected int m_ratioWidth

m_rowLabelWidth

protected int m_rowLabelWidth

m_columnLabelHeight

protected int m_columnLabelHeight

m_labelGutter

protected int m_labelGutter

m_fontGutter

protected int m_fontGutter

m_labelFont

protected java.awt.Font m_labelFont

m_fontSize

protected int m_fontSize

m_maxFontSize

protected final int m_maxFontSize
See Also:
Constant Field Values

m_defaultResolution

protected final int m_defaultResolution
See Also:
Constant Field Values

m_resolution

protected int m_resolution

m_textSize

protected int m_textSize

m_cellSize

protected java.awt.Dimension m_cellSize
Constructor Detail

JMatrixDisplay

public JMatrixDisplay(java.lang.String filename)
               throws java.io.IOException

JMatrixDisplay

public JMatrixDisplay(DenseDoubleMatrix2DNamed matrix)

JMatrixDisplay

public JMatrixDisplay(ColorMatrix matrix)
Method Detail

init

public void init(ColorMatrix matrix)

initSize

protected void initSize()
Sets the display size


getSize

protected java.awt.Dimension getSize(boolean withLabels)

paintComponent

protected void paintComponent(java.awt.Graphics g)
JComponent method used to render this component

Parameters:
g - Graphics used for painting

setStandardizedEnabled

public void setStandardizedEnabled(boolean showStandardizedMatrix)

getStandardizedEnabled

public boolean getStandardizedEnabled()

drawMatrix

protected void drawMatrix(java.awt.Graphics g,
                          boolean leaveRoomForLabels)
Gets called from #paintComponent and #saveImage

Parameters:
g - Graphics
leaveRoomForLabels - boolean

drawRowNames

protected void drawRowNames(java.awt.Graphics g)
Draws row names (horizontally)

Parameters:
g - Graphics

drawColumnNames

protected void drawColumnNames(java.awt.Graphics g)
Draws column names vertically (turned 90 degrees counter-clockwise)

Parameters:
g - Graphics

saveImage

public void saveImage(java.lang.String outPngFilename)
               throws java.io.IOException
Saves the image to a png file.

Parameters:
outPngFilename - String
Throws:
java.io.IOException

saveImage

public void saveImage(java.lang.String outPngFilename,
                      boolean showLabels)
               throws java.io.IOException
Throws:
java.io.IOException

saveImage

public void saveImage(java.lang.String outPngFilename,
                      boolean showLabels,
                      boolean standardize)
               throws java.io.IOException
Parameters:
outPngFilename - String
showLabels - boolean
standardize - normalize to deviation 1, mean 0.
Throws:
java.io.IOException

setLabelsVisible

public void setLabelsVisible(boolean isShowLabels)
If this display component has already been added to the GUI, it will be resized to fit or exclude the row names

Parameters:
isShowLabels - boolean

getColorMatrix

public ColorMatrix getColorMatrix()

getMatrix

public AbstractNamedDoubleMatrix getMatrix()

setMatrix

public void setMatrix(ColorMatrix matrix)
Parameters:
matrix - the new matrix to use; will resize this display component as necessary

setCellSize

public void setCellSize(java.awt.Dimension d)

setRowHeight

public void setRowHeight(int height)

getRowHeight

public int getRowHeight()

getColor

public java.awt.Color getColor(int row,
                               int column)

getValue

public double getValue(int row,
                       int column)

getRow

public double[] getRow(int row)

getRowByName

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

getRowCount

public int getRowCount()

getColumnCount

public int getColumnCount()

getColumnName

public java.lang.String getColumnName(int column)

getRowName

public java.lang.String getRowName(int row)

getColumnNames

public java.lang.String[] getColumnNames()

getRowNames

public java.lang.String[] getRowNames()

getRowIndexByName

public int getRowIndexByName(java.lang.String rowName)

setRowKeys

public void setRowKeys(int[] rowKeys)

resetRowKeys

public void resetRowKeys()

setColorMap

public void setColorMap(java.awt.Color[] colorMap)
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

getColorMap

public java.awt.Color[] getColorMap()
Returns:
the current color map

getMin

public double getMin()
Returns:
the smallest value in the matrix

getMax

public double getMax()
Returns:
the largest value in the matrix

getDisplayMin

public double getDisplayMin()

getDisplayMax

public double getDisplayMax()

getDisplayRange

public double getDisplayRange()

setDisplayRange

public void setDisplayRange(double min,
                            double max)

getMissingColor

public java.awt.Color getMissingColor()
Returns:
the color used for missing values


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