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.HorizonColorBar

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Canvas
              |
              +--ncsa.horizon.awt.color.HorizonColorBar

public class HorizonColorBar
extends java.awt.Canvas
HorizonColorBar displays an indexed colormodel in a retangular canvas.

Indexed ColorModels can be passed to this class (via the constructor or the setActiveColorModel() method) in the form of an IndexColorModel, a HorizonColorModel, or a StretchableColorModel. If the color model reference is of the last kind, the bar will allow the user to mutate the model via mouse drags on the canvas (see below).

The width of the bar by default is the size of the color table, and the height is 32 pixels; however, it can be resized as necessary.

The color model can be fiddled if it has been passed in the form of a StretchableColorModel. This fiddling comes in two modes: shifting and stretching. Shifting is done by dragging the mouse left or right; this causes the values in the color table to be shifted. By dragging the mouse up or down, one can compress or stretch the array of colors in the color table.

See Also:
Serialized Form

Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Constructor Summary
HorizonColorBar(HorizonColorModel horizoncolormodel)
          Given a HorizonColorModel, instantiates a default sized HorizonColorBar.
HorizonColorBar(java.awt.image.IndexColorModel indexcolormodel)
          Given an IndexColorModel, instantiates a default sized HorizonColorBar.
HorizonColorBar(java.awt.image.IndexColorModel indexcolormodel, int canvas_width, int canvas_height)
          Given an IndexColorModel, instantiates a HorizonColorBar with a given width and height.
HorizonColorBar(HorizonColorModel horizoncolormodel, int canvas_width, int canvas_height)
          Given a HorizonColorModel, instantiate a HorizonColorBar with a given width and height.
HorizonColorBar(StretchableColorModel stretchablecm, boolean allowFiddling, int canvas_width, int canvas_height)
          display a StretchableColorModel
HorizonColorBar(StretchableColorModel stretchablecm, boolean allowFiddling)
          display a StretchableColorModel
 
Method Summary
StretchableColorModel getActiveColorModel()
          Returns the current colormodel used by HorizonColorBar.
java.awt.Dimension getPreferredSize()
           
boolean isModelMutable()
          return true if the user can mutate the color model graphically.
static void main(java.lang.String[] args)
           
void paint(java.awt.Graphics g)
           
void setActiveColorModel(java.awt.image.IndexColorModel cm)
          set the bar to display a new IndexColorModel.
void setActiveColorModel(HorizonColorModel cm)
          set the bar to display a new HorizonColorModel.
void setActiveColorModel(StretchableColorModel cm, boolean allowFiddling)
          set the bar to display a new StretchableColorModel.
void setBounds(int x, int y, int width, int height)
           
void setMouseLock(boolean setXmouselock, boolean setYmouselock)
          Allows one to lock out mouse movement in the X or Y direction.
void wakeupColorBar()
           
void xShift(int deltaX)
          Shifts the HorizonColorBar by a distance of deltaX.
void yShift(double deltaY)
          Stretches/Narrows the HorizonColorBar by a distance of deltaY.
 
Methods inherited from class java.awt.Canvas
addNotify, paint
 
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
 

Constructor Detail

HorizonColorBar

public HorizonColorBar(HorizonColorModel horizoncolormodel)
Given a HorizonColorModel, instantiates a default sized HorizonColorBar.
Parameters:
horizoncolormodel - a HorizonColorModel

HorizonColorBar

public HorizonColorBar(java.awt.image.IndexColorModel indexcolormodel)
Given an IndexColorModel, instantiates a default sized HorizonColorBar.
Parameters:
indexcolormodel - an IndexColorModel

HorizonColorBar

public HorizonColorBar(java.awt.image.IndexColorModel indexcolormodel,
                       int canvas_width,
                       int canvas_height)
Given an IndexColorModel, instantiates a HorizonColorBar with a given width and height.
Parameters:
indexcolormodel - an IndexColorModel
canvas_width - an int for the desired Display width.
canvas_height - an int for the desired Display height.

HorizonColorBar

public HorizonColorBar(HorizonColorModel horizoncolormodel,
                       int canvas_width,
                       int canvas_height)
Given a HorizonColorModel, instantiate a HorizonColorBar with a given width and height.
Parameters:
Horizoncolormodel - a HorizonColorModel
canvas_width - an int for the desired Display width.
canvas_height - an int for the desired Display height.

HorizonColorBar

public HorizonColorBar(StretchableColorModel stretchablecm,
                       boolean allowFiddling,
                       int canvas_width,
                       int canvas_height)
display a StretchableColorModel
Parameters:
model - a StretchableColorModel
allowFiddling - if true, this class will allow the color model to be fiddled with.
canvas_width - the width of the canvas
canvas_height - the height of the canvas

HorizonColorBar

public HorizonColorBar(StretchableColorModel stretchablecm,
                       boolean allowFiddling)
display a StretchableColorModel
Parameters:
model - a StretchableColorModel
allowFiddling - if true, this class will allow the color model to be fiddled with.
Method Detail

isModelMutable

public boolean isModelMutable()
return true if the user can mutate the color model graphically.

setActiveColorModel

public void setActiveColorModel(java.awt.image.IndexColorModel cm)
set the bar to display a new IndexColorModel. This model will not be mutable.

setActiveColorModel

public void setActiveColorModel(HorizonColorModel cm)
set the bar to display a new HorizonColorModel. This model will not be mutable.

setActiveColorModel

public void setActiveColorModel(StretchableColorModel cm,
                                boolean allowFiddling)
set the bar to display a new StretchableColorModel.
Parameters:
cm - the colormodel
allowFiddling - if true, allow the user to fiddle the color model.

setMouseLock

public void setMouseLock(boolean setXmouselock,
                         boolean setYmouselock)
Allows one to lock out mouse movement in the X or Y direction. If locked, mouse movement in that direction will not affect the display.
Parameters:
setXmouselock - A boolean that will lock out shifting in the X direction.
setYmouselock - A boolean that will lock out shifting in the Y direction.

xShift

public void xShift(int deltaX)
Shifts the HorizonColorBar by a distance of deltaX.
Parameters:
deltaX - An int which will adjust the HorizonColorBar.

yShift

public void yShift(double deltaY)
Stretches/Narrows the HorizonColorBar by a distance of deltaY.
Parameters:
deltaY - An int which will adjust the HorizonColorBar.

getPreferredSize

public java.awt.Dimension getPreferredSize()
Overrides:
getPreferredSize in class java.awt.Component

getActiveColorModel

public StretchableColorModel getActiveColorModel()
Returns the current colormodel used by HorizonColorBar.

setBounds

public void setBounds(int x,
                      int y,
                      int width,
                      int height)
Overrides:
setBounds in class java.awt.Component

paint

public void paint(java.awt.Graphics g)
Overrides:
paint in class java.awt.Canvas

wakeupColorBar

public void wakeupColorBar()

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