Seg2Dgel
Class Sg2drawHistogram

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by javax.swing.JPanel
                  extended by Seg2Dgel.Sg2drawHistogram
All Implemented Interfaces:
java.awt.event.MouseListener, java.awt.event.MouseMotionListener, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, java.util.EventListener, javax.accessibility.Accessible

public class Sg2drawHistogram
extends javax.swing.JPanel
implements java.awt.event.MouseListener, java.awt.event.MouseMotionListener

Class Sg2drawHistogram is used to draw an image intensity histogram

Refactored from Sg2showImage By Greg Thornwall, SAIC.

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 Open2Dprot Mozilla and Legal files are available on http://Open2Dprot.sourceforge.net/.

Version:
$Date: 2005/10/21 17:08:03 $ $Revision: 1.5 $
Author:
P. Lemkin, NCI-Frederick, Frederick, MD, 21702
See Also:
Open2Dprot Home, Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JPanel
javax.swing.JPanel.AccessibleJPanel
 
Nested classes/interfaces inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
 int activeBin
          active bin idx of SCALED sHist[0:nHist-1] else -1
private  java.awt.Color activeBinColor
          Active bin peak on histogram color
 float activeBinValue
          active bin data value corresponding to activeBinidx of SCALED sHist[0:nHist-1].
 float binScale
          sHist[] Bin width sampling or averaging distance computed as floating (nHist/nShist) to map hist[] to a sHist[] bin.
 boolean changeGuiFlag
          flag to indicating that the GUI may have changed and that it should be rebuilt.
private  int cHeight
          working canvas height
private  int cWidth
          working canvas width
private  java.lang.String dataName
          name of the data used in histogram
private  java.lang.String dataUnits
          data units abbreviation
 java.lang.String dispName
          Name of image to display after a segmentation
 char[] dispPixC
          Picture buffer char[] of image to display after a segmentation.
 java.lang.String dispPixFile
          File of image to display after a segmentation.
 int[] dispPixI
          Picture buffer int[] of image to display after a segmentation.
(package private)  java.awt.Dimension frameSize
          size of frame
 boolean hasHistFlag
          Histogram exists and should be drawn.
 boolean hasHistGUIflag
          flag to indicate that the GUI contains the Histogram sub-GUI
static int HIST_HEIGHT
          Height of the histogram
static int HIST_WIDTH
          Width of the histogram
private  java.awt.Color histColor
           
private  java.awt.Color histTopColor
           
 int histType
          type of data to use with the histogram
private  java.awt.Color labelColor
           
private  java.awt.Font largeFont
          medium font used for labeling
 float maxDataValue
          The maximum data value at hist[max index]
 int maxHistFreqValue
          The maximum frequency in hist[]
 int maxShistFreq
          max sHist Frequency in sHist value to be displayed
 int maxShistIdx
          max non-zero bin of sHist to be displayed
 int meanDataGrayValue
          mean non-zero data gray value of sHist to display for Image density
 float meanDataValue
          mean non-zero data value of sHist to be displayed
 int meanShistIdx
          mean non-zero bin of sHist to be displayed
private  java.awt.Color meanValueBinColor
          Mean value bin peak on histogram color
 int medianDataGrayValue
          median non-zero data gray value of sHist to display for Image density
 float medianDataValue
          median non-zero data value of sHist to be displayed
 int medianShistIdx
          median non-zero bin of sHist to be displayed
private  java.awt.Color medianValueBinColor
          Median value bin peak on histogram color
private  java.awt.Font mediumFont
          medium font used for labeling
 float minDataValue
          The minimum data value at hist[0]
 int minHistFreqValue
          The minimum frequency value in hist[]
 int minShistFreq
          min sHist Frequency in sHist value to be displayed
 int minShistIdx
          min non-zero bin of sHist to be displayed
 int modeDataGrayValue
          mode non-zero data gray value of sHist to display for Image density
 float modeDataValue
          mode non-zero data value of sHist to be displayed
 int modeShistIdx
          mode non-zero bin of sHist to be displayed
private  java.awt.Color modeValueBinColor
          Mode value bin peak on histogram color
 int nbrPassedFilter
          # of spots passing filter
