NOTICE: This version of the NSF Unidata web site (archive.unidata.ucar.edu) is no longer being updated.
Current content can be found at unidata.ucar.edu.
To learn about what's going on, see About the Archive Site.
Bill, That all worked great; thanks! Donna L. Gresh, Ph.D. IBM T.J. Watson Research Center (914) 945-2472 http://www.research.ibm.com/people/g/donnagresh gresh@xxxxxxxxxx Bill Hibbard <hibbard@facstaff.w To: Donna L Gresh/Watson/IBM@IBMUS isc.edu> cc: visad <visad-list@xxxxxxxxxxxxx> Sent by: Subject: Re: a couple of questions about ColorControl setFunction method owner-visad-list@ss ec.wisc.edu 02/03/2003 10:20 AM Hi Donna, > 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. You can call: float[][] table BaseColorControl.initTableVis5D(new float[3][tableLength]); color_control.setTable(table); to create the default color table of whatever length you like. The call to setTable() will disable any Function passed to setFunction(). > 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? ColorControl samples Function values using NEAREST_NEIGHBOR. Since this is essentially what it does for a table, it seems to me that Function should provide an alternative. So I changed it to WEIGHTED_AVERAGE. Until the next VisAD release you can find it at: ftp://ftp.ssec.wisc.edu/pub/visad-2.0/untested/BaseColorControl.java Please let us know if this does not solve you problem. Cheers, Bill
visad
archives: