org::scilab::modules::renderer::utils::ColorMap Class Reference

Inheritance diagram for org::scilab::modules::renderer::utils::ColorMap:

Inheritance graph
[legend]

Public Member Functions

 ColorMap ()
void getColor (int colorIndex, double[] color)
double[] getColor (int colorIndex)
double[][] getColors (int[] colorIndices)
double getRedChannel (int colorIndex)
double getGreenChannel (int colorIndex)
double getBlueChannel (int colorIndex)
int clampColorIndex (int colorIndex)
void setData (double[] newData)
double[] getData ()
void getData (double[] data)
int getSize ()
void setSize (int newSize)
void setColor (int index, double[] color)
int convertScilabToColorMapIndex (int scilabIndex)
String toString ()

Static Public Member Functions

static ColorMap create ()

Private Attributes

double[] redChannel
double[] greenChannel
double[] blueChannel
int colormapSize

Static Private Attributes

static final String COMMA = ", "
static final int NBCOL = 3
static final int BLACK_INDEX = -1
static final int WHITE_INDEX = -2

Detailed Description

Class to handle Scilab colormaps
Author:
Jean-Baptiste Silvy

Definition at line 21 of file ColorMap.java.


Constructor & Destructor Documentation

org::scilab::modules::renderer::utils::ColorMap::ColorMap (  )  [inline]

Default constructor

Definition at line 43 of file ColorMap.java.

References blueChannel, colormapSize, greenChannel, and redChannel.

Referenced by create().

00043                           {
00044           redChannel   = null;
00045           greenChannel = null;
00046           blueChannel  = null;
00047           colormapSize = 0;
00048         }

Here is the caller graph for this function:


Member Function Documentation

static ColorMap org::scilab::modules::renderer::utils::ColorMap::create ( void   )  [inline, static]

Factory

Returns:
a new instance of colormap

Reimplemented in org::scilab::modules::renderer::utils::TexturedColorMap.

Definition at line 54 of file ColorMap.java.

References ColorMap().

00054                                         {
00055                 return new ColorMap();
00056         }

Here is the call graph for this function:

void org::scilab::modules::renderer::utils::ColorMap::getColor ( int  colorIndex,
double[]  color 
) [inline]

Get the channels of a color given its index in the colormap

Parameters:
colorIndex color index in the colormap
color return result, should be an array of size 3 to store the 3 channels

Definition at line 63 of file ColorMap.java.

References getBlueChannel(), getGreenChannel(), and getRedChannel().

Referenced by org::scilab::modules::renderer::utils::TexturedColorMap::applyTexCoord(), org::scilab::modules::renderer::surfaceDrawing::FlatShadedFacetDrawer::drawFacet(), org::scilab::modules::renderer::grayplotDrawing::DrawableGrayplotGL::drawGrayplot(), org::scilab::modules::renderer::segsDrawing::SegsLineDrawerGL::drawSegs(), org::scilab::modules::renderer::fecDrawing::FecColorMap::fillLowerPart(), org::scilab::modules::renderer::fecDrawing::FecColorMap::fillMiddlePart(), org::scilab::modules::renderer::fecDrawing::FecColorMap::fillUpperPart(), org::scilab::modules::renderer::drawers::ArrowHeadDrawerGL::getArrowColor(), org::scilab::modules::renderer::polylineDrawing::PolylineBarDrawerGL::getBackColor(), org::scilab::modules::renderer::drawers::FillDrawerGL::getBackColor(), org::scilab::modules::renderer::textDrawing::TextContentDrawerGL::getBackgroundColor(), org::scilab::modules::renderer::subwinDrawing::SubwinBackgroundDrawerGL::getBackgroundColor(), org::scilab::modules::renderer::figureDrawing::DrawableFigureGL::getBackgroundColor(), getColor(), org::scilab::modules::renderer::fecDrawing::FecFacetDrawerGL::getColorFecPolygon(), getColors(), org::scilab::modules::renderer::subwinDrawing::TicksDrawerGL::getExponentRenderer(), org::scilab::modules::renderer::textDrawing::TextContentDrawerGL::getFontColor(), org::scilab::modules::renderer::subwinDrawing::GridDrawerGL::getGridColor(), org::scilab::modules::renderer::subwinDrawing::SubwinLineBoxDrawer::getHiddenAxisColor(), org::scilab::modules::renderer::surfaceDrawing::FacetDrawerGL::getHiddenColor(), org::scilab::modules::renderer::textDrawing::TextContentDrawerGL::getLineColor(), org::scilab::modules::renderer::subwinDrawing::TicksDrawerGL::getLineColor(), org::scilab::modules::renderer::subwinDrawing::SubwinLineBoxDrawer::getLineColor(), org::scilab::modules::renderer::polylineDrawing::PolylineBarDrawerGL::getLineColor(), org::scilab::modules::renderer::drawers::LineDrawerGL::getLineColor(), org::scilab::modules::renderer::subwinDrawing::TicksDrawerGL::getTextRenderer(), org::scilab::modules::renderer::polylineDrawing::GL2PSShadeFacetDrawer::paintTriangle(), and org::scilab::modules::renderer::drawers::ArrowHeadDrawerGL::redrawArrowHeads().

00063                                                              {
00064                 color[0] = getRedChannel(colorIndex);
00065                 color[1] = getGreenChannel(colorIndex);
00066                 color[2] = getBlueChannel(colorIndex);
00067         }

Here is the call graph for this function:

Here is the caller graph for this function:

double [] org::scilab::modules::renderer::utils::ColorMap::getColor ( int  colorIndex  )  [inline]

Get the channels of a color given its index in the colormap

Parameters:
colorIndex color index in the colormap
Returns:
An array of size 3 to store the 3 channels

Definition at line 74 of file ColorMap.java.

References getColor(), NBCOL, and res.

00074                                                  {
00075                 double[] res = new double[NBCOL];
00076                 getColor(colorIndex, res);
00077                 return res;
00078         }

Here is the call graph for this function:

double [][] org::scilab::modules::renderer::utils::ColorMap::getColors ( int[]  colorIndices  )  [inline]

Get the 3 color channels of several color indices

Parameters:
colorIndices color indices in the colormap
Returns:
Array of same size as colorIndices

Definition at line 85 of file ColorMap.java.

References getColor(), i, and res.

00085                                                         {
00086                 int nbIndices = colorIndices.length;
00087                 double[][] res = new double[nbIndices][];
00088                 for (int i = 0; i < nbIndices; i++) {
00089                         res[i] = getColor(colorIndices[i]);
00090                 }
00091                 return res;
00092         }

Here is the call graph for this function:

double org::scilab::modules::renderer::utils::ColorMap::getRedChannel ( int  colorIndex  )  [inline]

Parameters:
colorIndex color index in the colormap
Returns:
the red channel of the color corresponding to the colorIndex

Definition at line 98 of file ColorMap.java.

References clampColorIndex(), and redChannel.

Referenced by getColor(), and org::scilab::modules::renderer::utils::TexturedColorMap::getImage().

00098                                                     {
00099                 return redChannel[clampColorIndex(colorIndex)];
00100         }

Here is the call graph for this function:

Here is the caller graph for this function:

double org::scilab::modules::renderer::utils::ColorMap::getGreenChannel ( int  colorIndex  )  [inline]

Parameters:
colorIndex color index in the colormap
Returns:
the red channel of the color corresponding to the colorIndex

Definition at line 106 of file ColorMap.java.

References clampColorIndex(), and greenChannel.

Referenced by getColor(), and org::scilab::modules::renderer::utils::TexturedColorMap::getImage().

00106                                                       {
00107                 return greenChannel[clampColorIndex(colorIndex)];
00108         }

Here is the call graph for this function:

Here is the caller graph for this function:

double org::scilab::modules::renderer::utils::ColorMap::getBlueChannel ( int  colorIndex  )  [inline]

Parameters:
colorIndex color index in the colormap
Returns:
the red channel of the color corresponding to the colorIndex

Definition at line 114 of file ColorMap.java.

References blueChannel, and clampColorIndex().

Referenced by getColor(), and org::scilab::modules::renderer::utils::TexturedColorMap::getImage().

00114                                                      {
00115                 return blueChannel[clampColorIndex(colorIndex)];
00116         }

Here is the call graph for this function:

Here is the caller graph for this function:

int org::scilab::modules::renderer::utils::ColorMap::clampColorIndex ( int  colorIndex  )  [inline]

Clamp a colormap index to the valid range of colormap. To be used for index which are sent to renderer directly in colormap index (and not in Scilab one).

Parameters:
colorIndex imput index we want to use
Returns:
clamped index betwwen 0 and whiteId

Definition at line 125 of file ColorMap.java.

References colormapSize.

Referenced by getBlueChannel(), getGreenChannel(), and getRedChannel().

00125                                                    {
00126                 if (colorIndex <= 0) {
00127                         return 0;
00128                 } else if (colorIndex >= colormapSize + 1) {
00129                         return colormapSize + 1;
00130                 } else {
00131                         return colorIndex;
00132                 }
00133         }

Here is the caller graph for this function:

void org::scilab::modules::renderer::utils::ColorMap::setData ( double[]  newData  )  [inline]

Set new data to the colorMap

Parameters:
newData nbColor x 3 matrix containign the 3 channels the matrix is stored rowwise like in Scilab

Reimplemented in org::scilab::modules::renderer::utils::TexturedColorMap.

Definition at line 140 of file ColorMap.java.

References blueChannel, colormapSize, greenChannel, NBCOL, redChannel, and setSize().

00140                                               {
00141                 
00142                 // new size
00143                 setSize(newData.length / NBCOL);
00144                 
00145                 // red channel
00146                 System.arraycopy(newData, 0, redChannel, 0, colormapSize);
00147                 
00148                 // green channel
00149                 System.arraycopy(newData, colormapSize, greenChannel, 0, colormapSize);
00150 
00151                 // blue channel
00152                 System.arraycopy(newData, 2 * colormapSize, blueChannel, 0, colormapSize);
00153 
00154         }

Here is the call graph for this function:

double [] org::scilab::modules::renderer::utils::ColorMap::getData (  )  [inline]

Get the nbColor x 3 matrix of the colormap Should only be used from C code

Returns:
matrix of the colormap

Definition at line 161 of file ColorMap.java.

References colormapSize, NBCOL, and res.

Referenced by org::scilab::modules::renderer::figureDrawing::DrawableFigureGL::getColorMapData().

00161                                   {
00162                 double[] res = new double[NBCOL * colormapSize];
00163                 getData(res);
00164                 return res;
00165         }

Here is the caller graph for this function:

void org::scilab::modules::renderer::utils::ColorMap::getData ( double[]  data  )  [inline]

Fill the data array with the colormap data data should be of size colormapSize x 3

Parameters:
data matrix wich will be filled

Definition at line 172 of file ColorMap.java.

References blueChannel, colormapSize, greenChannel, and redChannel.

00172                                            {
00173                 // copy channels
00174                 System.arraycopy(redChannel  , 0, data,                0, colormapSize);
00175                 System.arraycopy(greenChannel, 0, data,     colormapSize, colormapSize);
00176                 System.arraycopy(blueChannel , 0, data, 2 * colormapSize, colormapSize);
00177         }

int org::scilab::modules::renderer::utils::ColorMap::getSize ( void   )