Class DrawHistogram

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Canvas
              |
              +--DrawHistogram
All Implemented Interfaces:
javax.accessibility.Accessible, java.util.EventListener, java.awt.image.ImageObserver, java.awt.MenuContainer, java.awt.event.MouseListener, java.io.Serializable

class DrawHistogram
extends java.awt.Canvas
implements java.awt.event.MouseListener

Class to draw an intensity histogram in popup frame. It is updated by the PopupRegistry when the normalization, Filter.workingCL, or other state values change.

This work was produced by Peter Lemkin of the National Cancer Institute, an agency of the United States Government. As a work of the United States Government there is no associated copyright. It is offered as open source software under the Mozilla Public License (version 1.1) subject to the limitations noted in the accompanying LEGAL file. This notice must be included with the code. The MAExplorer Mozilla and Legal files are available on http://maexplorer.sourceforge.net/.

Version:
$Date: 2002/10/14 20:46:12 $ $Revision: $
Author:
P. Lemkin (NCI), G. Thornwall (SAIC), NCI-Frederick, Frederick, MD
See Also:
MAExplorer Home, ShowPlotPopup, Serialized Form

Inner classes inherited from class java.awt.Canvas
java.awt.Canvas.AccessibleAWTCanvas
 
Inner classes inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.AWTTreeLock
 
Field Summary
(package private)  int activeBin
          active bin idx [0:MAXBINS-1] else -1
private  float[] binDataValue
          [0:MAXBINS] bins actual value @start of bin for display
private  int[] binFreq
          [0:MAXBINS] bins frequency for display
private  int cvPrecision
          precision in intensity data report
private  float deltaBin
          value of hist[] bin in [minX:maxX]
private  boolean drawIntoImageFlag
          set if draw plot to GIF file
private  int[] hist
          freq hist[0:nHist-1].
private  java.lang.String horizCaption
          horizontal caption
private  java.lang.String horizVariableCaption
          horizontal variable caption
private  int iHeight
          working canvas height
private  int intensL
          idx lower intensity range binDataValue[] space
private  int intensU
          idx upper intensity range binDataValue[] space
private  int iWidth
          working canvas width
private  boolean logScalingFlag
          Linear(false)/Log(true)
private  MAExplorer mae
          link to global MAExplorer instance
(package private) static int MAXBINS
          Break histogram into bins
private  int maxBinX
          ARG: maximum possible value range set by scrollers
private  int maxFreq
          maximum range of values found in binFreq[]
private  float maxX
          ARG: maximum possible value range set by scrollers
private  int meanBin
          mean bin intensity value for medianFreq
private  int meanFreq
          mean binFreq[]
private  float meanValue
          mean binFreq of weighted binFreq[]
private  int medianBin
          median bin intensity value for medianFreq
private  int medianFreq
          median binFreq[]
private  float medianH
          set from ms hist[] statistics
private  float medianValue
          median binFreq of binDataValue[]
(package private) static int MIN_CANVAS_HEIGHT
          default canvas height
(package private) static int MIN_CANVAS_WIDTH
          default canvas width
private  int minBinX
          ARG: minimum possible value range set by scrollers
private  int minFreq
          minimum range of values found in binFreq[]
private  float minX
          ARG: minimum possible value range set by scrollers
private  float modeH
          set from ms hist[] statistics
private  MaHybridSample ms
          link to global MaHybridSample instance
private  java.lang.String mTitle
          ARG: opt.
private  java.lang.String ncStr
          Info on genes in the current bin
(package private)  int nHist
          hist[0:nHist-1] of raw data.
private  java.lang.String oGifFileName
          full Gif file path name
private  boolean outsideRangeFlag
          for testing range
private  int plotMode
          ARG: plot mode
private  int pointType
          point type: DRAW _PLUS, _CIRCLE, _BOX
 int preferredHeight
          preferred canvas height
 int preferredWidth
          preferred canvas width
private  java.awt.Font smallFont
          font used for lableing
private  ShowPlotPopup spp
          ARG: parent window
(package private) static int TARGET_SIZE
          target Size for selecting a line
private  java.lang.String title
          title
