[Gvsig_english] Refresh functionnality

Charlotte Declercq c.declercq at alkante.com
Tue Jul 29 08:14:16 CEST 2008


Hi,

I have tried this but it doesn't draw the layers at all.
I don't know what to do.
Could someone from Iver help ?

Charlotte

Fran a écrit :
> 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 {
>>            }
>>
>>        }
>>
>>    }
>>
>>
>>
>>
>>
>
> _______________________________________________
> Gvsig_internacional mailing list
> Gvsig_internacional at runas.cap.gva.es
> http://runas.cap.gva.es/mailman/listinfo/gvsig_internacional
>


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