trex.GUI
Class HistoPanel

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--javax.swing.JComponent
                    |
                    +--javax.swing.JPanel
                          |
                          +--trex.GUI.HistoPanel
All Implemented Interfaces:
Accessible, ImageObserver, MenuContainer, Serializable

public class HistoPanel
extends JPanel

This class provides a panel for (possibly two concurrent) histograms of ImageIcons.

Version:
$Revision: 1.4 $
Author:
Bastian Friedrich <bastian@bastian-friedrich.de>
See Also:
Serialized Form

Nested Class Summary
 
Nested classes inherited from class javax.swing.JPanel
JPanel.AccessibleJPanel
 
Nested classes inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
 
Nested classes inherited from class java.awt.Container
Container.AccessibleAWTContainer
 
Nested classes inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BltBufferStrategy, Component.FlipBufferStrategy
 
Field Summary
static int CHANNEL_BLUE
          Display Histogram for blue channel
static int CHANNEL_GREEN
          Display Histogram for green channel
static int CHANNEL_RED
          Display Histogram for red channel
static int CHANNEL_VALUE
          Display Histogram for value
 
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
HistoPanel(Frame parent, ImageIcon img1, ImageIcon img2, Color color1, Color color2, String colExpl, int height, int channel)
          Constructor.
 
Method Summary
protected static int[] collectBins(Frame parent, ImageIcon img, int channel)
          Grab pixels from image and create histogram bins.
protected static int[] collectBins(int[] pixels, int channel)
          Create histogram bins.
static ImageIcon createHisto(Frame parent, ImageIcon img, int border, int height, Color color, int channel)
          Create the actual histogram image.
 void setImg1(ImageIcon img)
          Set image1.
 void setImg2(ImageIcon img)
          Set image2.
 
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getGraphics, getHeight, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPreferredSize, getPropertyChangeListeners, getPropertyChangeListeners, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFont, setForeground, 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, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, 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, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, 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, processMouseEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, 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

CHANNEL_VALUE

public static final int CHANNEL_VALUE
Display Histogram for value

See Also:
Constant Field Values

CHANNEL_RED

public static final int CHANNEL_RED
Display Histogram for red channel

See Also:
Constant Field Values

CHANNEL_GREEN

public static final int CHANNEL_GREEN
Display Histogram for green channel

See Also:
Constant Field Values

CHANNEL_BLUE

public static final int CHANNEL_BLUE
Display Histogram for blue channel

See Also:
Constant Field Values
Constructor Detail

HistoPanel

public HistoPanel(Frame parent,
                  ImageIcon img1,
                  ImageIcon img2,
                  Color color1,
                  Color color2,
                  String colExpl,
                  int height,
                  int channel)
Constructor. Initializes Data and Panel.

Parameters:
parent - Parent window (for message boxes).
img1 - First image to draw histogram for.
img2 - Second image to draw histogram for.
color1 - Color of first histogram.
color2 - Color of second histogram.
colExpl - Text string to inform user of color uses.
height - Image height.
channel - The channel to draw histogram for (CHANNEL_VALUE, CHANNEL_RED, CHANNEL_GREEN or CHANNEL_BLUE).
Method Detail

collectBins

protected static int[] collectBins(int[] pixels,
                                   int channel)
Create histogram bins. All pixels from the array are counted and put in to their respective bins.

Parameters:
pixels - Pixel data.
channel - Channel to display (CHANNEL_VALUE, CHANNEL_RED, CHANNEL_GREEN or CHANNEL_BLUE).
Returns:
The bin array.

collectBins

protected static int[] collectBins(Frame parent,
                                   ImageIcon img,
                                   int channel)
Grab pixels from image and create histogram bins. In fact this method only grabs pixel data and alls collectBins(int[], int).

Parameters:
parent - Parent window.
img - Image to grab pixels from.
channel - Channel to create bins of (see static fields).
Returns:
The bin array.

createHisto

public static ImageIcon createHisto(Frame parent,
                                    ImageIcon img,
                                    int border,
                                    int height,
                                    Color color,
                                    int channel)
Create the actual histogram image.

Parameters:
parent - Parent window (for Message boxes).
img - Image to create histogram for.
border - Empty (unused) border around actual histogram.
height - Image height.
color - Color of histo lines.
channel - The channel to draw histogram for (CHANNEL_VALUE, CHANNEL_RED, CHANNEL_GREEN or CHANNEL_BLUE).
Returns:
An ImageIcon containing the histogram.

setImg1

public void setImg1(ImageIcon img)
Set image1.

Parameters:
img - Image to set as image 1.

setImg2

public void setImg2(ImageIcon img)
Set image2.

Parameters:
img - Image to set as image 2.