private  java.lang.String vertCaption
          vertical caption
private  int[] x1
          x1 [0:MAXBINS-1] for clicking on point in list
private  int[] x2
          x2 [0:MAXBINS-1] for clicking on point in list
 
Fields inherited from class java.awt.Canvas
base, nameCounter, serialVersionUID
 
Fields inherited from class java.awt.Component
accessibleContext, actionListenerK, adjustmentListenerK, appContext, background, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, changeSupport, componentListener, componentListenerK, componentOrientation, componentSerializedDataVersion, containerListenerK, cursor, dbg, dropTarget, enabled, eventMask, focusListener, focusListenerK, font, foreground, graphicsConfig, hasFocus, height, hierarchyBoundsListener, hierarchyBoundsListenerK, hierarchyListener, hierarchyListenerK, incRate, inputMethodListener, inputMethodListenerK, isInc, isPacked, itemListenerK, keyListener, keyListenerK, LEFT_ALIGNMENT, locale, LOCK, metrics, minSize, mouseListener, mouseListenerK, mouseMotionListener, mouseMotionListenerK, name, nameExplicitlySet, newEventsOnly, ownedWindowK, parent, peer, peerFont, popups, prefSize, privateKey, RIGHT_ALIGNMENT, textListenerK, TOP_ALIGNMENT, valid, visible, width, windowClosingException, windowListenerK, x, y
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
(package private) DrawHistogram(MAExplorer mae, ShowPlotPopup spp, java.lang.String mTitle, java.lang.String horizVariableCaption, int plotMode)
          DrawHistogram() - constructor to create an intensity histogram.
 
Method Summary
(package private)  boolean drawGifFile(java.lang.String oGifFileName)
          drawGifFile() - draw plot into Gif image file if in stand-alone mode.
(package private)  void drawHistogram(java.awt.Graphics g)
          drawHistogram() - draw histogram of hist[].
private static void drawPlus(java.awt.Graphics g, int x, int y, java.awt.Color color)
          drawPlus() - draw plus sign at the specified color.
private  void drawRectangleBin(java.awt.Graphics g, int x, int y, int width, int height, java.awt.Color color, int bIdx, boolean fillIt)
          drawRectangleBin() - draw histogram bin at the specified color
(package private)  void filterByBin()
          filterByBin() - filter genes by current activeBin histogram bin(s).
 java.awt.Dimension getMinimumSize()
          getMinimumSize() - get the minimum preferred size
 java.awt.Dimension getPreferredSize()
          getPreferredSize() - get the preferred size
 void mouseClicked(java.awt.event.MouseEvent e)
           
 void mouseDragged(java.awt.event.MouseEvent e)
           
 void mouseEntered(java.awt.event.MouseEvent e)
           
 void mouseExited(java.awt.event.MouseEvent e)
           
 void mouseHandler(int x, int y)
          mouseHandler() - interact with current plot if a graphic plot.
 void mouseMoved(java.awt.event.MouseEvent e)
           
 void mousePressed(java.awt.event.MouseEvent e)
          mousePressed() - process mouse event
 void mouseReleased(java.awt.event.MouseEvent e)
           
 void paint(java.awt.Graphics g)
          paint() - draw the histogram
private  void setHistogramData(java.lang.String vertCaption, java.lang.String horizCaption, java.lang.String title, float minX, float maxX, float deltaBin, float modeH, float medianH, int pointType, int[] hist, int nHist)
          setHistogramData() - draw histogram of hist[0:nHist-1].
(package private)  void updateHistogramPlot()
          updateHistogramPlot() - set hist state and do repaint to draw it.
private  void updateSampleBins()
          updateSampleBins() - map hist[0:nHist-1] to binXXX[0:MAXBINS-1].
(package private)  void updateScaling(boolean logScalingFlag)
          updateScaling() - set scaling mode in proper sub-object.
(package private)  void updateScrolledRegion(float x1Pos, float x2Pos)
          updateScrolledRegion() - update scrolled region to plot
 
