xmlgraphics-batik-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Frederik Santens" <frederik.sant...@pandora.be>
Subject RE: Backend driven svg application
Date Mon, 19 Jul 2004 20:17:04 GMT
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


Mime
View raw message