Class DrawRatioHistogram

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

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

This class draws a ratio histogram on an extended Canvas. 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: 2003/02/18 18:02:26 $ $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
private  int activeBin
          active bin # [0:nHist] else -1
private  int[] binIndex
          corresponding hist bin index
private  CompositeDatabase cdb
          link to global instance
private  int curXbinIdx
          index of X axis for data arrays
private  boolean drawIntoImageFlag
          set if draw plot to GIF file
private  int[] histRatio
          freq bin hist[0:nHist-1].
private  double[] histValue
          value bin hist[0:nHist-1].
private  java.lang.String horizCaption
          horizontal caption
private  java.lang.String horizVariableCaption
          horizontal variable caption
private  int iHeight
           
private  int iWidth
           
private  boolean logScalingFlag
          Linear(false)/Log(true)
private  MAExplorer mae
          link to global instance
private  double maxX
          ARG: maximum possible value range set by scrollers
private  double maxXfound
          min value of range of values found
(package private) static int MIN_CANVAS_HEIGHT
           
(package private) static int MIN_CANVAS_WIDTH
           
private  double minX
          ARG: minimum possible value range set by scrollers
private  double minXfound
          min value of range of values found
private  java.lang.String ncStr
          Info on genes in the current bin
private  int nHist
          hist[0:npoints-1]
private  java.lang.String oGifFileName
          full Gif file path name
private  boolean outsideRangeFlag
          for testing range
private  java.awt.Canvas pCanvas
          canvas used to draw ratio histogram
private  int plotMode
          plot mode
private  int pointType
          point type: DRAW _PLUS, _CIRCLE, _BOX
 int preferredHeight
           
 int preferredWidth
           
private  float ratioLower
          lower range of histogram values
private  float ratioUpper
          upper range of histogram values
private  java.awt.Font smallFont
          font used for lableing
private  ShowPlotPopup spp
          link to global instance
(package private) static int TARGET_SIZE
          target Size for selecting a line
private  java.lang.String title
          title
private  java.lang.String titleX
          X title
private  java.lang.String titleY
          Y title
private  java.lang.String vertCaption
          vertical caption
private  int[] x1
          X2 [1:nHist] for clicking on point in list
private  int[] x2
          X2 [1:nHist] 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) DrawRatioHistogram(MAExplorer mae, ShowPlotPopup spp, int plotMode)
          DrawRatioHistogram() - constructor to draw ratio 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 drawHistogramRatios(java.awt.Graphics g)
          drawHistogramRatios() - draw histogram of rg.ratioHist[].
(package private) static void drawPlus(java.awt.Graphics g, int x, int y, java.awt.Color color)
          drawPlus() - draw plus sign in the specified color.
(package private)  void drawRectangleBin(java.awt.Graphics g, int x, int y, int width, int height, java.awt.Color color, int binIdx, boolean fillIt)
          drawRectangleBin() - draw histogram bin
(package private)  void filterByBin()
          filterByBin() - filter genes by current activeBin histogram bin.
 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
(package private)  void setHistogramRatiosData(java.lang.String vertCaption, java.lang.String horizCaption, java.lang.String title, java.lang.String titleX, java.lang.String titleY, double minX, double maxX, int pointType, int[] histRatio, double[] histValue, int nHist)
          setHistogramRatiosData() - draw histogram of rg.ratioHist[].
(package private)  void updateRatioHistogramPlot()
          updateRatioHistogramPlot() - set ratioHist state & do repaint to draw it.
(package private)  void updateScaling(boolean logScalingFlag)
          updateScaling() - set scaling mode in proper sub-object.
 
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 instance

cdb

private CompositeDatabase cdb
link to global instance

spp

private ShowPlotPopup spp
link to global instance

plotMode

private int plotMode
plot mode

pCanvas

private java.awt.Canvas pCanvas
canvas used to draw ratio histogram

MIN_CANVAS_WIDTH

static final int MIN_CANVAS_WIDTH

MIN_CANVAS_HEIGHT

static final int MIN_CANVAS_HEIGHT

TARGET_SIZE

static final int TARGET_SIZE
target Size for selecting a line

preferredHeight

public int preferredHeight

preferredWidth

public int preferredWidth

x1