private  int nShist
          size of input unscaled histogram[] data
private  java.awt.Color optBkgrdColor
           
 int preferredHeight
          preferred size of canvas
 int preferredWidth
          preferred size of canvas
 int roiX1
          ROI ULHC X
 int roiX2
          ROI LRHC X
 int roiY1
          ROI ULHC Y
 int roiY2
          ROI LRHC Y
 float scaleFreq
          sHist[] frequency scale factor computed as floating (maxHistFreq/nShist)
(package private) static long serialVersionUID
          frame id
private  Seg2Dgel sg2
          link to global instance
private  int[] sHist
          local SCALED histogram [0:nShist-1]data
private  int[] sHistDisp
          local SCALED histogram [0:nShist-1] scaled to max data value of nShist
private  Sg2showImage ssi
           
 boolean useFilterByBinFlag
          menu CB item to filter spots by testing if the histogram active bin is selected and histogram spot feature meets the active bin test
 boolean useHistGUIflag
          flag to use simple ImageViewer w/o histogram or full GUI with the histogram
 int xLRHC
          lower Y right hand corner of hist.
private  int[] xPainted
          local SCALED histogram X position
 int xULHC
          upper X left hand corner of hist.
 int yLRHC
          lower Y right hand corner of hist.
 int yULHC
          upper Y left hand corner of hist.
 
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
Sg2drawHistogram(Sg2showImage ssi, java.awt.Dimension frameSize, boolean useHistGUIflag, boolean useFilterByBinFlag)
          DrawHistogram() - create a blank histogram canvas
 
Method Summary
private  void drawFilledBox(java.awt.Graphics g, int xC, int yC, int width, java.awt.Color color)
          drawFilledBox() - draw plus sign at the specified color.
private  void drawFilledRectangle(java.awt.Graphics g, int x1, int x2, int y1, int y2, java.awt.Color color)
          drawFilledRectangle() - draw plus sign at the specified color.
private  boolean drawHistInCanvas(java.awt.Graphics g)
          drawHistInCanvas() - draw histogram of hist[].
 void mouseClicked(java.awt.event.MouseEvent e)
           
 void mouseDragged(java.awt.event.MouseEvent e)
          mouseDragged() - process mouse event
 void mouseEntered(java.awt.event.MouseEvent e)
           
 void mouseExited(java.awt.event.MouseEvent e)
           
 boolean mouseHandler(int x, int y)
          mouseHandler() - search for the active bin if any
 void mouseMoved(java.awt.event.MouseEvent e)
           
 void mousePressed(java.awt.event.MouseEvent e)
           
 void mouseReleased(java.awt.event.MouseEvent e)
          mouseReleased() - process mouse event
 void paint(java.awt.Graphics g)
          paint() - redraw the histogram
 boolean setHistData(java.lang.String title, boolean hasHistFlag, java.lang.String dataName, java.lang.String dataUnits, java.lang.String horizCaption, java.lang.String vertCaption, int[] hist, float minDataValue, float maxDataValue)
          setHistData() - set the hist data, title, Horiz and Vert captions and then repaint to start drawing it.
 
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, 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, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paintBorder, paintChildren, paintComponent, 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
 
Methods inherited from class java.awt.Container
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, 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, 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, hide, 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, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

serialVersionUID

static final long serialVersionUID
frame id

See Also:
Constant Field Values

HIST_WIDTH

public static final int HIST_WIDTH
Width of the histogram

See Also:
Constant Field Values

HIST_HEIGHT

public static final int HIST_HEIGHT
Height of the histogram

See Also:
Constant Field Values

ssi

private Sg2showImage ssi

sg2

private Seg2Dgel sg2
link to global instance


preferredWidth

public int preferredWidth
preferred size of canvas


preferredHeight

public int preferredHeight
preferred size of canvas


mediumFont

private java.awt.Font mediumFont
medium font used for labeling


largeFont

private java.awt.Font largeFont
medium font used for labeling


optBkgrdColor

private java.awt.Color optBkgrdColor

histColor

private java.awt.Color histColor

histTopColor

private java.awt.Color histTopColor

activeBinColor

