net.grelf.image
Class HistogramAll

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by net.grelf.image.HistogramAll
All Implemented Interfaces:
java.awt.image.ImageObserver, java.awt.MenuContainer, java.awt.print.Printable, java.io.Serializable
Direct Known Subclasses:
Histogram

public class HistogramAll
extends javax.swing.JComponent
implements java.awt.print.Printable

A histogram of the whole of an image comprising any number of bands.

See Also:
Serialized Form

Nested Class Summary
 
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.BaselineResizeBehavior, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
protected  int[][] fbin
           
protected  int[][] freq
           
protected static int MAX_NLEVELS
           
protected  int nBands
           
protected  int nLevels
           
protected  int scale
           
protected  java.lang.String[] xLabels
           
 
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.print.Printable
NO_SUCH_PAGE, PAGE_EXISTS
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
protected HistogramAll()
          Only for sub-class: must have an image to build the data from.
  HistogramAll(Image image)
          Histogram of a whole Image.
 
Method Summary
protected  void buildData(Image image)
          Analyse the whole image
 void draw(java.awt.Graphics2D g2, int xOffset, int yOffset)
          Draw a graph of the histogram in the given graphics context (screen or printer) at the given offset position.
 void equalise(Image image)
           
 int[] getMaxValues()
          Get array of maximum values for each channel (red, green and blue in the 3-channel case).
 int[] getMinValues()
          Get array of minimum values for each channel (red, green and blue in the 3-channel case).
 int[] getModes()
          Get array of modal values for each channel (red, green and blue in the 3-channel case).
 int[] getModes(int start, int end)
          Get array of modal values, using only levels from start to end inclusive.
 Statistics[] getStatistics()
          Calculate all statistics, returning as an array index by channel (band).
 Statistics[] getStatistics(int start, int end)
          Calculate all statistics, returning as an array index by channel (band).
 void paintComponent(java.awt.Graphics g)
           
 int print(java.awt.Graphics g, java.awt.print.PageFormat pf, int pageNo)
          Print the histogram.
protected  void reBin()
          For plotting as 256 bins wide.
 void saveCSV()
          Save the histogram as a comma-separated-value file, suitable for loading into spreadsheets.
 void saveXML()
          Save the histogram as an XML file.
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getAccessibleContext, 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, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintImmediately, paintImmediately, paramString, 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, updateUI
 
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

nLevels

protected int nLevels

nBands

protected int nBands

freq

protected int[][] freq

scale

protected int scale

MAX_NLEVELS

protected static final int MAX_NLEVELS

fbin

protected int[][] fbin

xLabels

protected java.lang.String[] xLabels
Constructor Detail

HistogramAll

protected HistogramAll()
Only for sub-class: must have an image to build the data from.


HistogramAll

public HistogramAll(Image image)
Histogram of a whole Image.

Method Detail

buildData

protected void buildData(Image image)
Analyse the whole image


reBin

protected void reBin()
For plotting as 256 bins wide.


equalise

public void equalise(Image image)

getMaxValues

public int[] getMaxValues()
Get array of maximum values for each channel (red, green and blue in the 3-channel case).


getMinValues

public int[] getMinValues()
Get array of minimum values for each channel (red, green and blue in the 3-channel case).


getModes

public int[] getModes()
Get array of modal values for each channel (red, green and blue in the 3-channel case).


getModes

public int[] getModes(int start,
                      int end)
Get array of modal values, using only levels from start to end inclusive.


getStatistics

public Statistics[] getStatistics(int start,
                                  int end)
Calculate all statistics, returning as an array index by channel (band). Only consider grey levels from start to end in every channel.


getStatistics

public Statistics[] getStatistics()
Calculate all statistics, returning as an array index by channel (band).


draw

public void draw(java.awt.Graphics2D g2,
                 int xOffset,
                 int yOffset)
Draw a graph of the histogram in the given graphics context (screen or printer) at the given offset position.


paintComponent

public void paintComponent(java.awt.Graphics g)
Overrides:
paintComponent in class javax.swing.JComponent

print

public int print(java.awt.Graphics g,
                 java.awt.print.PageFormat pf,
                 int pageNo)
          throws java.awt.print.PrinterException
Print the histogram.

Specified by:
print in interface java.awt.print.Printable
Throws:
java.awt.print.PrinterException

saveCSV

public void saveCSV()
Save the histogram as a comma-separated-value file, suitable for loading into spreadsheets.


saveXML

public void saveXML()
Save the histogram as an XML file.