private int[] x1
X2 [1:nHist] for clicking on point in list

x2

private int[] x2
X2 [1:nHist] for clicking on point in list

binIndex

private int[] binIndex
corresponding hist bin index

iWidth

private int iWidth

iHeight

private int iHeight

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

titleX

private java.lang.String titleX
X title

titleY

private java.lang.String titleY
Y title

minXfound

private double minXfound
min value of range of values found

maxXfound

private double maxXfound
min value of range of values found

minX

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

maxX

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

pointType

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

histRatio

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

histValue

private double[] histValue
value bin hist[0:nHist-1].

curXbinIdx

private int curXbinIdx
index of X axis for data arrays

activeBin

private int activeBin
active bin # [0:nHist] else -1

nHist

private int nHist
hist[0:npoints-1]

ratioLower

private float ratioLower
lower range of histogram values

ratioUpper

private float ratioUpper
upper range of histogram values

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

DrawRatioHistogram

DrawRatioHistogram(MAExplorer mae,
                   ShowPlotPopup spp,
                   int plotMode)
DrawRatioHistogram() - constructor to draw ratio histogram
Parameters:
mae - is the MAExplorer instance
spp - is the ShowPlotPopup instance
plotMode - is the specific plot mode to implement
See Also:
updateRatioHistogramPlot()
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
See Also:
Component.repaint()

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

updateRatioHistogramPlot

void updateRatioHistogramPlot()
updateRatioHistogramPlot() - set ratioHist state & do repaint to draw it. Does {PLOT_HIST_F1F2_RATIO, PLOT_HIST_HP_XY_RATIO, PLOT_HIST_HP_XY_SETS_RATIO }. [CHECK] compute hist of SETS of X and Y microarray samples.
See Also:
CompositeDatabase.calcHistOfF1F2Ratios(GeneList, MaHybridSample), CompositeDatabase.calcHistOfHP_XYratios(GeneList, boolean), setHistogramRatiosData(java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, double, double, int, int[], double[], int)

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:
drawHistogramRatios(java.awt.Graphics)

drawPlus

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

drawRectangleBin

final void drawRectangleBin(java.awt.Graphics g,
                            int x,
                            int y,
                            int width,
                            int height,
                            java.awt.Color color,
                            int binIdx,
                            boolean fillIt)
drawRectangleBin() - draw histogram bin
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

setHistogramRatiosData

void setHistogramRatiosData(java.lang.String vertCaption,
                            java.lang.String horizCaption,
                            java.lang.String title,
                            java.lang.String titleX,
                            java.lang.String titleY,
                            double minX,
                            double maxX,
                            int pointType,
                            int[] histRatio,
                            double[] histValue,
                            int nHist)
setHistogramRatiosData() - draw histogram of rg.ratioHist[]. Rescale it to 300x400 canvas.
Parameters:
vertCaption - is the vertical caption
horizCaption -  
title - is the window title
titleX - is the X axis title
titleY - is the Y axis title
minX - is lowest X axis value
maxX - is highest X axis value
pointType - is either DRAW _PLUS, _CIRCLE, _BOX
histRatio - is the ratios of the ratio histogram
histValue - is the bin values frequencies of the ratio histogram
nHist - is the number of points in hist[0:npoints-1]
See Also:
Util.showMsg(java.lang.String), drawRectangleBin(java.awt.Graphics, int, int, int, int, java.awt.Color, int, boolean), Component.repaint()

drawHistogramRatios

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

filterByBin

void filterByBin()
filterByBin() - filter genes by current activeBin histogram bin. Use the spp.histBinRange range to set the desired thresholds. Both nHist>0 and activeBin>=0 to do filtering. If get a hit, then display data for the gene.
See Also:
CompositeDatabase.setRatioHistCLfromF1F2Ratios(GeneList, MaHybridSample, float, float, boolean), CompositeDatabase.setRatioHistCLfromHP_XYratios(GeneList, MaHybridSample, MaHybridSample, float, float, boolean), CompositeDatabase.setRatioHistCLfromHP_XYsetRatios(GeneList, float, float, boolean), Filter.computeWorkingGeneList(), 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.
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) [DEPRICATED]
Parameters:
logScalingFlag - if using log scaling
See Also:
filterByBin()