Hello,

first I had the same problem, but then I found out that the raster becomed 
visible, when I resized the JMapPane (manually by mouse).
So it must have been an update problem.

I solved the problem by calling JMapPane.setReset(true) before 
JMapPane.repaint().
It tells the JMapPane, that something has changed and that the map must be 
completely updated.

Additionally I had to set the displayed area by 
JMapPane.setMapArea(<envelope>). Otherwise I got a NullPointerException while 
zooming (via mouse click).

For my GridCoverage2D I created the bounding envelope by the following code:

org.opengis.spatialschema.geometry.Envelope e = grid2D.getEnvelope();
com.vividsolutions.jts.geom.Envelope area = new 
com.vividsolutions.jts.geom.Envelope(
  e.getUpperCorner().getOrdinate(0),  // X1
  e.getLowerCorner().getOrdinate(0),  // X2
  e.getUpperCorner().getOrdinate(1),  // Y1
  e.getLowerCorner().getOrdinate(1)   // Y2
);

This way was necessary because the opengis-Envelope (returned by 
GridCoverage2D.getEnvelope()) in not compatible with the 
vividsolution-Envelope, which is requested for JMapPane.setMapArea(.).

I hope my answer will help you.

BTW:
Do you also display FeatureCollections in your Map?
I generate FeatureCollections from ShapeFiles. LineString-FeatureCollections 
(e.g. steetd) are displayed well with LineSymbolizer, but the PolygonSymbolizer 
works not with my Polygon-FeatureCollection! Nothing is displayed...
In the old StyledMapPane of GT-2.1.M3 the Polygon-ShapeFile was displayed 
without any problems.

Any solutions?


Martin Schmitz


> -----Ursprüngliche Nachricht-----
> Von: Kaergaard Kasper <[EMAIL PROTECTED]>
> Gesendet: 06.09.06 16:41:05
> An: [email protected]
> Betreff: [Geotools-gt2-users] JMapPane and Raster data


> Hello All.. 
> 
> We are trying to display raster data in the JMapPane
> using the following code:
> 
>       public void testRotatedRaster() throws Exception{
> 
>               final int width  = 500;
>         final int height = 500;
> 
>         WritableRaster raster =
> RasterFactory.createBandedRaster(DataBuffer.TYPE_INT,
>                                                       
>           width, height, 1, null);
>         for (int y=0; y<height; y++) {
>             for (int x=0; x<width; x++) {
>                 raster.setSample(x, y, 0, x+y);
>             }
>         }
> 
>         StyleBuilder sb = new StyleBuilder();
>         Style style =
> sb.createStyle(sb.createRasterSymbolizer());
>         
>         Envelope2D envelope = new
> Envelope2D(DefaultGeographicCRS.WGS84,0, 0, 30, 30);
> 
>         GridCoverageFactory gridCoverageFactory = new
> GridCoverageFactory();
>         GridCoverage2D gc =
> gridCoverageFactory.create("test",raster,envelope);
>         
>         MapContext context = new DefaultMapContext();
>         context.addLayer(gc,style);
>         
>         StreamingRenderer renderer = new
> StreamingRenderer();
>         
>         JMapPane mapPane = new JMapPane();
>         mapPane.setContext(context);
>         mapPane.setRenderer(renderer);
>         
>         mapPane.doLayout();
>         mapPane.validate();
>         mapPane.repaint();
>         
>         JFrame frame = new JFrame();
>         frame.setLayout(new BorderLayout());
>         frame.add(mapPane,BorderLayout.CENTER);
>         frame.setPreferredSize(new
> Dimension(500,500));
>         frame.pack();
>         frame.setVisible(true);
>         
>         Thread.sleep(20000);
> 
>       
>       
>       }
> 
> But nothing is showing up on the JFrame.. 
> 
> Any suggestions are greatly appreciated.
> 
> - Kasper
> 

_______________________________________________________________________
Viren-Scan für Ihren PC! Jetzt für jeden. Sofort, online und kostenlos.
Gleich testen! http://www.pc-sicherheit.web.de/freescan/?mc=022222


-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Geotools-gt2-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users

Reply via email to