Ah, thank you very much for the suggestions. I'll give them a shot.

-Tom

On 5/7/07, Martin Schmitz <[EMAIL PROTECTED]> wrote:

Hi Tom,

some time ago, I found out that the raster colorization does not work
when I give labels to my ColorMap-Categories, e.g. you did:

ColorMap map = sb.createColorMap(
   new String[] { "1", "2", "3", "4", "5" },
   breaks,
   colors,
   ColorMap.TYPE_RAMP
);

At that time, I did not figure it out exactly and was content to deal
without labels on my Categories.
But today I hit on some strange thing again:
Although using empty Category labels, my GridCoverage2D created by

GridCoverage2D gc = new GridCoverageFactory().create(name, data, env);

does not become colorized. But when I created a dummy-copy of that grid,
the colors became visible!

GridCoverage2D gc  = new GridCoverageFactory().create(name, data, env);
GridCoverage2D gc2 = new GridCoverageFactory().create(
   "", gc.getRenderedImage(), gc.getEnvelope() );

After debugging some time I figured out, that THE NAME OF THE
GRIDCOVERAGE was the reason of the hole colorization trouble!

I do not know, what the programmer of the RasterSymbolizer stuff thought
when coding the classes, but: To colorize a grid with ColorMap, THE
CATEGORY NAMES MUST BE EXACTLY CORRESPOND TO THE GRID NAME!

So, to cut a long story short:
Although it is not a solution, leaving both - category names and grid
coverage names - empty string, is a appropriate work-around for the grid
colorization problem...

Kind regards

Martin Schmitz



Tom Howe schrieb:
> Hi, I'm trying to use a Raster symbolizer to display some data that I
> extracted from a netcdf file.  Here's my code:
>
> StyleBuilder sb = new StyleBuilder();
>             double interval = (minMax.getMax() - minMax.getMin()) / 5;
>             double min = minMax.getMin();
>             ColorBrewer brewer = ColorBrewer.instance();
>             brewer.loadPalettes();
>             BrewerPalette[] palettes = brewer.getPalettes
> (ColorBrewer.SEQUENTIAL);
>             Color[] colors = palettes[1].getColors(5);
>             double[] breaks = new double[] { min, min + interval, min +
> 2 * interval, min + 3 * interval,
>                     min + 4 * interval };
>             ColorMap map = sb.createColorMap(new String[] { "1", "2",
> "3", "4", "5" }, breaks, colors,
>                     ColorMap.TYPE_RAMP);
>             Style style = sb.createStyle(sb.createRasterSymbolizer(map,
1));
>             MapContext context = new
> DefaultMapContext(set.getCoordAxes().getBoundingBox()
>                     .getCoordinateReferenceSystem());
>             context.setAreaOfInterest (set.getCoordAxes
().getBoundingBox());
>             context.addLayer(gridCoverage, style);
>             JMapPane mapPane = new JMapPane();
>             JFrame jf = new JFrame("MapPane");
>             jf.setSize (500, 500);
>             jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
>             jf.setLayout(new BorderLayout());
>             jf.getContentPane().add(mapPane);
>             mapPane.setMapArea(context.getAreaOfInterest ());
>             GTRenderer renderer = new StreamingRenderer();
>             HashMap hints = new HashMap();
>             hints.put("memoryPreloadingEnabled", Boolean.TRUE);
>             renderer.setRendererHints (hints);
>             mapPane.setRenderer(renderer);
>             mapPane.setContext(context);
>             jf.setVisible(true);
>
> but, the image still comes out as a grayscale.  Am I doing something
> wrong or is the color map stuff not supported by streaming renderer or
> something else all together?
>
> Thanks,
> Tom
>
>
> ------------------------------------------------------------------------


-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Geotools-gt2-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users

Reply via email to