Methods inherited from class java.awt.Canvas
, addNotify, constructComponentName, getAccessibleContext, postsOldMouseEvents
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addPropertyChangeListener, addPropertyChangeListener, areInputMethodsEnabled, bounds, checkGD, checkImage, checkImage, checkWindowClosingException, coalesceEvents, contains, contains, createChildHierarchyEvents, createHierarchyEvents, createImage, createImage, deliverEvent, disable, disableEvents, dispatchEvent, dispatchEventImpl, doLayout, enable, enable, enableEvents, enableInputMethods, eventEnabled, firePropertyChange, getAccessibleIndexInParent, getAccessibleStateSet, getAlignmentX, getAlignmentY, getBackground, getBounds, getBounds, getColorModel, getComponentAt, getComponentAt, getComponentOrientation, getCursor, getDropTarget, getFont_NoClientCode, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getInputContext, getInputMethodRequests, getListeners, getLocale, getLocation, getLocation, getLocationOnScreen_NoTreeLock, getLocationOnScreen, getMaximumSize, getName, getNativeContainer, getParent_NoClientCode, getParent, getPeer, getSize, getSize, getToolkit, getToolkitImpl, getTreeLock, getWidth, getWindowForObject, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, initIDs, inside, invalidate, isDisplayable, isDoubleBuffered, isEnabled, isEnabledImpl, isFocusTraversable, isLightweight, isOpaque, isRecursivelyVisible, isShowing, isValid, isVisible, keyDown, keyUp, layout, lightweightPaint, lightweightPrint, list, list, list, list, list, locate, location, lostFocus, minimumSize, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, numListening, paintAll, paintHeavyweightComponents, paramString, postEvent, preferredSize, prepareImage, prepareImage, print, printAll, printHeavyweightComponents, processComponentEvent, processEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, readObject, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, resetGC, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFont, setForeground, setLocale, setLocation, setLocation, setName, setSize, setSize, setVisible, show, show, size, toString, transferFocus, update, validate, writeObject
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, wait, wait, wait
 

Field Detail

mae

private MAExplorer mae
link to global MAExplorer instance

ms

private MaHybridSample ms
link to global MaHybridSample instance

spp

private ShowPlotPopup spp
ARG: parent window

plotMode

private int plotMode
ARG: plot mode

mTitle

private java.lang.String mTitle
ARG: opt. title else generate one

MAXBINS

static final int MAXBINS
Break histogram into bins

MIN_CANVAS_WIDTH

static final int MIN_CANVAS_WIDTH
default canvas width

MIN_CANVAS_HEIGHT

static final int MIN_CANVAS_HEIGHT
default canvas height

TARGET_SIZE

static final int TARGET_SIZE
target Size for selecting a line

preferredHeight

public int preferredHeight
preferred canvas height

preferredWidth

public int preferredWidth
preferred canvas width

binFreq

private int[] binFreq
[0:MAXBINS] bins frequency for display

binDataValue

private float[] binDataValue
[0:MAXBINS] bins actual value @start of bin for display

x1

private int[] x1
x1 [0:MAXBINS-1] for clicking on point in list

x2

private int[] x2
x2 [0:MAXBINS-1] for clicking on point in list

cvPrecision

private int cvPrecision
precision in intensity data report

iWidth

private int iWidth
working canvas width

iHeight

private int iHeight
working canvas height

oGifFileName

private java.lang.String oGifFileName
full Gif file path name

ncStr

private java.lang.String ncStr
Info on genes in the current bin

vertCaption

private java.lang.String vertCaption
vertical caption

horizCaption

private java.lang.String horizCaption
horizontal caption

horizVariableCaption

private java.lang.String horizVariableCaption
horizontal variable caption

title

private java.lang.String title
title

intensL

private int intensL
idx lower intensity range binDataValue[] space

intensU

private int intensU
idx upper intensity range binDataValue[] space

minFreq

private int minFreq
minimum range of values found in binFreq[]

maxFreq

private int maxFreq
maximum range of values found in binFreq[]

meanFreq

private int meanFreq
mean binFreq[]

medianFreq

private int medianFreq
median binFreq[]

meanBin

private int meanBin
mean bin intensity value for medianFreq

medianBin