private java.awt.Color activeBinColor
Active bin peak on histogram color


meanValueBinColor

private java.awt.Color meanValueBinColor
Mean value bin peak on histogram color


modeValueBinColor

private java.awt.Color modeValueBinColor
Mode value bin peak on histogram color


medianValueBinColor

private java.awt.Color medianValueBinColor
Median value bin peak on histogram color


labelColor

private java.awt.Color labelColor

frameSize

java.awt.Dimension frameSize
size of frame


cWidth

private int cWidth
working canvas width


cHeight

private int cHeight
working canvas height


dataName

private java.lang.String dataName
name of the data used in histogram


dataUnits

private java.lang.String dataUnits
data units abbreviation


sHist

private int[] sHist
local SCALED histogram [0:nShist-1]data


nShist

private int nShist
size of input unscaled histogram[] data


sHistDisp

private int[] sHistDisp
local SCALED histogram [0:nShist-1] scaled to max data value of nShist


xPainted

private int[] xPainted
local SCALED histogram X position


activeBin

public int activeBin
active bin idx of SCALED sHist[0:nHist-1] else -1


activeBinValue

public float activeBinValue
active bin data value corresponding to activeBinidx of SCALED sHist[0:nHist-1]. Only valid if activeBin is NEQ -1


xULHC

public int xULHC
upper X left hand corner of hist. graph


yULHC

public int yULHC
upper Y left hand corner of hist. graph


xLRHC

public int xLRHC
lower Y right hand corner of hist. graph


yLRHC

public int yLRHC
lower Y right hand corner of hist. graph


minShistIdx

public int minShistIdx
min non-zero bin of sHist to be displayed


maxShistIdx

public int maxShistIdx
max non-zero bin of sHist to be displayed


meanShistIdx

public int meanShistIdx
mean non-zero bin of sHist to be displayed


medianShistIdx

public int medianShistIdx
median non-zero bin of sHist to be displayed


modeShistIdx

public int modeShistIdx
mode non-zero bin of sHist to be displayed


minShistFreq

public int minShistFreq
min sHist Frequency in sHist value to be displayed


maxShistFreq

public int maxShistFreq
max sHist Frequency in sHist value to be displayed


minHistFreqValue

public int minHistFreqValue
The minimum frequency value in hist[]


maxHistFreqValue

public int maxHistFreqValue
The maximum frequency in hist[]


meanDataValue

public float meanDataValue
mean non-zero data value of sHist to be displayed


medianDataValue

public float medianDataValue
median non-zero data value of sHist to be displayed


modeDataValue

public float modeDataValue
mode non-zero data value of sHist to be displayed


meanDataGrayValue

public int meanDataGrayValue
mean non-zero data gray value of sHist to display for Image density


medianDataGrayValue

public int medianDataGrayValue
median non-zero data gray value of sHist to display for Image density


modeDataGrayValue

public int modeDataGrayValue
mode non-zero data gray value of sHist to display for Image density


minDataValue

public float minDataValue
The minimum data value at hist[0]


maxDataValue

public float maxDataValue
The maximum data value at hist[max index]


binScale

public float binScale
sHist[] Bin width sampling or averaging distance computed as floating (nHist/nShist) to map hist[] to a sHist[] bin.


scaleFreq

public float scaleFreq
sHist[] frequency scale factor computed as floating (maxHistFreq/nShist)


changeGuiFlag

public boolean changeGuiFlag
flag to indicating that the GUI may have changed and that it should be rebuilt.


hasHistGUIflag

public boolean hasHistGUIflag
flag to indicate that the GUI contains the Histogram sub-GUI


useHistGUIflag

public boolean useHistGUIflag
flag to use simple ImageViewer w/o histogram or full GUI with the histogram


roiX1

public int roiX1
ROI ULHC X


roiY1

public int roiY1
ROI ULHC Y


roiX2

public int roiX2
ROI LRHC X


roiY2

public int roiY2
ROI LRHC Y


dispName

public java.lang.String dispName
Name of image to display after a segmentation


dispPixI

public int[] dispPixI
Picture buffer int[] of image to display after a segmentation. Note this is read either from the pix? variable or from the file if the pix? variable is null.


