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 Frederik Santens <fr...@pandora.be> on 2004/07/19 01:17:03 UTC

Backend driven svg application

Hello,
 
We have a notification engine that fire events when changes occur in the
backend system. Based upon those events we would like to update the
JSVGCanvas in correspondence with these backend data changes. The rate
at which those changes occur, is every 10 seconds, so, for performance
reasons, we are probably not able to rerender the svg each time (with a
setDocument(…)). We also want to avoid the blinking and the loss of the
zoom status that occurs when rerendering the svg in the JSVGCanvas. 
 
The ideal situation for us, would be to change the svg dynamically. I
tried calling a script (defined in the svg) from within the java code
but without success.
 
My code:
 
UpdateManager um = svgCanvas.getUpdateManager();
Interpreter ip =
um.getBridgeContext().getInterpreter("text/ecmascript");
ScriptRun sr = new ScriptRun("alert", ip);
um.getUpdateRunnableQueue().invokeLater(sr);
 
public class ScriptRun implements Runnable{
    private Interpreter interpreter;
    private String scriptName;
 
    public ScriptRun(String scriptName, Interpreter interpreter) {
        this.interpreter = interpreter;
        this.scriptName = scriptName;
    }
 
    public void run() {
        try{
            interpreter.evaluate(this.scriptName);
        } catch(InterpreterException ie){
            ie.printStackTrace();
        }
    }
}
 
What is going wrong? Or are there better approaches to tackle this
problem. 
 
I’m using batik 1.5.1. on JDK 1.4.2_04.
 
Thx
Frederik
 

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.708 / Virus Database: 464 - Release Date: 18/06/2004
 

Re: Backend driven svg application

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

    I don't know how big a deal it is for you but you can
fairly easily avoid having the svg canvas copy your
document by using the Batik DOM Implementation.  The
easiest thing to do is use:

    batik.dom.svg.SAXSVGDocumentFactory

    You can provide any SAX2 Parser class to the constructor
(such as: "org.apache.xerces.parsers.SAXParser").

Frederik Santens wrote:

> Ok it works. Indeed, the problem was that I used the parsed document and
> not the svgcanvas' internal document.
> 
> From: Thomas DeWeese [mailto:Thomas.DeWeese@Kodak.com] 

> Hi Frederik,
> 
>     Can you provide the SVG file being manipulated?
> 
>     Also where does 'doc' come from (in some cases the
> canvas has to 'copy' the given document)?  It's
> generally best to use svgCanvas.getSVGDocument().
> 
>     Are you sure that 'node' is the element you
> expect it to be (I assume a rect)?
> 
> Frederik Santens wrote:
>>
>>Instead of calling the javascript from updatemanager thread, I
>>manipulate the DOM tree of the svg now. Here is the code:
>>
>>I'm just trying to move the position of a text field.
>>
>>However the svgCanvas does not reflect the changes. What am I doing
>>wrong?

>>Frederik Santens wrote:
>>
>>>I had a javascript function named "alert" which just called
>>>alert("Helloworld"); 
>>>
>>>When I called my alert js function from within java
>>>(Interpeter.evaluate("alert()")) I got this StackOverflowError. When I
>>>changed the name of the function to 'displayMessage' it worked.
>>
>>>Probably something with reserved words.
>>
>>   Well just confusion about which 'alert' function to call, in JS
>>there is no function overloading so your 'alert' function called
>>itself.
>>
>>>Can I pass references to custom objects to the javascript too?
>>
>>    Yes, although you'll have to work at it a bit since you can't
>>easily reference your custom object from the string.  The easiest
>>thing to do is use 'bind' to associate your custom object with
>>a global variable in JS, then have your function just use that
>>global var - Iky, I know.  Also be careful as it is really easy to
>>introduce memory leaks this way.
>>
>>>You mentioned also in the previous reply that I don't need javascript
>>>to do the dynamic updates of my rendered svg. Do you mean manipulating
>>>the DOM tree via the updatemanager thread is the alternative way of doing
>>>this or are there other ways?
>>
>>    This is what I mean.  Once you are running in the Update manager
>>thread you can just manipulate the DOM tree using Java.  What other
>>way did you have in mind?

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


RE: Backend driven svg application

Posted by Frederik Santens <fr...@pandora.be>.
Hi Thomas

Ok it works. Indeed, the problem was that I used the parsed document and
not the svgcanvas' internal document.