private int medianBin
median bin intensity value for medianFreq

minBinX

private int minBinX
ARG: minimum possible value range set by scrollers

maxBinX

private int maxBinX
ARG: maximum possible value range set by scrollers

deltaBin

private float deltaBin
value of hist[] bin in [minX:maxX]

meanValue

private float meanValue
mean binFreq of weighted binFreq[]

medianValue

private float medianValue
median binFreq of binDataValue[]

modeH

private float modeH
set from ms hist[] statistics

medianH

private float medianH
set from ms hist[] statistics

minX

private float minX
ARG: minimum possible value range set by scrollers

maxX

private float maxX
ARG: maximum possible value range set by scrollers

pointType

private int pointType
point type: DRAW _PLUS, _CIRCLE, _BOX

hist

private int[] hist
freq hist[0:nHist-1].

activeBin

int activeBin
active bin idx [0:MAXBINS-1] else -1

nHist

int nHist
hist[0:nHist-1] of raw data. nHist should be MAExplorer.MAX_INTENSITY

drawIntoImageFlag

private boolean drawIntoImageFlag
set if draw plot to GIF file

outsideRangeFlag

private boolean outsideRangeFlag
for testing range

logScalingFlag

private boolean logScalingFlag
Linear(false)/Log(true)

smallFont

private java.awt.Font smallFont
font used for lableing
Constructor Detail

DrawHistogram

DrawHistogram(MAExplorer mae,
              ShowPlotPopup spp,
              java.lang.String mTitle,
              java.lang.String horizVariableCaption,
              int plotMode)
DrawHistogram() - constructor to create an intensity histogram.
Parameters:
mae - is the MAExplorer instance
spp - is the ShowPlotPopup instance
mTitle - is window title
horizVariableCaption - is horizontal caption
plotMode - is the specific plot mode to implement
See Also:
MaHybridSample.calcIntensHist(), updateHistogramPlot()
Method Detail

drawGifFile

boolean drawGifFile(java.lang.String oGifFileName)
drawGifFile() - draw plot into Gif image file if in stand-alone mode. This sets it up and lets paint() to the heavy lifting...
Parameters:
oGifFileName - is the full path GIF output file
Returns:
true if successful

getPreferredSize

public java.awt.Dimension getPreferredSize()
getPreferredSize() - get the preferred size
Overrides:
getPreferredSize in class java.awt.Component
Returns:
window size

getMinimumSize

public java.awt.Dimension getMinimumSize()
getMinimumSize() - get the minimum preferred size
Overrides:
getMinimumSize in class java.awt.Component
Returns:
window size

updateHistogramPlot

void updateHistogramPlot()
updateHistogramPlot() - set hist state and do repaint to draw it.
See Also:
MaHybridSample.calcIntensHist(), setHistogramData(java.lang.String, java.lang.String, java.lang.String, float, float, float, float, float, int, int[], int)

updateScrolledRegion

void updateScrolledRegion(float x1Pos,
                          float x2Pos)
updateScrolledRegion() - update scrolled region to plot
Parameters:
x1Pos - is x1 position in the range 0.0:1.0
x2Pos - is x2 position in the range 0.0:1.0
See Also:
setHistogramData(java.lang.String, java.lang.String, java.lang.String, float, float, float, float, float, int, int[], int)

setHistogramData

private void setHistogramData(java.lang.String vertCaption,
                              java.lang.String horizCaption,
                              java.lang.String title,
                              float minX,
                              float maxX,
                              float deltaBin,
                              float modeH,
                              float medianH,
                              int pointType,
                              int[] hist,
                              int nHist)
setHistogramData() - draw histogram of hist[0:nHist-1]. Rescale it to 300x400 canvas.
Parameters:
vertCaption - is vertical caption
horizCaption - is horizontal caption
title - for window
minX - is min range to display
maxX - is max range to display
deltaBin - is width of a histogram bin
modeH - the mode computed from histogram
medianH - the median computed from histogram
pointType - (type of symbol)
hist - is the intensity freqency hist[0:MAXINTENS]
nHist - is the number of bins in hist[0:npoints-1]
See Also:
Component.repaint(), updateSampleBins()

