com.michaelbaranov.microba.gradient

Class GradientBar


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

Field Summary

static String
PROPERTY_ALPHA_COLUMN
The name of a "alphaColumn" property.
static String
PROPERTY_ALPHA_MODEL
The name of a "alphaModel" property.
static String
PROPERTY_ALPHA_POSITION_COLUMN
The name of a "alphaPositionColumn" property.
static String
PROPERTY_COLOR_COLUMN
The name of a "colorColumn" property.
static String
PROPERTY_COLOR_POSITION_COLUMN
The name of a "colorPositionColumn" property.
static String
PROPERTY_DATA_MODEL
The name of a "dataModel" property.
static String
PROPERTY_ORIENTATION
The name of a "orientation" property.

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

Field Details

PROPERTY_ALPHA_COLUMN

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

PROPERTY_ALPHA_MODEL

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

PROPERTY_ALPHA_POSITION_COLUMN

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

PROPERTY_COLOR_COLUMN

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

PROPERTY_COLOR_POSITION_COLUMN

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

PROPERTY_DATA_MODEL

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

PROPERTY_ORIENTATION

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

Constructor Details

GradientBar

public GradientBar()
Constructor.

GradientBar

public GradientBar(BoundedTableModel model)
Constructor.

GradientBar

public GradientBar(BoundedTableModel model,
                   int orientation)
Constructor.

Method Details

getAlphaColumn

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

getAlphaModel

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

getAlphaPositionColumn

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

getColorColumn

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

getColorPositionColumn

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

getDataModel

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

getOrientation

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

getUIClassID

public String getUIClassID()

setAlphaColumn

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

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

setAlphaPositionColumn

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

setColorColumn

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

setColorPositionColumn

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

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

setOrientation

public void setOrientation(int orientation)
Sets orientation of the component. Possible values are:
  • SwingConstants.HORIZONTAL
  • SwingConstants.VERTICAL
Parameters:
orientation -