[Gvsig_english] Refresh functionnality

Charlotte Declercq c.declercq at alkante.com
Thu Jul 24 11:15:58 CEST 2008


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 {
            }

        }

    }





-- 
Charlotte DECLERCQ

ALKANTE SAS
Ingénieur R&D SIG
1, rue du Chêne Morand
35 510 Cesson-Sévigné
Bur: + 33 (0) 2 99 22 25 70
fax : + 33 (0) 2 99 32 12 76





More information about the Gvsig_internacional mailing list