Hi,
I'm using the setFunction method of ColorControl to set a custom color map.
This mostly works, but I have a couple of questions. One is, is there a
simple way to "unset" the function (that is, to have it go back to the
default colormap)? I tried naively setting the function to null but that
did not work. I want to allow the user to choose between several
colormaps, including the default. I know I can build a custom map that
looks like the default, but wanted to avoid that.
Second, I use a FlatField to represent the colormap, which gets passed to
the setFunction method, with it constructed like this:
RealType cp = RealType.getRealType("cp");
RealType cr = RealType.getRealType("cr");
RealType cg = RealType.getRealType("cg");
RealType cb = RealType.getRealType("cb");
try {
RealTupleType crgb = new RealTupleType(cr, cg, cb);
FunctionType colormapfunction = new FunctionType(cp, crgb);
float[][] cpos = new float[1][pos.size()];
for (int i=0; i<pos.size(); i++) {
cpos[0][i] = pos.get(i);
}
Irregular1DSet colorbarpos = new Irregular1DSet(cp, cpos);
FlatField mycolormap = new FlatField(colormapfunction,
colorbarpos);
double[][] samples = new double[3][colors.size()];
ColorRGBValue col;
for (int i=0; i<colors.size(); i++) {
col = colors.get(i);
samples[0][i] = col.r;
samples[1][i] = col.g;
samples[2][i] = col.b;
}
mycolormap.setSamples(samples);
"pos" and "colors" are simply Java Vectors holding the 1D positons of the
colormap or the 3D rgb colors of the map. It seems that this creates a
segmented colormap, in that there are abrupt boundaries between the colors,
instead of smooth. Is this how it works? i.e. do I have to have lots of
points in my colormap to get a smooth appearance?
Thanks for any help,
Donna
Donna L. Gresh, Ph.D.
IBM T.J. Watson Research Center
(914) 945-2472
http://www.research.ibm.com/people/g/donnagresh
gresh@xxxxxxxxxx