Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS | NEXT CLASS FRAMES  | NO FRAMES
SUMMARY:  INNER | FIELD | CONSTR | METHOD DETAIL:  FIELD | CONSTR | METHOD

Class ncsa.horizon.awt.color.HorizonColorModelEditor

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--java.awt.Panel
                    |
                    +--ncsa.horizon.awt.color.HorizonColorModelEditor

public class HorizonColorModelEditor
extends java.awt.Panel
implements java.awt.event.ActionListener, HorizonColorModelListener
a panel for editing a HorizonColorModel

This panel supports two modes of graphically tweaking a HorizonColorModel. First is through the color bar display at the top of the panel. Clicking and dragging the mouse on the bar will transform the color table: dragging left and right shifts the colors up and down, while dragging up and down stretches and compresses the colors. (One can also change the special colors--undefined, underflow, and overflow--see the HorizonColorModelDisplay for details.)

The second mode is by manipulating the color components seperately. In general, one can edit all four components--red, green, blue, and alpha--independently; however, if isAlphaVisible() returns false, only the RGB components are shown. For each component, a graph of the component values is shown along with tool buttons for maniputating them. The "Reset" button will restore the color model's original values for that component.

See Also:
Serialized Form

Field Summary
CurveEditPanel alpha_CMP
           
CurveEditPanel blue_CMP
           
static java.lang.String[] defaultModeNames
          the names of the default editing modes.
EditableColorModel ecm
           
CurveEditPanel green_CMP
           
HorizonColorModelDisplay HCMD
           
CurveEditPanel red_CMP
           
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Constructor Summary
HorizonColorModelEditor(EditableColorModel ecm)
          create an editor that operates on the given EditableColorModel
HorizonColorModelEditor(EditableColorModel ecm, boolean showAlpha)
          create an editor that operates on the given EditableColorModel
 
Method Summary
void actionPerformed(java.awt.event.ActionEvent e)
           
void addHorizonColorModelListener(HorizonColorModelListener l)
          add a listener of this editor.
void addMenusToFrame(java.awt.Frame f)
          add menu controls to the menu bar of a given frame.
void colorModelUpdate(ColorModelUpdateEvent e)
          forward ColorModelUpdateEvents from the current active color model to listeners of this editor.
StretchableColorModel getActiveColorModel()
          return the color model currently being edited.
static CurveEditMode[] getDefaultModes()
          create and return instances of the default editing modes used by this panel.
void invertColors()
          reverse the colors in the color table
boolean isAlphaVisible()
          return true if the subpanel used to edit the alpha component of the color model is visible.
void loadIntoActiveColorModel(HorizonColorModel cm)
          load the colors from a given HorizonColorModel into the current model being edited.
void loadIntoActiveColorModel(java.awt.image.IndexColorModel cm)
          load the colors from a given IndexColorModel into the current model being edited.
void loadIntoActiveColorModel(java.io.File file)
          load the colors from a file into the current model being edited.
static void main(java.lang.String[] args)
           
void removeAllListeners()
          remove all listeners
void removeHorizonColorModelListener(HorizonColorModelListener l)
          remove a listener
void setActiveColorModel(java.awt.image.IndexColorModel cm)
          replace the current color model being displayed.
void setActiveColorModel(HorizonColorModel cm)
          replace the current color model being displayed.
void setAlphaVisible(boolean b)
          show or hide the subpanel used to edit the alpha component of the color model.
 
Methods inherited from class java.awt.Panel
addNotify
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addNotify, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponentAt, getComponentAt, getComponent, getComponentCount, getComponents, getInsets, getLayout, getMaximumSize, getMinimumSize, getPreferredSize, insets, invalidate, isAncestorOf, layout, list, list, locate, minimumSize, paintComponents, paint, paramString, preferredSize, printComponents, print, processContainerEvent, processEvent, removeAll, remove, remove, removeContainerListener, removeNotify, setLayout, update, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, deliverEvent, disable, disableEvents, dispatchEvent, doLayout, enable, enable, enableEvents, enableInputMethods, firePropertyChange, getAlignmentX, getAlignmentY, getBackground, getBounds, getBounds, getColorModel, getComponentAt, getComponentAt, getComponentOrientation, getCursor, getDropTarget, getFont, getFontMetrics, getForeground, getGraphics, getHeight, getInputContext, getInputMethodRequests, getLocale, getLocation, getLocation, getLocationOnScreen, getMaximumSize, getMinimumSize, getName, getParent, getPeer, getPreferredSize, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, invalidate, isDisplayable, isDoubleBuffered, isEnabled, isFocusTraversable, isLightweight, isOpaque, isShowing, isValid, isVisible, keyDown, keyUp, layout, list, list, list, list, list, locate, location, lostFocus, minimumSize, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, paint, paramString, postEvent, preferredSize, prepareImage, prepareImage, printAll, print, processComponentEvent, processEvent, processFocusEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, remove, removeComponentListener, removeFocusListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, 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
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notifyAll, notify, toString, wait, wait, wait
 

