com.michaelbaranov.microba.gradient
Class GradientBar

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by com.michaelbaranov.microba.common.MicrobaComponent
                  extended by com.michaelbaranov.microba.gradient.GradientBar
All Implemented Interfaces:
java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable
Direct Known Subclasses:
GradientEditor

public class GradientBar
extends MicrobaComponent

IMPORTANT: alpha featre not implemented. Stubs only.

A concrete implementation of JComponent. Displays an area filled with gradient color (palette). The color and alpha value (transparency) is linearly interpolated between key points.

The color key points are provided by the data model in combination with color column (index) and color position column (index). Each row in the model represents a colored key point. Color values are expected to be of type Color and position values of type Number with integer precision.

The alpha key points are provided by the alpha model in combination with alpha column (index) and alpha position column (index). Each row in the model represents an alpha key point. Alpha values are expected to be of type Number with floating-point precision ranging form 0.0f (transparent) to 1.0f (opaque) and position values of type Number with integer precision. Example:

 GradientBar bar = new GradientBar();
 bar.setDataModel(myColorModel);
 bar.setColorColumn(0);
 bar.setColorPositionColumn(1);
 
 bar.setAlphaModel(myAlphaModel);
 bar.setAlphaColumn(1);
 bar.setAlphaPositionColumn(0);
 

Author:
Michael Baranov
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Field Summary
static java.lang.String PROPERTY_ALPHA_COLUMN
          The name of a "alphaColumn" property.
static java.lang.String PROPERTY_ALPHA_MODEL
          The name of a "alphaModel" property.
static java.lang.String PROPERTY_ALPHA_POSITION_COLUMN
          The name of a "alphaPositionColumn" property.
static java.lang.String PROPERTY_COLOR_COLUMN
          The name of a "colorColumn" property.
static java.lang.String PROPERTY_COLOR_POSITION_COLUMN
          The name of a "colorPositionColumn" property.
static java.lang.String PROPERTY_DATA_MODEL
          The name of a "dataModel" property.
static java.lang.String PROPERTY_ORIENTATION
          The name of a "orientation" property.
 
Fields inherited from class com.michaelbaranov.microba.common.MicrobaComponent
PROPERTY_NAME_COLOR_OVERRIDE_MAP
 
Fields inherited from class javax.swing.JComponent
TOOL_TIP_TEXT_KEY, 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
GradientBar()
          Constructor.
GradientBar(BoundedTableModel model)
          Constructor.
GradientBar(BoundedTableModel model, int orientation)
          Constructor.
 
Method Summary
 int getAlphaColumn()
          Returns the index of the alpha column for the alpha model.
 BoundedTableModel getAlphaModel()
          Regturns the current alpha model.
 int getAlphaPositionColumn()
          Returns the index of the position column for the alpha model.
 int getColorColumn()
          Returns the index of the color column for the data model.
 int getColorPositionColumn()
          Returns the index of the position column for the data model.
 BoundedTableModel getDataModel()
          Regturns the current data model.
 int getOrientation()
          Returns current orientation of the component.
 java.lang.String getUIClassID()
           
 void setAlphaColumn(int alphaColumn)
          Sets the index of the alpha column for the alpha model.
 void setAlphaModel(BoundedTableModel alphaModel)
          Sets the current alpha model.
 void setAlphaPositionColumn(int positionColumn)
          Sets the index of the position column for the alpha model.
 void setColorColumn(int colorColumn)
          Sets the index of the color column for the data model.
 void setColorPositionColumn(int positionColumn)
          Sets the index of the position column for the data model.
 void setDataModel(BoundedTableModel dataModel)
          Sets the current data model.
 void setOrientation(int orientation)
          Sets orientation of the component.
 
Methods inherited from class com.michaelbaranov.microba.common.MicrobaComponent
getColorOverrideMap, getUI, setColorOverrideMap, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, getAccessibleContext, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, 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, paintImmediately, paintImmediately, print, printAll, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, 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, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, 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, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusBackward, transferFocusDownCycle, validate
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, contains, createImage, createImage, createVolatileImage, createVolatileImage, dispatchEvent, enable, enableInputMethods, 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, 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
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

PROPERTY_DATA_MODEL

public static final java.lang.String PROPERTY_DATA_MODEL
The name of a "dataModel" property.

