public class MatrixDisplay<R,C> extends JPanel
JPanel.AccessibleJPanel
JComponent.AccessibleJComponent
Container.AccessibleAWTContainer
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
Modifier and Type | Field and Description |
---|---|
protected Dimension |
m_cellSize |
protected int |
m_columnLabelHeight |
protected int |
m_defaultResolution |
protected int |
m_fontGutter |
protected int |
m_fontSize |
protected boolean |
m_isShowLabels |
protected boolean |
m_isShowScale |
protected Font |
m_labelFont |
protected int |
m_labelGutter |
protected int |
m_maxColumnLength |
protected int |
m_maxFontSize |
protected int |
m_ratioWidth |
protected int |
m_resolution |
protected int |
m_rowLabelWidth |
protected int |
m_textSize |
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
accessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
Constructor and Description |
---|
MatrixDisplay(ColorMatrix<R,C> matrix) |
MatrixDisplay(DoubleMatrix<R,C> matrix) |
Modifier and Type | Method and Description |
---|---|
protected Dimension |
computeSize(boolean showLabels,
boolean showScalebar)
compute the size of the matrix in pixels.
|
protected void |
drawColumnNames(Graphics g,
boolean leaveRoomForScalebar)
Draws column names vertically (turned 90 degrees counter-clockwise)
|
protected void |
drawMatrix(ColorMatrix<R,C> matrix,
Graphics g,
boolean leaveRoomForLabels,
boolean leaveRoomForScalebar)
Gets called from #paintComponent and #saveImage.
|
protected void |
drawRowNames(Graphics g,
boolean showScalebar)
Draws row names (horizontally)
|
protected void |
drawScaleBar(Graphics g,
Dimension d,
double displayMin,
double displayMax) |
Color |
getColor(int row,
int column) |
Color[] |
getColorMap() |
ColorMatrix<R,C> |
getColorMatrix() |
int |
getColumnCount() |
Object |
getColumnName(int column) |
String[] |
getColumnNames() |
double |
getDisplayMax() |
double |
getDisplayMin() |
double |
getDisplayRange() |
DoubleMatrix<R,C> |
getMatrix() |
double |
getMax() |
int |
getMaxColumnLength() |
double |
getMin() |
Color |
getMissingColor() |
double |
getRawValue(int row,
int column) |
double[] |
getRow(int row) |
double[] |
getRowByName(R rowName) |
int |
getRowCount() |
int |
getRowHeight() |
int |
getRowIndexByName(R rowName) |
Object |
getRowName(int row) |
String[] |
getRowNames() |
boolean |
getStandardizedEnabled() |
double |
getValue(int row,
int column) |
void |
init(ColorMatrix<R,C> matrix) |
protected void |
initSize()
Sets the display size
|
static <R,C> MatrixDisplay<R,C> |
newInstance(ColorMatrix<R,C> matrix) |
protected void |
paintComponent(Graphics g) |
void |
resetRowKeys() |
void |
saveImage(ColorMatrix<R,C> matrix,
String outPngFilename,
boolean showLabels,
boolean showScalebar,
boolean standardize) |
void |
saveImage(String outPngFilename)
Saves the image to a png file.
|
void |
saveImage(String outPngFilename,
boolean showLabels,
boolean showScale) |
void |
saveImageToPng(ColorMatrix<R,C> matrix,
OutputStream stream,
boolean showLabels,
boolean showScalebar,
boolean standardize) |
void |
setCellSize(Dimension d) |
void |
setColorMap(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<R,C> matrix) |
void |
setMaxColumnLength(int columnLength) |
void |
setRowHeight(int height) |
void |
setRowKeys(int[] rowKeys) |
void |
setScaleBarVisible(boolean isShowScale) |
void |
setStandardizedEnabled(boolean showStandardizedMatrix) |
void |
writeToPng(ColorMatrix<R,C> matrix,
OutputStream stream,
boolean showLabels,
boolean showScalebar) |
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusDownCycle, validate, validateTree
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, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, 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, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
protected Dimension m_cellSize
protected int m_columnLabelHeight
protected final int m_defaultResolution
protected int m_fontGutter
protected int m_fontSize
protected boolean m_isShowLabels
protected boolean m_isShowScale
protected Font m_labelFont
protected int m_labelGutter
protected int m_maxColumnLength
protected final int m_maxFontSize
protected int m_ratioWidth
protected int m_resolution
protected int m_rowLabelWidth
protected int m_textSize
public MatrixDisplay(ColorMatrix<R,C> matrix)
public MatrixDisplay(DoubleMatrix<R,C> matrix)
public static <R,C> MatrixDisplay<R,C> newInstance(ColorMatrix<R,C> matrix)
public Color getColor(int row, int column)
public Color[] getColorMap()
public ColorMatrix<R,C> getColorMatrix()
public int getColumnCount()
public Object getColumnName(int column)
public String[] getColumnNames()
public double getDisplayMax()
public double getDisplayMin()
public double getDisplayRange()
public DoubleMatrix<R,C> getMatrix()
public double getMax()
public int getMaxColumnLength()
public double getMin()
public Color getMissingColor()
public double getRawValue(int row, int column)
public double[] getRow(int row)
public double[] getRowByName(R rowName)
public int getRowCount()
public int getRowHeight()
public int getRowIndexByName(R rowName)
public Object getRowName(int row)
public String[] getRowNames()
public boolean getStandardizedEnabled()
public double getValue(int row, int column)
public void init(ColorMatrix<R,C> matrix)
public void resetRowKeys()
public void saveImage(ColorMatrix<R,C> matrix, String outPngFilename, boolean showLabels, boolean showScalebar, boolean standardize) throws IOException
outPngFilename
- StringshowLabels
- booleanstandardize
- normalize to deviation 1, mean 0. FIXME this is not used?IOException
public void saveImage(String outPngFilename) throws IOException
outPngFilename
- StringIOException
public void saveImage(String outPngFilename, boolean showLabels, boolean showScale) throws IOException
outPngFilename
- showLabels
- IOException
public void saveImageToPng(ColorMatrix<R,C> matrix, OutputStream stream, boolean showLabels, boolean showScalebar, boolean standardize) throws IOException
stream
- showLabels
- standardize
- IOException
public void setCellSize(Dimension d)
public void setColorMap(Color[] colorMap)
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_COLORMAPpublic void setDisplayRange(double min, double max)
min
- max
- public void setLabelsVisible(boolean isShowLabels)
isShowLabels
- booleanpublic void setMatrix(ColorMatrix<R,C> matrix)
matrix
- the new matrix to use; will resize this display component as necessarypublic void setMaxColumnLength(int columnLength)
columnLength
- the m_maxColumnLength to setpublic void setRowHeight(int height)
public void setRowKeys(int[] rowKeys)
public void setScaleBarVisible(boolean isShowScale)
public void setStandardizedEnabled(boolean showStandardizedMatrix)
public void writeToPng(ColorMatrix<R,C> matrix, OutputStream stream, boolean showLabels, boolean showScalebar) throws IOException
matrix
- stream
- showLabels
- showScalebar
- IOException
protected Dimension computeSize(boolean showLabels, boolean showScalebar)
withLabels
- protected void drawColumnNames(Graphics g, boolean leaveRoomForScalebar)
g
- Graphicsprotected void drawMatrix(ColorMatrix<R,C> matrix, Graphics g, boolean leaveRoomForLabels, boolean leaveRoomForScalebar)
g
- GraphicsleaveRoomForLabels
- booleanprotected void drawRowNames(Graphics g, boolean showScalebar)
g
- GraphicsshowScalebar
- protected void drawScaleBar(Graphics g, Dimension d, double displayMin, double displayMax)
g
- d
- protected void initSize()
protected void paintComponent(Graphics g)
paintComponent
in class JComponent
Copyright © 2003–2023 UBC Michael Smith Laboratories. All rights reserved.