updateSampleBins

private void updateSampleBins()
updateSampleBins() - map hist[0:nHist-1] to binXXX[0:MAXBINS-1]. Where binXXX[] is binFreq[], binDataValue[]. Given the data value range [minX:maxX], map hist[0:nHist-1] to binXXX[0:MAXBINS-1]. Also compute minFreq, maxFreq, meanValue, medianValue

paint

public void paint(java.awt.Graphics g)
paint() - draw the histogram
Overrides:
paint in class java.awt.Canvas
Parameters:
g - is graphics context
See Also:
drawHistogram(java.awt.Graphics)

drawPlus

private static final void drawPlus(java.awt.Graphics g,
                                   int x,
                                   int y,
                                   java.awt.Color color)
drawPlus() - draw plus sign at the specified color.
Parameters:
g - is graphics context
x - is center of object
y - is center of object
color - is color to draw

drawRectangleBin

private final void drawRectangleBin(java.awt.Graphics g,
                                    int x,
                                    int y,
                                    int width,
                                    int height,
                                    java.awt.Color color,
                                    int bIdx,
                                    boolean fillIt)
drawRectangleBin() - draw histogram bin at the specified color
Parameters:
g - is graphics context
x - is center of object
y - is center of object
width - of object
height - of object
color - is color to draw
fillit - to draw a solid object

drawHistogram

void drawHistogram(java.awt.Graphics g)
drawHistogram() - draw histogram of hist[]. Rescale it to 300x400 size canvas.
Parameters:
g - is graphics context
See Also:
Util.showMsg(java.lang.String), WriteGifEncoder, WriteGifEncoder.writeFile(java.lang.String), drawHistogram(java.awt.Graphics), drawRectangleBin(java.awt.Graphics, int, int, int, int, java.awt.Color, int, boolean), Component.repaint()

filterByBin

void filterByBin()
filterByBin() - filter genes by current activeBin histogram bin(s). Use the spp.histBinRange range to set the desired thresholds. If get a hit, then display data for the gene. If do not get a hit, then clear the filter. Note: because there is only ONE plot so can't get into trouble with multiple plots.
See Also:
Filter.computeWorkingGeneList(), CompositeDatabase.setIntensHistCLfromIntenRange(GeneList, MaHybridSample, float, float, boolean), Component.repaint(), Util.cvf2s(float, int), Util.saveCmdHistory(java.lang.String), Util.showMsg2(java.lang.String), Util.showMsg3(java.lang.String), Component.repaint()

mouseHandler

public void mouseHandler(int x,
                         int y)
mouseHandler() - interact with current plot if a graphic plot. If get a hit, then display data for the gene. Note: because there is only ONE plot so can't get into trouble with multiple plots.
Parameters:
x - mouse position
y - mouse position
See Also:
filterByBin()

mousePressed

public void mousePressed(java.awt.event.MouseEvent e)
mousePressed() - process mouse event
Specified by:
mousePressed in interface java.awt.event.MouseListener
Parameters:
e - is mouse pressed event
See Also:
mouseHandler(int, int)

mouseClicked

public void mouseClicked(java.awt.event.MouseEvent e)
Specified by:
mouseClicked in interface java.awt.event.MouseListener

mouseEntered

public void mouseEntered(java.awt.event.MouseEvent e)
Specified by:
mouseEntered in interface java.awt.event.MouseListener

mouseExited

public void mouseExited(java.awt.event.MouseEvent e)
Specified by:
mouseExited in interface java.awt.event.MouseListener

mouseReleased

public void mouseReleased(java.awt.event.MouseEvent e)
Specified by:
mouseReleased in interface java.awt.event.MouseListener

mouseMoved

public void mouseMoved(java.awt.event.MouseEvent e)

mouseDragged

public void mouseDragged(java.awt.event.MouseEvent e)

updateScaling

void updateScaling(boolean logScalingFlag)
updateScaling() - set scaling mode in proper sub-object. Linear(false)/Log(true)
Parameters:
logScalingFlag - if using log scaling
See Also:
filterByBin()