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 massimo citterio <ci...@sinapto.net> on 2008/06/17 18:20:48 UTC

smil animation broken after first run

Hi all
I am adding animation to a <g> element
everything is ok the first time I add & start it, then I stop the anim
and remove the <g> element.
The second time I try it, animation doesn't start.
How can I debug it?

I tried to save the svg when the second animation is created, and
squiggle plays it properly.


can you spot any error here?

//creating animation
        Element elt = getDocument().getElementById(tickerId);
        Element anim = getDocument().createElementNS(svgNS, "animate");
        anim.setAttributeNS(null, "id", animId);
        anim.setAttributeNS(null, "dur", String.valueOf(dur));
        //anim.setAttributeNS(null, "dur", "15");
        anim.setAttributeNS(null, "values", "0;26;51;76;102");
        anim.setAttributeNS(null, "begin", "indefinite");
        anim.setAttributeNS(null, "calcMode", "discrete");
        anim.setAttributeNS(null, "fill", "freeze");
        anim.setAttributeNS(null, "attributeName", "width");
        anim.setAttributeNS(null, "attributeType", "XML");
        //adding anim to ticker
        elt.appendChild(anim);


.....

//starting animation, sometimes ok, sometimes not
 Element elt = getDocument().getElementById(animId);
        if (elt != null) {
            boolean res = ((SVGAnimationElement) elt).beginElement();
            logger.info(animId + " res: " + res);
		//nb: res is always true!
        }




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


Re: smil animation broken after first run

Posted by massimo citterio <ci...@sinapto.net>.
further investigations make me think that is not possible to remove an
animation, or the parent of the animation.
eg: if an animation moves a rect, neither the rect nor the animation can
be removed

If I try to do this, I have those tick error.
A workaround I've found is never remove an animation, or the parent, and
always reuse them, and hide the parent when it's not needed.

Did anyone succeed in adding and removing animation?
Is this weird thing happening to me only?

I am trying to create a small application that can reproduce the
problem, as soon as it's done, I will post it

Massimo


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


Re: smil animation broken after first run

Posted by massimo citterio <ci...@sinapto.net>.
> > 
> > INFO: SVGException: java.lang.NullPointerException
> > java.lang.NullPointerException
> >         at
> > org.apache.batik.anim.AnimationEngine.tick(AnimationEngine.java:389)
> 
> 
> the line 389 of org.apache.batik.anim.AnimationEngine is:
> 
> if (sandwich.shouldUpdate || sandwich.animation.isDirty) 

which is the proper way to stop and remove an animation?

 Element elt = getElementById(id);
      if(elt!=null){
            boolean res = ((SVGAnimationElement) elt).endElement();
	}


and then 

document.getElementById(id).getParentNode().removeChild(elt);

is this ok?




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


Re: smil animation broken after first run

Posted by massimo citterio <ci...@sinapto.net>.
On Thu, 2008-06-19 at 10:11 +0200, massimo citterio wrote:
> I've enabled exception printstacktrace, and I've found that when this
> exception occurs, it stops the smil animation execution from that time
> on.
> 
> I am starting animations with 
> 
>         Element elt = getDocument().getElementById(animId);
>         boolean res = ((SVGAnimationElement) elt).beginElement();
> 
> is there a way to catch the exception and continue/reset animation?
> 
> 
> 
> INFO: SVGException: java.lang.NullPointerException
> java.lang.NullPointerException
>         at
> org.apache.batik.anim.AnimationEngine.tick(AnimationEngine.java:389)


the line 389 of org.apache.batik.anim.AnimationEngine is:

if (sandwich.shouldUpdate || sandwich.animation.isDirty) 

and debugging it seems that sometimes sandwich.animation is null
it looks like the animation (or the parent) was added & started, then
deleted.
It is my fault, but since it's not easy to solve, is there a way to play
next animations?





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


Re: smil animation broken after first run

Posted by massimo citterio <ci...@sinapto.net>.
I've enabled exception printstacktrace, and I've found that when this
exception occurs, it stops the smil animation execution from that time
on.

I am starting animations with 

        Element elt = getDocument().getElementById(animId);
        boolean res = ((SVGAnimationElement) elt).beginElement();

is there a way to catch the exception and continue/reset animation?



INFO: SVGException: java.lang.NullPointerException
java.lang.NullPointerException
        at
org.apache.batik.anim.AnimationEngine.tick(AnimationEngine.java:389)
        at org.apache.batik.bridge.SVGAnimationEngine.access
$601(SVGAnimationEngine.java:99)
        at org.apache.batik.bridge.SVGAnimationEngine
$AnimationTickRunnable.run(SVGAnimationEngine.java:859)
        at
org.apache.batik.util.RunnableQueue.run(RunnableQueue.java:237)
        at java.lang.Thread.run(Thread.java:619)




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