Ciao Diego, a few remarks. 1> It seems that you geotiff files are pretty big. If you really want to see very good performances I would add overviews to them. Try also to compress them before doing so, this way loading wil be much faster (for rgb I usually use JPEG compression). This can be easily done with gdal_translate tool.
2> In your code you are providing the traight coverage to the map pane. To gain access to decimation on reading and/or overviews you need to provide the map pane with the reader directly not with the coverage. The renderer wil then ask the reader to supply the best resolutio navailable exploiting overviews/decimation 3>RasterSymbolizer Support for raster symbolization is spretty bad these days. Guys from geosolutions are working on integrating the work that I have done during late summer-early fall which should improve the situation. I will tell you more about it along the week. Hope that helps, Simone. On Dec 11, 2007 1:56 PM, Diego Fdez. Durán <[EMAIL PROTECTED]> wrote: > Hi all: > > I'm using ImageMosaic to load a GeoTiff index shapefile (9 GeoTiffs, > total size of 146889x92337). If I display the resulting map using > DisplayJAI I get an optimal performance but I need to use > StreamingRenderer.render method to display multiple layers above the > raster image. With StreamingRenderer.render I get really poor > performance. Am I using GeoTools in the right way? > > P.S.- I think that I'm missunderstanding (or not understanding at all the > RasterSimbolizer part) because I get some kind of inverted colors. > > Thanks in advance. > > -- Here is my code (I'm using GeoTools 2.3.5) > > public class PanelGeoMap extends JPanel implements MouseMotionListener { > > private class PanelMap extends JPanel { > > @Override > public void paint(Graphics g) { > try { > Graphics2D g2d = (Graphics2D) g; > Rectangle rectangle = new Rectangle(getSize()); > > //System.out.println("Map size (px): " + rectangle.height > + "x" + rectangle.width); > > renderer.paint(g2d, rectangle, mapContext.getLayerBounds()); > } catch (IOException ex) { > > Logger.getLogger(PanelGeoMap.class.getName()).log(Level.SEVERE, > null, ex); > } > } > } > > private PanelMap panelMap; > private JScrollPane scrollPaneMap; > > private Dimension preferredSizeMaximum; > > private CoordinateReferenceSystem crs; > private GTRenderer renderer; > private Envelope env; > private DefaultMapContext mapContext; > > public PanelGeoMap() { > renderer = new StreamingRenderer(); > > File file = null; > JFileChooser fc = new JFileChooser(); > int ret = fc.showOpenDialog(this); > > if (ret == JFileChooser.APPROVE_OPTION) { > file = fc.getSelectedFile(); > } else { > System.exit(0); > } > > AbstractGridCoverage2DReader reader; > try { > //reader = new GeoTiffReader(file, new > Hints(Hints.FORCE_LONGITUDE_FIRST_AXIS_ORDER, Boolean.TRUE)); > reader = new ImageMosaicReader(file, new > Hints(Hints.FORCE_LONGITUDE_FIRST_AXIS_ORDER, Boolean.TRUE)); > } catch (IOException ex) { > ex.printStackTrace(); > return; > } > > GridCoverage2D coverage; > try { > coverage = (GridCoverage2D) reader.read(null); > } catch (IOException ex) { > ex.printStackTrace(); > return; > } > > crs = coverage.getCoordinateReferenceSystem(); > env = coverage.getEnvelope(); > RenderedImage image = coverage.getRenderedImage(); > > StyleBuilder styleBuilder = new StyleBuilder(); > > ColorMap cm = styleBuilder.createColorMap( > new String[]{"0", "255"}, > new double[]{0, 255}, > new Color[]{ new Color(0, 0, 0), > new Color(255, 255, 255)}, > ColorMap.TYPE_RAMP); // XXX: ? > > > RasterSymbolizer rs = styleBuilder.createRasterSymbolizer(cm, 1); > Style st = styleBuilder.createStyle(rs); > > mapContext = new DefaultMapContext(crs); > mapContext.addLayer(reader, st); > renderer.setContext(mapContext); > > RenderingHints hints = new > RenderingHints(RenderingHints.KEY_RENDERING, > RenderingHints.VALUE_RENDER_SPEED); > renderer.setJava2DHints(hints); > Map renderParams = new HashMap(); > renderParams.put("optimizedDataLoadingEnabled", new Boolean(true)); > renderer.setRendererHints(renderParams); > > int width = image.getWidth(); > int height = image.getHeight(); > > /* Debug */ > JFrame frameJAI = new JFrame("DisplayJAI"); > frameJAI.getContentPane().add(new JScrollPane(new > DisplayJAI(image))); > frameJAI.setVisible(true); > > System.out.println("Image size: " + width + "x" + height); > > panelMap = new PanelMap(); > panelMap.addMouseMotionListener(this); > preferredSizeMaximum = new Dimension(width, height); > panelMap.setPreferredSize(preferredSizeMaximum); > > scrollPaneMap = new JScrollPane(panelMap); > > scrollPaneMap.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); > > scrollPaneMap.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED); > scrollPaneMap.setAutoscrolls(true); > > add(scrollPaneMap, BorderLayout.CENTER); > } > > public void zoomIn() { > Dimension preferredSizeActual = panelMap.getPreferredSize(); > > panelMap.setPreferredSize(new Dimension(preferredSizeActual.width > - 2000, preferredSizeActual.height - 2000)); > panelMap.revalidate(); > } > > public void zoomOut() { > Dimension preferredSizeActual = panelMap.getPreferredSize(); > } > > public void mouseDragged(MouseEvent e) { > System.out.println("Dragging " + e.getX() + " " + e.getY()); > Rectangle r = new Rectangle(e.getX(), e.getY(), 1, 1); > scrollPaneMap.scrollRectToVisible(r); > } > > public void mouseMoved(MouseEvent e) { > > } > } > > -- > Diego Fdez. Durán <[EMAIL PROTECTED]> | http://www.goedi.net > GPG : 925C 9A21 7A11 3B13 6E43 50DB F579 D119 90D2 66BB > > > > > > ------------------------------------------------------------------------- > SF.Net email is sponsored by: > Check out the new SourceForge.net Marketplace. > It's the best place to buy or sell services for > just about anything Open Source. > http://sourceforge.net/services/buy/index.php > _______________________________________________ > Geotools-gt2-users mailing list > Geotools-gt2-users@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users > -- ------------------------------------------------------- Eng. Simone Giannecchini President /CEO GeoSolutions S.A.S. Via Carignoni 51 55041 Camaiore (LU) Italy phone: +39 0584983027 fax: +39 0584983027 mob: +39 333 8128928 http://www.geo-solutions.it ------------------------------------------------------- ------------------------------------------------------------------------- SF.Net email is sponsored by: Check out the new SourceForge.net Marketplace. It's the best place to buy or sell services for just about anything Open Source. http://sourceforge.net/services/buy/index.php _______________________________________________ Geotools-gt2-users mailing list Geotools-gt2-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users