jpl.mipl.mica.tools
Class BrightnessContrast

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 jpl.mipl.mica.tools.BrightnessContrast
All Implemented Interfaces:
ImageObserver, MenuContainer, PropertyChangeListener, Serializable, EventListener, Accessible

public class BrightnessContrast
extends JPanel
implements PropertyChangeListener

A BrightnessContrast tool (BnC) is a JavaBean that applies a JAI operator to change the appearance of an ImageChip. The operator is a JAI "Piecewise" operator to perform piecewise-linear remapping of the chip's pixel values. The tool uses this operator to independently control the brightness and contrast of the chip's image.

The tool adds, modifies, or removes the operator by using the ImageChip setOperation() method. The values of the operator ParameterBlock are read in from the current set of selected chips. If only one chip is in the set, then the piecewise point editor is activated and initialized. If no chip is selected, the entire list of ImageChips is used instead.

When the user clicks one of the brightness or contrast buttons, the appropriate increment or decrement "delta" algorithm is applied to each piecewise point in each chip in the selected set. When the user drags one of the points in the point editor, that point is modified accordingly in the single selected chip.

The "delta" algorithms are modelled on those of the well-known image processing program "XV." A brightness delta of +5% will move all piecewise mapping points 5% closer to the maximum value. A contrast delta of +5% will add a sinusoid to all points where the amplitude is 5% of the maximum value. In pseudocode:

point.y += 0.05*maxYValue * Math.sin( -point.x/maxXValue * 2.0*Math.PI );

Author:
SGT, Inc.
See Also:
BrightnessContrastBeanInfo, ImageChip, Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JPanel
JPanel.AccessibleJPanel
 
Nested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BltBufferStrategy, Component.FlipBufferStrategy
 
Field Summary
protected  PropertyChangeSupport butler
          A utility object used to manage PropertyChangeListeners.
protected  jpl.mipl.mica.tools.BrightnessContrast.IvjEventHandler ivjEventHandler
          Instance of the inner class to handle GUI feedback.
 
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
BrightnessContrast()
          Constructor.
 
Method Summary
 void addNotify()
          Adds this tool as a PropertyChangeListener for "Selection" and "Operation" property change events.
 void addPropertyChangeListener(PropertyChangeListener listener)
          Adds a PropertyChangeListener to be notified when any bound properties change.
 void addPropertyChangeListener(String propertyName, PropertyChangeListener listener)
          Adds a PropertyChangeListener to be notified when a given bound property changes.
 void brightnessDown_ActionPerformed(ActionEvent actionEvent)
          Handle button click.
 void brightnessUp_ActionPerformed(ActionEvent actionEvent)
          Handle button click.
 void contrastDown_ActionPerformed(ActionEvent actionEvent)
          Handle button click.
 void contrastUp_ActionPerformed(ActionEvent actionEvent)
          Handle button click.
static void main(String[] args)
          main entrypoint - starts the part when it is run as an application
 void propertyChange(PropertyChangeEvent evt)
          Handles a selection property change or a change to an operator with "BrightnessContrast" as its key value.
 void removeNotify()
          Removes this tool as a PropertyChangeListener from the MICA system.
 void removePropertyChangeListener(PropertyChangeListener listener)
          Removes a PropertyChangeListener.
 void resetButton_ActionPerformed(ActionEvent actionEvent)
          Resets all values to their initial state when the reset button is pressed.
 
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, 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, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, 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, 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, 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

butler

protected PropertyChangeSupport butler
A utility object used to manage PropertyChangeListeners.


ivjEventHandler

protected jpl.mipl.mica.tools.BrightnessContrast.IvjEventHandler ivjEventHandler
Instance of the inner class to handle GUI feedback.

Constructor Detail

BrightnessContrast

public BrightnessContrast()
Constructor. Initializes GUI elements.

Method Detail

removeNotify

public void removeNotify()
Removes this tool as a PropertyChangeListener from the MICA system.

Overrides:
removeNotify in class JComponent

addNotify

public void addNotify()
Adds this tool as a PropertyChangeListener for "Selection" and "Operation" property change events.

Overrides:
addNotify in class JComponent

propertyChange

public void propertyChange(PropertyChangeEvent evt)
Handles a selection property change or a change to an operator with "BrightnessContrast" as its key value. Determines the new selection (or no chips) and resets the piecewise point editor.

Specified by:
propertyChange in interface PropertyChangeListener

addPropertyChangeListener

public void addPropertyChangeListener(PropertyChangeListener listener)
Adds a PropertyChangeListener to be notified when any bound properties change.

Overrides:
addPropertyChangeListener in class Container

addPropertyChangeListener

public void addPropertyChangeListener(String propertyName,
                                      PropertyChangeListener listener)
Adds a PropertyChangeListener to be notified when a given bound property changes.

Overrides:
addPropertyChangeListener in class Container

removePropertyChangeListener

public void removePropertyChangeListener(PropertyChangeListener listener)
Removes a PropertyChangeListener.

Overrides:
removePropertyChangeListener in class Component

brightnessUp_ActionPerformed

public void brightnessUp_ActionPerformed(ActionEvent actionEvent)
Handle button click. Increments brightness by 5%.


brightnessDown_ActionPerformed

public void brightnessDown_ActionPerformed(ActionEvent actionEvent)
Handle button click. Decrements brightness by 5%.


contrastUp_ActionPerformed

public void contrastUp_ActionPerformed(ActionEvent actionEvent)
Handle button click. Increments contrast by 5%.


contrastDown_ActionPerformed

public void contrastDown_ActionPerformed(ActionEvent actionEvent)
Handle button click. Decrements contrast by 5%.


main

public static void main(String[] args)
main entrypoint - starts the part when it is run as an application

Parameters:
args - java.lang.String[]

resetButton_ActionPerformed

public void resetButton_ActionPerformed(ActionEvent actionEvent)
Resets all values to their initial state when the reset button is pressed.