dispPixC

public char[] dispPixC
Picture buffer char[] of image to display after a segmentation. Note this is read either from the pix? variable or from the file if the pix? variable is null.


dispPixFile

public java.lang.String dispPixFile
File of image to display after a segmentation. Used if dispPixI/C is null.


histType

public int histType
type of data to use with the histogram


useFilterByBinFlag

public boolean useFilterByBinFlag
menu CB item to filter spots by testing if the histogram active bin is selected and histogram spot feature meets the active bin test


nbrPassedFilter

public int nbrPassedFilter
# of spots passing filter


hasHistFlag

public boolean hasHistFlag
Histogram exists and should be drawn. This is cleared if we decide to blank out the histogram.

Constructor Detail

Sg2drawHistogram

public Sg2drawHistogram(Sg2showImage ssi,
                        java.awt.Dimension frameSize,
                        boolean useHistGUIflag,
                        boolean useFilterByBinFlag)
DrawHistogram() - create a blank histogram canvas

Parameters:
ssi - is Sg2showImage
frameSize - is size of canvas
Method Detail

setHistData

public boolean setHistData(java.lang.String title,
                           boolean hasHistFlag,
                           java.lang.String dataName,
                           java.lang.String dataUnits,
                           java.lang.String horizCaption,
                           java.lang.String vertCaption,
                           int[] hist,
                           float minDataValue,
                           float maxDataValue)
setHistData() - set the hist data, title, Horiz and Vert captions and then repaint to start drawing it. Rescale the hist[] to sHist[0:255].

Parameters:
title - title of histograms and should be drawn.
hasHistFlag - is cleared if we decide to blank out the histogram.
dataName - of the type of data used
dataUnits - of the type of data used
horizCaption - horizontal caption
vertCaption - vertical caption
hist - is the histogram array of any size
minDataValue - is the value the data at hist[0]
maxDataValue - is the value the data at hist[max index]
Returns:
true if succeed, false if there is a problem. i.e. no data

drawFilledBox

private final void drawFilledBox(java.awt.Graphics g,
                                 int xC,
                                 int yC,
                                 int width,
                                 java.awt.Color color)
drawFilledBox() - draw plus sign at the specified color.

Parameters:
g - is graphics context
x - is center of object
y - is center of object
width - is width of object
color - is color to draw

drawFilledRectangle

private final void drawFilledRectangle(java.awt.Graphics g,
                                       int x1,
                                       int x2,
                                       int y1,
                                       int y2,
                                       java.awt.Color color)
drawFilledRectangle() - draw plus sign at the specified color.

Parameters:
g - is graphics context
x1 - is Left edge
x1 - is Left edge
y1 - is top edge
color - is color to draw

drawHistInCanvas

private boolean drawHistInCanvas(java.awt.Graphics g)
drawHistInCanvas() - draw histogram of hist[]. NOTE: size is (ssi.HIST_WIDTH x ssi.HIST_HEIGHT)

Parameters:
g - is graphics context

paint

public void paint(java.awt.Graphics g)
paint() - redraw the histogram

Overrides:
paint in class javax.swing.JComponent
Parameters:
g - is graphics context
See Also:
drawHistInCanvas(java.awt.Graphics)

mouseHandler

public boolean mouseHandler(int x,
                            int y)
mouseHandler() - search for the active bin if any

Parameters:
x - mouse position
y - mouse position
Returns:
true if found it in the xPainted[] list and set activeBin to the index i in [0:255] else set activeBin to -1.

mouseDragged

public void mouseDragged(java.awt.event.MouseEvent e)
mouseDragged() - process mouse event

Specified by:
mouseDragged in interface java.awt.event.MouseMotionListener
Parameters:
e - is mouse pressed event

mouseReleased

public void mouseReleased(java.awt.event.MouseEvent e)
mouseReleased() - process mouse event

Specified by:
mouseReleased in interface java.awt.event.MouseListener
Parameters:
e - is mouse pressed event

mousePressed

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

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

mouseMoved

public void mouseMoved(java.awt.event.MouseEvent e)
Specified by:
mouseMoved in interface java.awt.event.MouseMotionListener