Thx a lot!
Frederik

-----Original Message-----
From: Thomas DeWeese [mailto:Thomas.DeWeese@Kodak.com] 
Sent: maandag 19 juli 2004 22:26
To: Batik Users
Subject: Re: Backend driven svg application

Hi Frederik,

    Can you provide the SVG file being manipulated?

    Also where does 'doc' come from (in some cases the
canvas has to 'copy' the given document)?  It's
generally best to use svgCanvas.getSVGDocument().

    Are you sure that 'node' is the element you
expect it to be (I assume a rect)?

Frederik Santens wrote:

> Hi,
> 
> Instead of calling the javascript from updatemanager thread, I
> manipulate the DOM tree of the svg now. Here is the code:
> 
> UpdateManager um = svgCanvas.getUpdateManager();
> ScriptRun1 sr = new ScriptRun1(doc);
> try{
>   um.getUpdateRunnableQueue().invokeLater(sr);
> }catch(Throwable t){
>   t.printStackTrace();
> }
> 
> public class ScriptRun1 implements Runnable{
>     Document doc;
>     public ScriptRun1(Document doc) {
>         this.doc = doc;
>     }
>     public void run() {
>             Element element = doc.getElementById("testContent");
>             Element node = (Element)element.getChildNodes().item(1);
>             int x = Integer.parseInt(node.getAttribute("x"));
>             x = x + 10;
>             node.setAttribute("x", "" + x);
>     }
> }
> 
> I'm just trying to move the position of a text field.
> 
> However the svgCanvas does not reflect the changes. What am I doing
> wrong?
> 
> Frederik    
> 
> 
> 
> 
> 
> -----Original Message-----
> From: Thomas DeWeese [mailto:Thomas.DeWeese@Kodak.com] 
> Sent: maandag 19 juli 2004 15:39
> To: Batik Users
> Subject: Re: Backend driven svg application
> 
> Frederik Santens wrote:
> 
> 
>>I had a javascript function named "alert" which just called
>>alert("Helloworld"); 
>>
>>When I called my alert js function from within java
>>(Interpeter.evaluate("alert()")) I got this StackOverflowError. When I
>>changed the name of the function to 'displayMessage' it worked.
> 
> Probably
> 
>>something with reserved words.
> 
> 
>    Well just confusion about which 'alert' function to call, in JS
> there is no function overloading so your 'alert' function called
> itself.
> 
> 
>>Can I pass references to custom objects to the javascript too?
> 
> 
>     Yes, although you'll have to work at it a bit since you can't
> easily reference your custom object from the string.  The easiest
> thing to do is use 'bind' to associate your custom object with
> a global variable in JS, then have your function just use that
> global var - Iky, I know.  Also be careful as it is really easy to
> introduce memory leaks this way.
> 
> 
>>You mentioned also in the previous reply that I don't need javascript
> 
> to
> 
>>do the dynamic updates of my rendered svg. Do you mean manipulating
> 
> the
> 
>>DOM tree via the updatemanager thread is the alternative way of doing
>>this or are there other ways?
> 
> 
>     This is what I mean.  Once you are running in the Update manager
> thread you can just manipulate the DOM tree using Java.  What other
> way did you have in mind?
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
> For additional commands, e-mail: batik-users-help@xml.apache.org
> 
> 
> ---
> Incoming mail is certified Virus Free.
> Checked by AVG anti-virus system (http://www.grisoft.com).
> Version: 6.0.708 / Virus Database: 464 - Release Date: 18/06/2004
>  
> 
> ---
> Outgoing mail is certified Virus Free.
> Checked by AVG anti-virus system (http://www.grisoft.com).
> Version: 6.0.708 / Virus Database: 464 - Release Date: 18/06/2004
>  
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
> For additional commands, e-mail: batik-users-help@xml.apache.org


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


---
Incoming mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.708 / Virus Database: 464 - Release Date: 18/06/2004
 

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.708 / Virus Database: 464 - Release Date: 18/06/2004
 


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


Re: Backend driven svg application

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

    Can you provide the SVG file being manipulated?

    Also where does 'doc' come from (in some cases the
canvas has to 'copy' the given document)?  It's
generally best to use svgCanvas.getSVGDocument().

    Are you sure that 'node' is the element you
expect it to be (I assume a rect)?

Frederik Santens wrote:

> Hi,
> 
> Instead of calling the javascript from updatemanager thread, I
> manipulate the DOM tree of the svg now. Here is the code:
> 
> UpdateManager um = svgCanvas.getUpdateManager();
> ScriptRun1 sr = new ScriptRun1(doc);
> try{
>   um.getUpdateRunnableQueue().invokeLater(sr);
> }catch(Throwable t){
>   t.printStackTrace();
> }
> 
> public class ScriptRun1 implements Runnable{
>     Document doc;
>     public ScriptRun1(Document doc) {
>         this.doc = doc;
>     }
>     public void run() {
>             Element element = doc.getElementById("testContent");
>             Element node = (Element)element.getChildNodes().item(1);
>             int x = Integer.parseInt(node.getAttribute("x"));
>             x = x + 10;
>             node.setAttribute("x", "" + x);
>     }
> }
> 
> I'm just trying to move the position of a text field.
> 
> However the svgCanvas does not reflect the changes. What am I doing
> wrong?
> 
> Frederik    
> 
> 
> 
> 
> 
> -----Original Message-----
> From: Thomas DeWeese [mailto:Thomas.DeWeese@Kodak.com] 
> Sent: maandag 19 juli 2004 15:39
> To: Batik Users
> Subject: Re: Backend driven svg application
> 
> Frederik Santens wrote:
> 
> 
>>I had a javascript function named "alert" which just called
>>alert("Helloworld"); 
>>
>>When I called my alert js function from within java
>>(Interpeter.evaluate("alert()")) I got this StackOverflowError. When I
>>changed the name of the function to 'displayMessage' it worked.
> 
> Probably
> 
>>something with reserved words.
> 
> 
>    Well just confusion about which 'alert' function to call, in JS
> there is no function overloading so your 'alert' function called
> itself.
> 
> 
>>Can I pass references to custom objects to the javascript too?
> 
> 
>     Yes, although you'll have to work at it a bit since you can't
> easily reference your custom object from the string.  The easiest
> thing to do is use 'bind' to associate your custom object with
> a global variable in JS, then have your function just use that
> global var - Iky, I know.  Also be careful as it is really easy to
> introduce memory leaks this way.
> 
> 
>>You mentioned also in the previous reply that I don't need javascript
> 
> to
> 
>>do the dynamic updates of my rendered svg. Do you mean manipulating
> 
> the
> 
>>DOM tree via the updatemanager thread is the alternative way of doing
>>this or are there other ways?
> 
> 
>     This is what I mean.  Once you are running in the Update manager
> thread you can just manipulate the DOM tree using Java.  What other
> way did you have in mind?
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
> For additional commands, e-mail: batik-users-help@xml.apache.org
> 
> 
> ---
> Incoming mail is certified Virus Free.
> Checked by AVG anti-virus system (http://www.grisoft.com).
> Version: 6.0.708 / Virus Database: 464 - Release Date: 18/06/2004
>  
> 
> ---
> Outgoing mail is certified Virus Free.
> Checked by AVG anti-virus system (http://www.grisoft.com).
> Version: 6.0.708 / Virus Database: 464 - Release Date: 18/06/2004
>  
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
> For additional commands, e-mail: batik-users-help@xml.apache.org


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


RE: Backend driven svg application

Posted by Frederik Santens <fr...@pandora.be>.
Hi,

Instead of calling the javascript from updatemanager thread, I
manipulate the DOM tree of the svg now. Here is the code:

UpdateManager um = svgCanvas.getUpdateManager();
ScriptRun1 sr = new ScriptRun1(doc);
try{
  um.getUpdateRunnableQueue().invokeLater(sr);
}catch(Throwable t){
  t.printStackTrace();
}

public class ScriptRun1 implements Runnable{
    Document doc;
    public ScriptRun1(Document doc) {
        this.doc = doc;
    }
    public void run() {
            Element element = doc.getElementById("testContent");
            Element node = (Element)element.getChildNodes().item(1);
            int x = Integer.parseInt(node.getAttribute("x"));
            x = x + 10;
            node.setAttribute("x", "" + x);
    }
}

I'm just trying to move the position of a text field.

However the svgCanvas does not reflect the changes. What am I doing
wrong?

Frederik    





-----Original Message-----
From: Thomas DeWeese [mailto:Thomas.DeWeese@Kodak.com] 
Sent: maandag 19 juli 2004 15:39
To: Batik Users
Subject: Re: Backend driven svg application

Frederik Santens wrote:

> I had a javascript function named "alert" which just called
> alert("Helloworld"); 
> 
> When I called my alert js function from within java
> (Interpeter.evaluate("alert()")) I got this StackOverflowError. When I
> changed the name of the function to 'displayMessage' it worked.
Probably
> something with reserved words.

   Well just confusion about which 'alert' function to call, in JS
there is no function overloading so your 'alert' function called
itself.

> Can I pass references to custom objects to the javascript too?

    Yes, although you'll have to work at it a bit since you can't
easily reference your custom object from the string.  The easiest
thing to do is use 'bind' to associate your custom object with
a global variable in JS, then have your function just use that
global var - Iky, I know.  Also be careful as it is really easy to
introduce memory leaks this way.

> You mentioned also in the previous reply that I don't need javascript
to
> do the dynamic updates of my rendered svg. Do you mean manipulating
the
> DOM tree via the updatemanager thread is the alternative way of doing
> this or are there other ways?

    This is what I mean.  Once you are running in the Update manager
thread you can just manipulate the DOM tree using Java.  What other
way did you have in mind?


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


---
Incoming mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.708 / Virus Database: 464 - Release Date: 18/06/2004
 

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.708 / Virus Database: 464 - Release Date: 18/06/2004
 


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


Re: Backend driven svg application

Posted by Thomas DeWeese <Th...@Kodak.com>.
Frederik Santens wrote:

> I had a javascript function named "alert" which just called
> alert("Helloworld"); 
> 
> When I called my alert js function from within java
> (Interpeter.evaluate("alert()")) I got this StackOverflowError. When I
> changed the name of the function to 'displayMessage' it worked. Probably
> something with reserved words.

   Well just confusion about which 'alert' function to call, in JS
there is no function overloading so your 'alert' function called
itself.

> Can I pass references to custom objects to the javascript too?

    Yes, although you'll have to work at it a bit since you can't
easily reference your custom object from the string.  The easiest
thing to do is use 'bind' to associate your custom object with
a global variable in JS, then have your function just use that
global var - Iky, I know.  Also be careful as it is really easy to
introduce memory leaks this way.

> You mentioned also in the previous reply that I don't need javascript to
> do the dynamic updates of my rendered svg. Do you mean manipulating the
> DOM tree via the updatemanager thread is the alternative way of doing
> this or are there other ways?

    This is what I mean.  Once you are running in the Update manager
thread you can just manipulate the DOM tree using Java.  What other
way did you have in mind?


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


RE: Backend driven svg application

Posted by Frederik Santens <fr...@pandora.be>.
Hi Thomas,

I had a javascript function named "alert" which just called
alert("Helloworld"); 


When I called my alert js function from within java
(Interpeter.evaluate("alert()")) I got this StackOverflowError. When I
changed the name of the function to 'displayMessage' it worked. Probably
something with reserved words.

Can I pass references to custom objects to the javascript too?

You mentioned also in the previous reply that I don't need javascript to
do the dynamic updates of my rendered svg. Do you mean manipulating the
DOM tree via the updatemanager thread is the alternative way of doing
this or are there other ways?

Frederik



-----Original Message-----
From: Thomas DeWeese [mailto:Thomas.DeWeese@Kodak.com] 
Sent: maandag 19 juli 2004 14:45
To: Batik Users
Subject: Re: Backend driven svg application

Hi Fredrik,

Frederik Santens wrote:

> When I put alert() instead of alert I get a 

   It just occurred to me that it should probably really be:

'alert("Hello World")'

   Can't imagine why that would cause infinite recursion, but
it might be the problem...

> 
> ava.lang.StackOverflowError
> 	at
> org.mozilla.javascript.ImporterTopLevel.has(ImporterTopLevel.java:101)
> 	at
>
org.mozilla.javascript.ScriptableObject.getBase(ScriptableObject.java:15
> 83)
> 	at
>
org.mozilla.javascript.ScriptableObject.hasProperty(ScriptableObject.jav
> a:1443)
> 	at
> org.mozilla.javascript.ScriptRuntime.bind(ScriptRuntime.java:1096)
> 	at
> org.mozilla.javascript.ScriptRuntime.getBase(ScriptRuntime.java:1106)
> 	at org.mozilla.javascript.gen.c1.call(Inline <script>
> file:/G:/HomeProjects/batik/intellij/multi.svg:73:4)
> 	at
> org.mozilla.javascript.ScriptRuntime.call(ScriptRuntime.java:1191)
> 	at org.mozilla.javascript.gen.c1.call(Inline <script>
> file:/G:/HomeProjects/batik/intellij/multi.svg:73:4)
> ...
> 
> Frederik
> 
> 
> -----Original Message-----
> From: Thomas DeWeese [mailto:Thomas.DeWeese@Kodak.com] 
> Sent: maandag 19 juli 2004 1:41
> To: Batik Users
> Subject: Re: Backend driven svg application
> 
> Frederik Santens wrote:
> 
> 
>>We have a notification engine that fire events when changes occur in
> 
> the 
> 
>>backend system. Based upon those events we would like to update the 
>>JSVGCanvas in correspondence with these backend data changes. The rate
> 
> 
>>at which those changes occur, is every 10 seconds, so, for performance
> 
> 
>>reasons, we are probably not able to rerender the svg each time (with
> 
> a 
> 
>>setDocument(…)). We also want to avoid the blinking and the loss of
> 
> the 
> 
>>zoom status that occurs when rerendering the svg in the JSVGCanvas.
>>
>>The ideal situation for us, would be to change the svg dynamically. I 
>>tried calling a script (defined in the svg) from within the java code 
>>but without success.
> 
> 
>     You should be aware that you can modify the SVG Document from
> Java directly (as long as you do it from within the UpdateManager
> Thread).  The most common mistake for systems like this is to fail
> to inform the canvas that the document should be treated as dynamic.
> This is done with:
> 
>     svgCanvas.setDocumentState(JSVGComponent.ALWAYS_DYNAMIC).
> 
> 
>>UpdateManager um = svgCanvas.getUpdateManager();
>>
>>Interpreter ip =
> 
> um.getBridgeContext().getInterpreter("text/ecmascript");
> 
>>ScriptRun sr = new ScriptRun("alert", ip);
> 
> 
>     This should probably be 'alert()'.
> 
> 
>>um.getUpdateRunnableQueue ( ).invokeLater(sr);
>>
>>What is going wrong? Or are there better approaches to tackle this
> 
> problem.
> 
>     Does anything happen when you do this (exception etc?).
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
> For additional commands, e-mail: batik-users-help@xml.apache.org
> 
> 
> ---
> Incoming mail is certified Virus Free.
> Checked by AVG anti-virus system (http://www.grisoft.com).
> Version: 6.0.708 / Virus Database: 464 - Release Date: 18/06/2004
>  
> 
> ---
> Outgoing mail is certified Virus Free.
> Checked by AVG anti-virus system (http://www.grisoft.com).
> Version: 6.0.708 / Virus Database: 464 - Release Date: 18/06/2004
>  
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
> For additional commands, e-mail: batik-users-help@xml.apache.org
> 



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


---
Incoming mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.708 / Virus Database: 464 - Release Date: 18/06/2004
 

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.708 / Virus Database: 464 - Release Date: 18/06/2004
 


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


Re: Backend driven svg application

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

Frederik Santens wrote:

> When I put alert() instead of alert I get a 

   It just occurred to me that it should probably really be:

'alert("Hello World")'

   Can't imagine why that would cause infinite recursion, but
it might be the problem...

> 
> ava.lang.StackOverflowError
> 	at
> org.mozilla.javascript.ImporterTopLevel.has(ImporterTopLevel.java:101)
> 	at
> org.mozilla.javascript.ScriptableObject.getBase(ScriptableObject.java:15
> 83)
> 	at
> org.mozilla.javascript.ScriptableObject.hasProperty(ScriptableObject.jav
> a:1443)
> 	at
> org.mozilla.javascript.ScriptRuntime.bind(ScriptRuntime.java:1096)
> 	at
> org.mozilla.javascript.ScriptRuntime.getBase(ScriptRuntime.java:1106)
> 	at org.mozilla.javascript.gen.c1.call(Inline <script>
> file:/G:/HomeProjects/batik/intellij/multi.svg:73:4)
> 	at
> org.mozilla.javascript.ScriptRuntime.call(ScriptRuntime.java:1191)
> 	at org.mozilla.javascript.gen.c1.call(Inline <script>
> file:/G:/HomeProjects/batik/intellij/multi.svg:73:4)
> ...
> 
> Frederik
> 
> 
> -----Original Message-----
> From: Thomas DeWeese [mailto:Thomas.DeWeese@Kodak.com] 
> Sent: maandag 19 juli 2004 1:41
> To: Batik Users
> Subject: Re: Backend driven svg application
> 
> Frederik Santens wrote:
> 
> 
>>We have a notification engine that fire events when changes occur in
> 
> the 
> 
>>backend system. Based upon those events we would like to update the 
>>JSVGCanvas in correspondence with these backend data changes. The rate
> 
> 
>>at which those changes occur, is every 10 seconds, so, for performance
> 
> 
>>reasons, we are probably not able to rerender the svg each time (with
> 
> a 
> 
>>setDocument(…)). We also want to avoid the blinking and the loss of
> 
> the 
> 
>>zoom status that occurs when rerendering the svg in the JSVGCanvas.
>>
>>The ideal situation for us, would be to change the svg dynamically. I 
>>tried calling a script (defined in the svg) from within the java code 
>>but without success.
> 
> 
>     You should be aware that you can modify the SVG Document from
> Java directly (as long as you do it from within the UpdateManager
> Thread).  The most common mistake for systems like this is to fail
> to inform the canvas that the document should be treated as dynamic.
> This is done with:
> 
>     svgCanvas.setDocumentState(JSVGComponent.ALWAYS_DYNAMIC).
> 
> 
>>UpdateManager um = svgCanvas.getUpdateManager();
>>
>>Interpreter ip =
> 
> um.getBridgeContext().getInterpreter("text/ecmascript");
> 
>>ScriptRun sr = new ScriptRun("alert", ip);
> 
> 
>     This should probably be 'alert()'.
> 
> 
>>um.getUpdateRunnableQueue ( ).invokeLater(sr);
>>
>>What is going wrong? Or are there better approaches to tackle this
> 
> problem.
> 
>     Does anything happen when you do this (exception etc?).
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
> For additional commands, e-mail: batik-users-help@xml.apache.org
> 
> 
> ---
> Incoming mail is certified Virus Free.
> Checked by AVG anti-virus system (http://www.grisoft.com).
> Version: 6.0.708 / Virus Database: 464 - Release Date: 18/06/2004
>  
> 
> ---
> Outgoing mail is certified Virus Free.
> Checked by AVG anti-virus system (http://www.grisoft.com).
> Version: 6.0.708 / Virus Database: 464 - Release Date: 18/06/2004
>  
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
> For additional commands, e-mail: batik-users-help@xml.apache.org
> 



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


Re: Backend driven svg application

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

    Getting somewhere, but the included stack trace
doesn't give me enough to know why you are getting
a circular reference (which is almost always the
reason you get a stack overflow).  Can you
include at least one complete cycle of stack frames?

    Also I am curious what is at line 76-77 in your SVG?
Since that line seems to be showing up in the stack trace
(which I wouldn't ordinarily expect).

Frederik Santens wrote:

> When I put alert() instead of alert I get a 
> 
> ava.lang.StackOverflowError
> 	at
> org.mozilla.javascript.ImporterTopLevel.has(ImporterTopLevel.java:101)
> 	at
> org.mozilla.javascript.ScriptableObject.getBase(ScriptableObject.java:15
> 83)
> 	at
> org.mozilla.javascript.ScriptableObject.hasProperty(ScriptableObject.jav
> a:1443)
> 	at
> org.mozilla.javascript.ScriptRuntime.bind(ScriptRuntime.java:1096)
> 	at
> org.mozilla.javascript.ScriptRuntime.getBase(ScriptRuntime.java:1106)
> 	at org.mozilla.javascript.gen.c1.call(Inline <script>
> file:/G:/HomeProjects/batik/intellij/multi.svg:73:4)
> 	at
> org.mozilla.javascript.ScriptRuntime.call(ScriptRuntime.java:1191)
> 	at org.mozilla.javascript.gen.c1.call(Inline <script>
> file:/G:/HomeProjects/batik/intellij/multi.svg:73:4)
> ...
> 
> Frederik
> 
> 
> -----Original Message-----
> From: Thomas DeWeese [mailto:Thomas.DeWeese@Kodak.com] 
> Sent: maandag 19 juli 2004 1:41
> To: Batik Users
> Subject: Re: Backend driven svg application
> 
> Frederik Santens wrote:
> 
> 
>>We have a notification engine that fire events when changes occur in
> 
> the 
> 
>>backend system. Based upon those events we would like to update the 
>>JSVGCanvas in correspondence with these backend data changes. The rate
> 
> 
>>at which those changes occur, is every 10 seconds, so, for performance
> 
> 
>>reasons, we are probably not able to rerender the svg each time (with
> 
> a 
> 
>>setDocument(…)). We also want to avoid the blinking and the loss of
> 
> the 
> 
>>zoom status that occurs when rerendering the svg in the JSVGCanvas.
>>
>>The ideal situation for us, would be to change the svg dynamically. I 
>>tried calling a script (defined in the svg) from within the java code 
>>but without success.
> 
> 
>     You should be aware that you can modify the SVG Document from
> Java directly (as long as you do it from within the UpdateManager
> Thread).  The most common mistake for systems like this is to fail
> to inform the canvas that the document should be treated as dynamic.
> This is done with:
> 
>     svgCanvas.setDocumentState(JSVGComponent.ALWAYS_DYNAMIC).
> 
> 
>>UpdateManager um = svgCanvas.getUpdateManager();
>>
>>Interpreter ip =
> 
> um.getBridgeContext().getInterpreter("text/ecmascript");
> 
>>ScriptRun sr = new ScriptRun("alert", ip);
> 
> 
>     This should probably be 'alert()'.
> 
> 
>>um.getUpdateRunnableQueue ( ).invokeLater(sr);
>>
>>What is going wrong? Or are there better approaches to tackle this
> 
> problem.
> 
>     Does anything happen when you do this (exception etc?).
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
> For additional commands, e-mail: batik-users-help@xml.apache.org
> 
> 
> ---
> Incoming mail is certified Virus Free.
> Checked by AVG anti-virus system (http://www.grisoft.com).
> Version: 6.0.708 / Virus Database: 464 - Release Date: 18/06/2004
>  
> 
> ---
> Outgoing mail is certified Virus Free.
> Checked by AVG anti-virus system (http://www.grisoft.com).
> Version: 6.0.708 / Virus Database: 464 - Release Date: 18/06/2004
>  
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
> For additional commands, e-mail: batik-users-help@xml.apache.org
> 



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


RE: Backend driven svg application

Posted by Frederik Santens <fr...@pandora.be>.
When I put alert() instead of alert I get a 

ava.lang.StackOverflowError
	at
org.mozilla.javascript.ImporterTopLevel.has(ImporterTopLevel.java:101)
	at
org.mozilla.javascript.ScriptableObject.getBase(ScriptableObject.java:15
83)
	at
org.mozilla.javascript.ScriptableObject.hasProperty(ScriptableObject.jav
a:1443)
	at
org.mozilla.javascript.ScriptRuntime.bind(ScriptRuntime.java:1096)
	at
org.mozilla.javascript.ScriptRuntime.getBase(ScriptRuntime.java:1106)
	at org.mozilla.javascript.gen.c1.call(Inline <script>
file:/G:/HomeProjects/batik/intellij/multi.svg:73:4)
	at
org.mozilla.javascript.ScriptRuntime.call(ScriptRuntime.java:1191)
	at org.mozilla.javascript.gen.c1.call(Inline <script>
file:/G:/HomeProjects/batik/intellij/multi.svg:73:4)
...

Frederik


-----Original Message-----
From: Thomas DeWeese [mailto:Thomas.DeWeese@Kodak.com] 
Sent: maandag 19 juli 2004 1:41
To: Batik Users
Subject: Re: Backend driven svg application

Frederik Santens wrote:

> We have a notification engine that fire events when changes occur in
the 
> backend system. Based upon those events we would like to update the 
> JSVGCanvas in correspondence with these backend data changes. The rate

> at which those changes occur, is every 10 seconds, so, for performance

> reasons, we are probably not able to rerender the svg each time (with
a 
> setDocument(…)). We also want to avoid the blinking and the loss of
the 
> zoom status that occurs when rerendering the svg in the JSVGCanvas.
> 
> The ideal situation for us, would be to change the svg dynamically. I 
> tried calling a script (defined in the svg) from within the java code 
> but without success.

    You should be aware that you can modify the SVG Document from
Java directly (as long as you do it from within the UpdateManager
Thread).  The most common mistake for systems like this is to fail
to inform the canvas that the document should be treated as dynamic.
This is done with:

    svgCanvas.setDocumentState(JSVGComponent.ALWAYS_DYNAMIC).

> UpdateManager um = svgCanvas.getUpdateManager();
> 
> Interpreter ip =
um.getBridgeContext().getInterpreter("text/ecmascript");
> 
> ScriptRun sr = new ScriptRun("alert", ip);

    This should probably be 'alert()'.

> um.getUpdateRunnableQueue ( ).invokeLater(sr);
> 
> What is going wrong? Or are there better approaches to tackle this
problem.

    Does anything happen when you do this (exception etc?).



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


---
Incoming mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.708 / Virus Database: 464 - Release Date: 18/06/2004
 

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.708 / Virus Database: 464 - Release Date: 18/06/2004
 


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


RE: Backend driven svg application

Posted by Frederik Santens <fr...@pandora.be>.
Thx for the quick response!

I thought that the moment there is a script tag inside the svg that the
canvas automatically takes a dynamic state.

Anyway, I added svgCanvas.setDocumentState(JSVGComponent.ALWAYS_DYNAMIC)
but the result is the same.

When I run the code nothing happens and I don't get any exception. The
script does nothing more than showing a javascript alert.

Frederik

-----Original Message-----
From: Thomas DeWeese [mailto:Thomas.DeWeese@Kodak.com] 
Sent: maandag 19 juli 2004 1:41
To: Batik Users
Subject: Re: Backend driven svg application

Frederik Santens wrote:

> We have a notification engine that fire events when changes occur in
the 
> backend system. Based upon those events we would like to update the 
> JSVGCanvas in correspondence with these backend data changes. The rate

> at which those changes occur, is every 10 seconds, so, for performance

> reasons, we are probably not able to rerender the svg each time (with
a 
> setDocument(…)). We also want to avoid the blinking and the loss of
the 
> zoom status that occurs when rerendering the svg in the JSVGCanvas.
> 
> The ideal situation for us, would be to change the svg dynamically. I 
> tried calling a script (defined in the svg) from within the java code 
> but without success.

    You should be aware that you can modify the SVG Document from
Java directly (as long as you do it from within the UpdateManager
Thread).  The most common mistake for systems like this is to fail
to inform the canvas that the document should be treated as dynamic.
This is done with:

    svgCanvas.setDocumentState(JSVGComponent.ALWAYS_DYNAMIC).

> UpdateManager um = svgCanvas.getUpdateManager();
> 
> Interpreter ip =
um.getBridgeContext().getInterpreter("text/ecmascript");
> 
> ScriptRun sr = new ScriptRun("alert", ip);

    This should probably be 'alert()'.

> um.getUpdateRunnableQueue ( ).invokeLater(sr);
> 
> What is going wrong? Or are there better approaches to tackle this
problem.

    Does anything happen when you do this (exception etc?).



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


---
Incoming mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.708 / Virus Database: 464 - Release Date: 18/06/2004
 

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.708 / Virus Database: 464 - Release Date: 18/06/2004
 


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


Re: Backend driven svg application

Posted by Thomas DeWeese <Th...@Kodak.com>.
Frederik Santens wrote:

> We have a notification engine that fire events when changes occur in the 
> backend system. Based upon those events we would like to update the 
> JSVGCanvas in correspondence with these backend data changes. The rate 
> at which those changes occur, is every 10 seconds, so, for performance 
> reasons, we are probably not able to rerender the svg each time (with a 
> setDocument(…)). We also want to avoid the blinking and the loss of the 
> zoom status that occurs when rerendering the svg in the JSVGCanvas.
> 
> The ideal situation for us, would be to change the svg dynamically. I 
> tried calling a script (defined in the svg) from within the java code 
> but without success.

    You should be aware that you can modify the SVG Document from
Java directly (as long as you do it from within the UpdateManager
Thread).  The most common mistake for systems like this is to fail
to inform the canvas that the document should be treated as dynamic.
This is done with:

    svgCanvas.setDocumentState(JSVGComponent.ALWAYS_DYNAMIC).

> UpdateManager um = svgCanvas.getUpdateManager();
> 
> Interpreter ip = um.getBridgeContext().getInterpreter("text/ecmascript");
> 
> ScriptRun sr = new ScriptRun("alert", ip);

    This should probably be 'alert()'.

> um.getUpdateRunnableQueue ( ).invokeLater(sr);
> 
> What is going wrong? Or are there better approaches to tackle this problem.

    Does anything happen when you do this (exception etc?).



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