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 Reinhard Brandstädter <r....@gmx.at> on 2003/06/12 15:34:56 UTC
getting Update Manager for JSVGCanvas...
Jan suggested updating a SVGDocument displayed in a JSVGCanvas via the
UpdateManager, but now I'm struggling with getting the UpdateManager for
my canvas.
I'm new to Batik and just playing around a little bit, but the Javadoc
isn't very helpful...
How do I create a UpdateManager so that I can use it in the way
described by Jan below?
I tried something (useless as the UpdateManager returned is null) like this:
This test should only "move" the rectangle "myrect" accross the canvas (?)
------
svgCanvas.setSVGDocument(svgDoc);
svgCanvas.getUpdateManager(). \\
getUpdateRunnableQueue().invokeLater(new Runnable() {
public void run() {
int x=0, y=0;
for (;;) {
x = (x+1)%400;
y = (y+1)%400;
Element e = svgDoc.getElementById("myrect");
e.setAttribute("x",(new Integer(x)).toString());
e.setAttribute("y",(new Integer(y)).toString());
}
}
}
);
------
thx,
Reinhard
Lolling, Jan wrote:
> OK now it is clear.
>
> BATIK is the right think to solve your task.
>
> Than all comments from Vincent are correct and the best way to create and remove elements is manipulating the DOM in the update manager.
>
> You can retrieve this from JSVGCanvas methode
> getUpdateManager().getUpdateRunnableQueue().invokeLater(yourDOMUpdateRunnable);
>
> here is an code snippet---------------
>
> canvas.getUpdateManager().getUpdateRunnableQueue().invokeLater(new Runnable() {
> public void run() {
> Element rectangle = document.createElementNS(svgNS, "rect");
> rectangle.setAttributeNS(null, "x", String.valueOf(x));
> rectangle.setAttributeNS(null, "y", String.valueOf(y));
> rectangle.setAttributeNS(null, "width", String.valueOf(ddx));
> rectangle.setAttributeNS(null, "height", String.valueOf(ddy));
> rectangle.setAttributeNS(null, "style", "fill:white; stroke:black");
> svgRoot.appendChild(rectangle);
> } //run
> });
>
> ---------------------------------
--
Reinhard Brandstaedter r.brandstaedter@gmx.at GPG: 0x033B81DB
- Student of Computer Science - J.K. University of Linz -
- <ICQ: 73059068> <Mobile: +43 699 12419541> -
- http://adelaide.dnsalias.net -
---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
For additional commands, e-mail: batik-users-help@xml.apache.org