[Gvsig_english] Refresh functionnality

Fran fpenarru at gmail.com
Thu Jul 24 11:58:08 CEST 2008


Hi Charlotte.

Maybe you can try this method:

public void setCachingDrawnLayers(boolean bCacheDrawnLayers)

You can use like this YourTopLayer.setCachingDrawnLayers(true);

Then, your layer will have a copy of the image generated before your 
layer is drawn, and dependent on the event that generated the repaint, 
it will be used or not.
I didn't test, but it may work.

Cheers.

Fran.


Charlotte Declercq escribió:
> Hello,
>
> I am looking in the code to add a refresh functionnality to gvsig 
> desktop.
> I have modified the paint method of MapControl (lib_FMap) here to add :
>
>
>                    while(true){
>                       Thread.sleep(2000);
>                       this.paint();
>                                             //commandRefresh();
>                        //System.out.println("refresh");
>                   }
>                 
> to refresh the map all 2 seconds.
>
> I would like to refresh only one layer and not all the layers, is it 
> possible to do that? If yes could someone guide me?
> If I could have a developper contact it would be great, thanks.
>
> Charlotte.
>
>
> ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ 
>
> Here is the whole function :
>
> public void paint()
>        {
>            try
>            {
>                canceldraw.setCanceled(false);
>                /* if (image == null)
>                {
>                    image = new BufferedImage(vp.getImageWidth(), 
> vp.getImageHeight(),
>                            BufferedImage.TYPE_INT_ARGB);
>                    Graphics gTemp = image.createGraphics();
>                    Color theBackColor = vp.getBackColor();
>                    if (theBackColor == null)
>                        gTemp.setColor(Color.WHITE);
>                    else
>                        gTemp.setColor(theBackColor);
>
>                    gTemp.fillRect(0,0,getWidth(), getHeight());
>                    gTemp.dispose();
>                    // g.drawImage(image,0,0,null);
>                    System.out.println("Imagen con null en 
> DESACTUALIZADO. Width = " + this.getWidth());
>                } */
>                Graphics2D g = image.createGraphics();
>
>                ViewPort viewPort = mapContext.getViewPort();
>
>                if (status == DESACTUALIZADO)
>                {
>                    Graphics2D gTemp = image.createGraphics();
>                    Color theBackColor = viewPort.getBackColor();
>                    if (theBackColor == null)
>                        gTemp.setColor(Color.WHITE);
>                    else
>                        gTemp.setColor(theBackColor);
>                    gTemp.fillRect(0, 0, viewPort.getImageWidth(), 
> viewPort.getImageHeight());
>                                                      // status = 
> ACTUALIZADO;/****charlotte: décommenter pour ne pas boucler***/
>                                                        // ESTILO MAC
> //                    BufferedImage imgMac = new 
> BufferedImage(vp.getImageWidth(), vp.getImageHeight(),
> //                            BufferedImage.TYPE_INT_ARGB);
> //
> //                    mapContext.draw(imgMac, g, canceldraw, 
> mapContext.getScaleView());
> //                    g.drawImage(imgMac, 0, 0, null);
>                    // FIN ESTILO MAC
>                    // SIN MAC:
>                                      mapContext.draw(image, g, 
> canceldraw, mapContext.getScaleView());
>                                      
> /************************************added 
> here*******************************************************/
>                    while(true){
>                       Thread.sleep(2000);
>                       this.paint();
>                                             //commandRefresh();
>                        //System.out.println("refresh");
>                   }
>                    
> /**************************************************************************************************/ 
>
>                                  }
>                else if (status == ONLY_GRAPHICS)
>                {
>                    status = ACTUALIZADO;
>                    mapContext.drawGraphics(image, g, 
> canceldraw,mapContext.getScaleView());
>                    System.out.println("charlotte:paint2");
>                }
>
>
>                // status = FAST_PAINT;
>              //  drawerAlive = false;
>                timer.stop();
>                repaint();
>
>
>            } catch (Throwable e) {
>                timer.stop();
>              //  isCancelled = true;
>                e.printStackTrace();
>                throwException(e);
>            } finally {
>            }
>
>        }
>
>    }
>
>
>
>
>



More information about the Gvsig_internacional mailing list