See Also:
Constant Field Values

PROPERTY_ALPHA_MODEL

public static final java.lang.String PROPERTY_ALPHA_MODEL
The name of a "alphaModel" property.

See Also:
Constant Field Values

PROPERTY_COLOR_POSITION_COLUMN

public static final java.lang.String PROPERTY_COLOR_POSITION_COLUMN
The name of a "colorPositionColumn" property.

See Also:
Constant Field Values

PROPERTY_ALPHA_POSITION_COLUMN

public static final java.lang.String PROPERTY_ALPHA_POSITION_COLUMN
The name of a "alphaPositionColumn" property.

See Also:
Constant Field Values

PROPERTY_COLOR_COLUMN

public static final java.lang.String PROPERTY_COLOR_COLUMN
The name of a "colorColumn" property.

See Also:
Constant Field Values

PROPERTY_ALPHA_COLUMN

public static final java.lang.String PROPERTY_ALPHA_COLUMN
The name of a "alphaColumn" property.

See Also:
Constant Field Values

PROPERTY_ORIENTATION

public static final java.lang.String PROPERTY_ORIENTATION
The name of a "orientation" property.

See Also:
Constant Field Values
Constructor Detail

GradientBar

public GradientBar()
Constructor.


GradientBar

public GradientBar(BoundedTableModel model)
Constructor.


GradientBar

public GradientBar(BoundedTableModel model,
                   int orientation)
Constructor.

Method Detail

getUIClassID

public java.lang.String getUIClassID()
Overrides:
getUIClassID in class javax.swing.JComponent

getColorColumn

public int getColorColumn()
Returns the index of the color column for the data model.

Returns:
index of color column
See Also:
setColorColumn(int)

setColorColumn

public void setColorColumn(int colorColumn)
Sets the index of the color column for the data model.

Parameters:
colorColumn - index of color column
See Also:
getColorColumn()

getAlphaColumn

public int getAlphaColumn()
Returns the index of the alpha column for the alpha model.

Returns:
index of alpha column
See Also:
setAlphaColumn(int)

setAlphaColumn

public void setAlphaColumn(int alphaColumn)
Sets the index of the alpha column for the alpha model.

Parameters:
alphaColumn - index of alpha column
See Also:
getAlphaColumn()

getDataModel

public BoundedTableModel getDataModel()
Regturns the current data model. The data model provides key points for interpolation (position & color).

Returns:
current data model
See Also:
setDataModel(BoundedTableModel), getColorColumn()

setDataModel

public void setDataModel(BoundedTableModel dataModel)
Sets the current data model. The data model provides key points for interpolation (position & color).

Parameters:
dataModel - current data model
See Also:
getDataModel(), getColorColumn()

getAlphaModel

public BoundedTableModel getAlphaModel()
Regturns the current alpha model. The data model provides alpha key points for interpolation (position & alpha).

Returns:
current alpha model
See Also:
setAlphaModel(BoundedTableModel), getAlphaColumn()

setAlphaModel

public void setAlphaModel(BoundedTableModel alphaModel)
Sets the current alpha model. The alpha model provides alpha key points for interpolation (position & alpha).

Parameters:
alphaModel - current alpha model
See Also:
getAlphaModel(), getAlphaColumn()

getOrientation

public int getOrientation()
Returns current orientation of the component. Possible values are:

Returns:
orientation
See Also:
setOrientation(int)

setOrientation

public void setOrientation(int orientation)
Sets orientation of the component. Possible values are:

Parameters:
orientation -

getColorPositionColumn

public int getColorPositionColumn()
Returns the index of the position column for the data model.

Returns:
index of position column
See Also:
setColorPositionColumn(int)

setColorPositionColumn

public void setColorPositionColumn(int positionColumn)
Sets the index of the position column for the data model.

Parameters:
positionColumn - index of position column
See Also:
getColorPositionColumn()

getAlphaPositionColumn

public int getAlphaPositionColumn()
Returns the index of the position column for the alpha model.

Returns:
index of position column
See Also:
setAlphaPositionColumn(int)

setAlphaPositionColumn

public void setAlphaPositionColumn(int positionColumn)
Sets the index of the position column for the alpha model.

Parameters:
positionColumn - index of position column
See Also:
getAlphaPositionColumn()