Hi,

I tried to test the Batik 1.5.1 framework and I encountered a big problem with several svg files. Some are included in the sanples directory of the quizzle browser and others are created by myself.
The problem is following:


When I load the file via JSVGCanvas.setURI(String) method, the document is loaded, parsed and rendered. But exactly when the image is diplayed it dissapears and the rendering starts again. This occurs over and over. Does anyone have a clue? The code I use is pasted at the bottom. One of the files, which does not work properly is the anne.svg file from the sample folder of the batik distribution. All of these files work in the squiggle browser, but not in mine. Do I have to set any option?

Thanks in advance,

Alexander

I use realtively simple code, most of it copied from the batik website. The class, representing the svg viewer is following:

package am.dc.vext.gui;

import javax.swing.*;
import java.awt.*;
import org.apache.batik.swing.*;
import java.io.File;
import java.io.IOException;
import org.apache.batik.swing.svg.SVGDocumentLoaderAdapter;
import org.apache.batik.swing.svg.SVGDocumentLoaderEvent;
import org.apache.batik.swing.svg.GVTTreeBuilderAdapter;
import org.apache.batik.swing.svg.GVTTreeBuilderEvent;
import org.apache.batik.swing.gvt.GVTTreeRendererAdapter;
import org.apache.batik.swing.gvt.GVTTreeRendererEvent;


public class SVGPane extends JPanel { private JSVGCanvas svgCanvas = new JSVGCanvas(); private JLabel label = new JLabel("SVG Graphics");

   public void setSVG(File f) {
       try {
           svgCanvas.setURI(f.toURL().toString());
       } catch (IOException ex) {
           ex.printStackTrace();
       }
   }

   public SVGPane() {
       this.setLayout(new BorderLayout());
       createComponents();
   }

   public void createComponents() {
       JPanel p = new JPanel(new FlowLayout(FlowLayout.LEFT));

p.add(label);

       add(p, BorderLayout.NORTH);
       add(svgCanvas, BorderLayout.CENTER);

// Set the JSVGCanvas listeners.
svgCanvas.addSVGDocumentLoaderListener(new SVGDocumentLoaderAdapter() {
public void documentLoadingStarted(SVGDocumentLoaderEvent e) {
label.setText("Document Loading...");
}


           public void documentLoadingCompleted(SVGDocumentLoaderEvent e) {
               label.setText("Document Loaded.");
           }
       });

       svgCanvas.addGVTTreeBuilderListener(new GVTTreeBuilderAdapter() {
           public void gvtBuildStarted(GVTTreeBuilderEvent e) {
               label.setText("Build Started...");
           }

           public void gvtBuildCompleted(GVTTreeBuilderEvent e) {
               label.setText("Build Done.");
               validate();
           }
       });

       svgCanvas.addGVTTreeRendererListener(new GVTTreeRendererAdapter() {
           public void gvtRenderingPrepare(GVTTreeRendererEvent e) {
               label.setText("Rendering Started...");
           }

           public void gvtRenderingCompleted(GVTTreeRendererEvent e) {
               label.setText("");
           }
       });
   }
}





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



Reply via email to