noni_4444 wrote:
> 
> I have an SVG document containing a rectangle which is to be animated
> repeatedly depending upon a value received in a callback function. The
> SVG document is loaded inside an applet. The problem i face is that 
> SVGCanvas is not updated automatically until i minimize the html page
> containing the applet and maximize it. Doing this calls the repaint method
> of applet. If i call the repaint method myself inside the callback method,
> i see the canvas flickering.  I have already read a dozen posts on this
> forum
>  related to this and have tried all the suggested solutions. All point to
> something like
> 
> "If you set the canvas's document state to JSVGCanvas.ALWAYS_DYNAMIC and
> run
> all your document updates in the UpdateManager, it should update itself".
> 
> What to do to update the SVG canvas without calling repaint() ? I am
> already following
> the above guideline.
> 
> Following are relevant portions of my code.
> 
> public class BatikApplet extends Applet {
>         UpdateManager updateManager = null;
>       
>         //Initialize the applet
>         public void init() {
>                 jbInit();
>                 svgCanvas = new JSVGCanvas();
>                 svgCanvas.setDocumentState(JSVGCanvas.ALWAYS_DYNAMIC);
>                 String parser =
> XMLResourceDescriptor.getXMLParserClassName();
>                 docFactory = new SAXSVGDocumentFactory(parser);
>                 rectDoc =
> docFactory.createSVGDocument("http://localhost:8080/"+screenName);
>               registerListeners();
>                 svgCanvas.setDocument(rectDoc);
>                 this.add(svgCanvas, BorderLayout.NORTH);
>                 svgCanvas.repaint();
>           }
> 
>       // Paint method
>         public void paint(Graphics g) {
>               svgCanvas.paintComponent(g);
>         }
> 
>       // Method which is called repeatedly with updated animation values to be
> drawn
>           public synchronized void callback(final String strData) {
>                   runnable = new Runnable() {
>                       public void run() {
>                         //Call to external object which changes the SVG 
> document
>                           oAnimEngine.animateScreen(strData); 
>                       }
>                   };
> 
>               try {
>                  
> updateManager.getUpdateRunnableQueue().invokeLater(runnable);
>               } catch (Exception ex) {
>                   
>               }
>           }
> 
>       // Register listener method
>           public void registerListeners() {
>               svgCanvas.addGVTTreeRendererListener(new
> GVTTreeRendererAdapter() {
>                   public void gvtRenderingCompleted(GVTTreeRendererEvent
> e) {
>                       updateManager = svgCanvas.getUpdateManager();
>                       oAnimEngine.setCustomSVGDocument(rectDoc);
>                   }
>               });
>     }
> }
> 

-- 
View this message in context: 
http://www.nabble.com/Require-repaint-in-applet-to-update-canvas-tf4403481.html#a12593679
Sent from the Batik - Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to