Field Detail

red_CMP

protected CurveEditPanel red_CMP

green_CMP

protected CurveEditPanel green_CMP

blue_CMP

protected CurveEditPanel blue_CMP

alpha_CMP

protected CurveEditPanel alpha_CMP

HCMD

protected HorizonColorModelDisplay HCMD

ecm

protected EditableColorModel ecm

defaultModeNames

protected static java.lang.String[] defaultModeNames
the names of the default editing modes. For each name, there should be an image in the images directory (under the ncsa.horizon.awt.color package) with the file name modename.gif. This image will appear on the button that engages the editing mode. If such an image is not found, the string will be used as a simple label on the button.
Constructor Detail

HorizonColorModelEditor

public HorizonColorModelEditor(EditableColorModel ecm)
create an editor that operates on the given EditableColorModel

HorizonColorModelEditor

public HorizonColorModelEditor(EditableColorModel ecm,
                               boolean showAlpha)
create an editor that operates on the given EditableColorModel
Parameters:
ecm - the color model to edit
showAlpha - if false, do not show the canvas for editing alpha component of the color model
Method Detail

getDefaultModes

protected static CurveEditMode[] getDefaultModes()
create and return instances of the default editing modes used by this panel. Override this method (along with defaultModeNames) to add additional modes.

setAlphaVisible

public void setAlphaVisible(boolean b)
show or hide the subpanel used to edit the alpha component of the color model.

isAlphaVisible

public boolean isAlphaVisible()
return true if the subpanel used to edit the alpha component of the color model is visible.

actionPerformed

public void actionPerformed(java.awt.event.ActionEvent e)
Description copied from interface:
 
Specified by:
actionPerformed(java.awt.event.ActionEvent) in interface java.awt.event.ActionListener

setActiveColorModel

public void setActiveColorModel(java.awt.image.IndexColorModel cm)
replace the current color model being displayed. The given color will be wrapped as a StretchableColorModel; thus, the client of this class should call getActiveColorModel() after calling this method to get a reference to the actual color model being edited.
Parameters:
cm - a IndexColorModel

setActiveColorModel

public void setActiveColorModel(HorizonColorModel cm)
replace the current color model being displayed. If the given color model is not a StretchableColorModel, it will be wrapped as a one; thus, in this case, the client of this class should call getActiveColorModel() after calling this method to get a reference to the actual color model being edited.
Parameters:
cm - a HorizonColorModel

getActiveColorModel

public StretchableColorModel getActiveColorModel()
return the color model currently being edited.

loadIntoActiveColorModel

public void loadIntoActiveColorModel(HorizonColorModel cm)
load the colors from a given HorizonColorModel into the current model being edited. This will cause listeners to adapt accordingly. The input model's table will be scaled to fit into the current model

loadIntoActiveColorModel

public void loadIntoActiveColorModel(java.awt.image.IndexColorModel cm)
load the colors from a given IndexColorModel into the current model being edited. This will cause listeners to adapt accordingly. The input model's table will be scaled to fit into the current model

loadIntoActiveColorModel

public void loadIntoActiveColorModel(java.io.File file)
                             throws java.io.IOException
load the colors from a file into the current model being edited. This will cause listeners to adapt accordingly. The input model's table will be scaled to fit into the current model

invertColors

public void invertColors()
reverse the colors in the color table

addHorizonColorModelListener

public void addHorizonColorModelListener(HorizonColorModelListener l)
add a listener of this editor. This editor will forward changes made to its active color model onto its listeners.

removeHorizonColorModelListener

public void removeHorizonColorModelListener(HorizonColorModelListener l)
remove a listener

removeAllListeners

public void removeAllListeners()
remove all listeners

colorModelUpdate

public void colorModelUpdate(ColorModelUpdateEvent e)
forward ColorModelUpdateEvents from the current active color model to listeners of this editor. The source of the event sent will be this editor (rather than the color model itself).
Specified by:
colorModelUpdate in interface HorizonColorModelListener

addMenusToFrame

public void addMenusToFrame(java.awt.Frame f)
add menu controls to the menu bar of a given frame. If the Frame does not have a menu bar, one will be created.

main

public static void main(java.lang.String[] args)

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS | NEXT CLASS FRAMES  | NO FRAMES
SUMMARY:  INNER | FIELD | CONSTR | METHOD DETAIL:  FIELD | CONSTR | METHOD