You are viewing a plain text version of this content. The canonical link for it is here.
Posted to batik-users@xmlgraphics.apache.org by Fredrik Medby Hagen <Fr...@idi.ntnu.no> on 2005/03/20 23:01:25 UTC

problem with displaying a SVGDocument

Hi!

I tried posting this some days ago, but got no answer. I guess something
went wrong (had just registered for this mail-list), so I'm trying again.

I've successfully loaded and displayed a document by calling the
loadSVGDocument [1] with an uri. But if trying the setSVGDocument [2] with a
SVGDocument instance, nothing happens at [3].

gvtBuildCompleted is never called when using the setSVGDocument... Any
ideas?

Sincerely, Fredrik

----CODE----

[1] svgCanvas.loadSVGDocument(someValidURI);
[2] svgCanvas.setSVGDocument(someSVGDocument);

[3] waitForGVTTreeBuilding();

private void waitForGVTTreeBuilding(){

        GVTTreeBuilderAdapter gvtba = new GVTTreeBuilderAdapter() {

            public void gvtBuildCompleted(GVTTreeBuilderEvent evt) {
                synchronized(this){notify();}
            }

            public void gvtBuildFailed(GVTTreeBuilderEvent evt){
                JOptionPane.showMessageDialog(gjf,"En feil skjedde under
lasting av svg. "+evt.toString(),"Feil under
lasting",JOptionPane.ERROR_MESSAGE);
            }

            public void gvtBuildCancelled(GVTTreeBuilderEvent evt){
                JOptionPane.showMessageDialog(gjf,"En feil skjedde under
lasting av svg. "+evt.toString(),"Feil under
lasting",JOptionPane.ERROR_MESSAGE);
            }

        };

        svgCanvas.addGVTTreeBuilderListener(gvtba);
        try{synchronized(gvtba){gvtba.wait(0);}}catch(Exception
e){e.printStackTrace();}
    }


---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org


Re: problem with displaying a SVGDocument

Posted by Thomas DeWeese <Th...@Kodak.com>.
Hi Fredrik,

Fredrik Medby Hagen wrote:

> By the way, what is the difference between an interactive document and an
> dynamic document. What different behaviour does Batik show due to the
> documentstate?

 From the BridgeContext (I'll copy some of it over to the Canvas as
that is where most people encounter this):

---

     /**
      * Indicates that no DOM listeners should be registered.
      * In this case the generated GVT tree should be totally
      * independent of the DOM tree.
      */
     public final static int STATIC      = 0;
     /**
      * Indicates that DOM listeners should be registered to support,
      * 'interactivity' this includes anchors and cursors, but does not
      * include support for DOM modifications.
      */
     public final static int INTERACTIVE = 1;

     /**
      * Indicates that all DOM listeners should be registered. This supports
      * 'interactivity' (anchors and cursors), as well as DOM modification
      * listeners to update the GVT rendering tree.
      */
     public final static int DYNAMIC     = 2;


---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org


RE: problem with displaying a SVGDocument

Posted by Fredrik Medby Hagen <Fr...@idi.ntnu.no>.
Hi. I've looked at the document using
org.apache.xml.serialize.XMLSerializer. It looks ok.

I tried commenting out the waitForGVTB... method. And the svg was displayed
correctly. I think this is because the gvtbuild event was dispatched before
the listener was attached (I reckon building the gvt from a local
svgdocument in memory is far faster than downloading from an url, building
the svgdocument and then building the gvt).

The problem was that I attached the listener just before wait()'ing...
Problem solved. Thanks for all help :)

By the way, what is the difference between an interactive document and an
dynamic document. What different behaviour does Batik show due to the
documentstate?

Sincerely, Fredrik

-----Original Message-----
From: Thomas DeWeese [mailto:Thomas.DeWeese@Kodak.com]
Sent: 21. mars 2005 02:09
To: batik-users@xmlgraphics.apache.org
Subject: Re: problem with displaying a SVGDocument


Fredrik Medby Hagen wrote:
> Hi. This method is used to get the svgdocument:
>
>     public static SVGDocument textToSVGDocument(String xmlSvg) throws
> Exception{
>         SAXSVGDocumentFactory ssdf = new
> SAXSVGDocumentFactory(XMLResourceDescriptor.getXMLParserClassName());
>         return
>
(SVGDocument)ssdf.createDocument("http:\\\\idi.ntnu.no\\~fredrhag\\test.svg"
> ,new StringReader(xmlSvg));
>     }
>
> The method returns a SVGDocument (the text is parsed and everything is
> ok...). The uri input to the createDocument is chosen at "random" since
the
> document is created from a string which has no uri. Does it matter? What
is
> the uri used for?

   It can matter, that is used as the 'base URL' for the document.
This is used when resolving external references (mostly images).

> Neither (from code below) gvtBuildSucceded/Failed or Cancelled is called.
> One of then should be called right?

    Yes in all cases one of them must be called if gvtBuildStarted
is called.  Is Build Started called?

    Also have you "looked" at the Document you get back?

>
> Sincerely, Fredrik
>
> -----Original Message-----
> From: Thomas DeWeese [mailto:Thomas.DeWeese@Kodak.com]
> Sent: 20. mars 2005 23:21
> To: batik-users@xmlgraphics.apache.org
> Cc: batik-users@xml.apache.org
> Subject: Re: problem with displaying a SVGDocument
>
>
> Hi Fredrik,
>
> Fredrik Medby Hagen wrote:
>
>
>>I tried posting this some days ago, but got no answer. I guess something
>>went wrong (had just registered for this mail-list), so I'm trying again.
>>
>>I've successfully loaded and displayed a document by calling the
>>loadSVGDocument [1] with an uri. But if trying the setSVGDocument [2] with
>
> a
>
>>SVGDocument instance, nothing happens at [3].
>>
>>gvtBuildCompleted is never called when using the setSVGDocument... Any
>>ideas?
>
>
>    Unless you have any more information not really ;)
>    How are you creating the SVG Document?   You might want to read
> the thread about 'namespace woes'.
>
>
>>Sincerely, Fredrik
>>
>>----CODE----
>>
>>[1] svgCanvas.loadSVGDocument(someValidURI);
>>[2] svgCanvas.setSVGDocument(someSVGDocument);
>>
>>[3] waitForGVTTreeBuilding();
>>
>>private void waitForGVTTreeBuilding(){
>>
>>        GVTTreeBuilderAdapter gvtba = new GVTTreeBuilderAdapter() {
>>
>>            public void gvtBuildCompleted(GVTTreeBuilderEvent evt) {
>>                synchronized(this){notify();}
>>            }
>>
>>            public void gvtBuildFailed(GVTTreeBuilderEvent evt){
>>                JOptionPane.showMessageDialog(gjf,"En feil skjedde under
>>lasting av svg. "+evt.toString(),"Feil under
>>lasting",JOptionPane.ERROR_MESSAGE);
>>            }
>>
>>            public void gvtBuildCancelled(GVTTreeBuilderEvent evt){
>>                JOptionPane.showMessageDialog(gjf,"En feil skjedde under
>>lasting av svg. "+evt.toString(),"Feil under
>>lasting",JOptionPane.ERROR_MESSAGE);
>>            }
>>
>>        };
>>
>>        svgCanvas.addGVTTreeBuilderListener(gvtba);
>>        try{synchronized(gvtba){gvtba.wait(0);}}catch(Exception
>>e){e.printStackTrace();}
>>    }
>>
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
>>For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org
>>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
> For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
> For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org


Re: problem with displaying a SVGDocument

Posted by Thomas DeWeese <Th...@Kodak.com>.
Fredrik Medby Hagen wrote:
> Hi. This method is used to get the svgdocument:
> 
>     public static SVGDocument textToSVGDocument(String xmlSvg) throws
> Exception{
>         SAXSVGDocumentFactory ssdf = new
> SAXSVGDocumentFactory(XMLResourceDescriptor.getXMLParserClassName());
>         return
> (SVGDocument)ssdf.createDocument("http:\\\\idi.ntnu.no\\~fredrhag\\test.svg"
> ,new StringReader(xmlSvg));
>     }
> 
> The method returns a SVGDocument (the text is parsed and everything is
> ok...). The uri input to the createDocument is chosen at "random" since the
> document is created from a string which has no uri. Does it matter? What is
> the uri used for?

   It can matter, that is used as the 'base URL' for the document.
This is used when resolving external references (mostly images).

> Neither (from code below) gvtBuildSucceded/Failed or Cancelled is called.
> One of then should be called right?

    Yes in all cases one of them must be called if gvtBuildStarted
is called.  Is Build Started called?

    Also have you "looked" at the Document you get back?

> 
> Sincerely, Fredrik
> 
> -----Original Message-----
> From: Thomas DeWeese [mailto:Thomas.DeWeese@Kodak.com]
> Sent: 20. mars 2005 23:21
> To: batik-users@xmlgraphics.apache.org
> Cc: batik-users@xml.apache.org
> Subject: Re: problem with displaying a SVGDocument
> 
> 
> Hi Fredrik,
> 
> Fredrik Medby Hagen wrote:
> 
> 
>>I tried posting this some days ago, but got no answer. I guess something
>>went wrong (had just registered for this mail-list), so I'm trying again.
>>
>>I've successfully loaded and displayed a document by calling the
>>loadSVGDocument [1] with an uri. But if trying the setSVGDocument [2] with
> 
> a
> 
>>SVGDocument instance, nothing happens at [3].
>>
>>gvtBuildCompleted is never called when using the setSVGDocument... Any
>>ideas?
> 
> 
>    Unless you have any more information not really ;)
>    How are you creating the SVG Document?   You might want to read
> the thread about 'namespace woes'.
> 
> 
>>Sincerely, Fredrik
>>
>>----CODE----
>>
>>[1] svgCanvas.loadSVGDocument(someValidURI);
>>[2] svgCanvas.setSVGDocument(someSVGDocument);
>>
>>[3] waitForGVTTreeBuilding();
>>
>>private void waitForGVTTreeBuilding(){
>>
>>        GVTTreeBuilderAdapter gvtba = new GVTTreeBuilderAdapter() {
>>
>>            public void gvtBuildCompleted(GVTTreeBuilderEvent evt) {
>>                synchronized(this){notify();}
>>            }
>>
>>            public void gvtBuildFailed(GVTTreeBuilderEvent evt){
>>                JOptionPane.showMessageDialog(gjf,"En feil skjedde under
>>lasting av svg. "+evt.toString(),"Feil under
>>lasting",JOptionPane.ERROR_MESSAGE);
>>            }
>>
>>            public void gvtBuildCancelled(GVTTreeBuilderEvent evt){
>>                JOptionPane.showMessageDialog(gjf,"En feil skjedde under
>>lasting av svg. "+evt.toString(),"Feil under
>>lasting",JOptionPane.ERROR_MESSAGE);
>>            }
>>
>>        };
>>
>>        svgCanvas.addGVTTreeBuilderListener(gvtba);
>>        try{synchronized(gvtba){gvtba.wait(0);}}catch(Exception
>>e){e.printStackTrace();}
>>    }
>>
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
>>For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org
>>
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
> For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
> For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org


RE: problem with displaying a SVGDocument

Posted by Fredrik Medby Hagen <Fr...@idi.ntnu.no>.
Hi. This method is used to get the svgdocument:

    public static SVGDocument textToSVGDocument(String xmlSvg) throws
Exception{
        SAXSVGDocumentFactory ssdf = new
SAXSVGDocumentFactory(XMLResourceDescriptor.getXMLParserClassName());
        return
(SVGDocument)ssdf.createDocument("http:\\\\idi.ntnu.no\\~fredrhag\\test.svg"
,new StringReader(xmlSvg));
    }

The method returns a SVGDocument (the text is parsed and everything is
ok...). The uri input to the createDocument is chosen at "random" since the
document is created from a string which has no uri. Does it matter? What is
the uri used for?

Neither (from code below) gvtBuildSucceded/Failed or Cancelled is called.
One of then should be called right?

Sincerely, Fredrik

-----Original Message-----
From: Thomas DeWeese [mailto:Thomas.DeWeese@Kodak.com]
Sent: 20. mars 2005 23:21
To: batik-users@xmlgraphics.apache.org
Cc: batik-users@xml.apache.org
Subject: Re: problem with displaying a SVGDocument


Hi Fredrik,

Fredrik Medby Hagen wrote:

> I tried posting this some days ago, but got no answer. I guess something
> went wrong (had just registered for this mail-list), so I'm trying again.
>
> I've successfully loaded and displayed a document by calling the
> loadSVGDocument [1] with an uri. But if trying the setSVGDocument [2] with
a
> SVGDocument instance, nothing happens at [3].
>
> gvtBuildCompleted is never called when using the setSVGDocument... Any
> ideas?

   Unless you have any more information not really ;)
   How are you creating the SVG Document?   You might want to read
the thread about 'namespace woes'.

>
> Sincerely, Fredrik
>
> ----CODE----
>
> [1] svgCanvas.loadSVGDocument(someValidURI);
> [2] svgCanvas.setSVGDocument(someSVGDocument);
>
> [3] waitForGVTTreeBuilding();
>
> private void waitForGVTTreeBuilding(){
>
>         GVTTreeBuilderAdapter gvtba = new GVTTreeBuilderAdapter() {
>
>             public void gvtBuildCompleted(GVTTreeBuilderEvent evt) {
>                 synchronized(this){notify();}
>             }
>
>             public void gvtBuildFailed(GVTTreeBuilderEvent evt){
>                 JOptionPane.showMessageDialog(gjf,"En feil skjedde under
> lasting av svg. "+evt.toString(),"Feil under
> lasting",JOptionPane.ERROR_MESSAGE);
>             }
>
>             public void gvtBuildCancelled(GVTTreeBuilderEvent evt){
>                 JOptionPane.showMessageDialog(gjf,"En feil skjedde under
> lasting av svg. "+evt.toString(),"Feil under
> lasting",JOptionPane.ERROR_MESSAGE);
>             }
>
>         };
>
>         svgCanvas.addGVTTreeBuilderListener(gvtba);
>         try{synchronized(gvtba){gvtba.wait(0);}}catch(Exception
> e){e.printStackTrace();}
>     }
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
> For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org


Re: problem with displaying a SVGDocument

Posted by Thomas DeWeese <Th...@Kodak.com>.
Hi Fredrik,

Fredrik Medby Hagen wrote:

> I tried posting this some days ago, but got no answer. I guess something
> went wrong (had just registered for this mail-list), so I'm trying again.
> 
> I've successfully loaded and displayed a document by calling the
> loadSVGDocument [1] with an uri. But if trying the setSVGDocument [2] with a
> SVGDocument instance, nothing happens at [3].
> 
> gvtBuildCompleted is never called when using the setSVGDocument... Any
> ideas?

   Unless you have any more information not really ;)
   How are you creating the SVG Document?   You might want to read
the thread about 'namespace woes'.

> 
> Sincerely, Fredrik
> 
> ----CODE----
> 
> [1] svgCanvas.loadSVGDocument(someValidURI);
> [2] svgCanvas.setSVGDocument(someSVGDocument);
> 
> [3] waitForGVTTreeBuilding();
> 
> private void waitForGVTTreeBuilding(){
> 
>         GVTTreeBuilderAdapter gvtba = new GVTTreeBuilderAdapter() {
> 
>             public void gvtBuildCompleted(GVTTreeBuilderEvent evt) {
>                 synchronized(this){notify();}
>             }
> 
>             public void gvtBuildFailed(GVTTreeBuilderEvent evt){
>                 JOptionPane.showMessageDialog(gjf,"En feil skjedde under
> lasting av svg. "+evt.toString(),"Feil under
> lasting",JOptionPane.ERROR_MESSAGE);
>             }
> 
>             public void gvtBuildCancelled(GVTTreeBuilderEvent evt){
>                 JOptionPane.showMessageDialog(gjf,"En feil skjedde under
> lasting av svg. "+evt.toString(),"Feil under
> lasting",JOptionPane.ERROR_MESSAGE);
>             }
> 
>         };
> 
>         svgCanvas.addGVTTreeBuilderListener(gvtba);
>         try{synchronized(gvtba){gvtba.wait(0);}}catch(Exception
> e){e.printStackTrace();}
>     }
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
> For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org