xmlgraphics-batik-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "HODAC, Olivier" <OLIVIER.HO...@airbus.com>
Subject RE: animate an element
Date Tue, 12 Jan 2010 13:06:12 GMT
Hello,

 

Are you talking about this?

((SVGOMAnimationElement)anim).beginElement();

 

In this case, what's the best practice? It has to be called within a runnable of the runnableQueue
of the canvas? Is that the right cast?

 

 

 

De : thomas.deweese@kodak.com [mailto:thomas.deweese@kodak.com] 
Envoyé : mardi 12 janvier 2010 12:29
À : batik-users@xmlgraphics.apache.org
Cc : batik-users@xmlgraphics.apache.org
Objet : Re: animate an element

 

Hi Dao, 

dao <dao.hodac@gmail.com> wrote on 01/12/2010 06:06:53 AM:

> you mean that I have to set all the attributes in the same runnable?
> of the updaterunnablequeue?

   If you don't set all the attributes in the same runnable then 
Batik is free to trigger a rendering between them.  This is very 
likely to cause odd behavior. 

   Additionally, there is non-trivial overhead associated with 
running a runnable, so having a runnable set just one attribute 
will add significant overhead.  I'd suggest simply adding a 'submit' 
method to your SvgRepainEngine that submits one Runnable with the list 
of 'Task' objects you have pushed since the last call to 'submit'. 

> On Tue, Jan 12, 2010 at 11:56 AM, <thomas.deweese@kodak.com> wrote: 
> Hi Dao, 
> 
> dao <dao.hodac@gmail.com> wrote on 01/11/2010 06:22:58 PM:
> 
> > Actually, I created the anim elements with the namespace 
> > "http://www.w3.org/2000/svg <http://www.w3.org/2000/svg> ".  
> > It is in fact null... how can I know which element belongs to 
> which namespace? 

>    Attributes that don't have a prefix (i.e. xlink:) should 
> be in the null namespace.  Attributes that have a prefix should be 
> in the namespace associated with that prefix.  In SVG this means that 
> essentially only the xlink attributes need namespaces. 
> 
> > But when I do this 
> > public void setVisible(final Element elt, boolean b) { 
> > final Element mask = elt2mask.get(elt); 
> > if (mask == null) 
> > return; 
> > Element anim = (Element) mask.getElementsByTagNameNS(null, 
> "animate").item(0); 
> > String animId = anim.getAttribute("id"); 
> > if (b) { 
> > SvgRepaintEngine.getInstance().push(new AttributeUpdateTask
> (mask.getAttribute(
> > "id"),"opacity", "1")); 
> > SvgRepaintEngine.getInstance().push(new AttributeUpdateTask(animId, "from", 
> > "0")); 
> > SvgRepaintEngine.getInstance().push(new AttributeUpdateTask
> (animId, "to", "1"
> > )); 
> > } else { 
> > SvgRepaintEngine.getInstance().push(new AttributeUpdateTask
> (mask.getAttribute(
> > "id"),"opacity", "0")); 
> > SvgRepaintEngine.getInstance().push(new AttributeUpdateTask(animId, "from", 
> > "1")); 
> > SvgRepaintEngine.getInstance().push(new AttributeUpdateTask
> (animId, "to", "0"
> > )); 
> > } 
> > 
> > the animation does not perform, and the opacity changes immediately 
> > (I tried to remove the first change) 

>    I think this is because you haven't started the animation, probably by 
> calling 'beginElement()' in your case. 
> 
> > Note that the SvgRepaintEngine only calls the invokeLater of the 
> > update manager to make a setAttribute 

>    You _really_ should have a way to bundle those changes together, 
> you could get strange results if a repaint started in between some 
> of those set attribute calls. 
>   
> > On Sat, Jan 9, 2010 at 2:58 PM, <thomas.deweese@kodak.com> wrote: 
> > Hi Dao, 
> > 
> > dao <dao.hodac@gmail.com> wrote on 01/06/2010 09:17:33 AM: 
> > 
> > 
> > > hello, I am running into a problem while attempting to animate an object.
> > > 
> > > I create an animation object using batik and I add this to my 
> > > ALWAYS_DYNAMIC canvas. The dump of the XML is like that after the append:
> > 
> >     What do you get if you call: 
> >         String an = animateElem.getAttributeNS(null, "attributeName"); 
> > 
> >     I see that in your 'dump' it looks OK, but the dump can easly not 
> > represent the details of the DOM in memory. 
> > 
> >     Can you post the code you use to create the animate element? 
> > 
> > > I get this exception. What's wrong with me?
> > 
> > > org.apache.batik.bridge.BridgeException: file:/C:/Users/to81028/
> > > runtime-EclipseApplication/aet/image/toto.svg:0
> > > The attribute "" of the element <g> is not animatable
> > >     at 
> 
> >    This means that in the animation bridge the getAttributeNS call 
> > above is returning either null or "" (not entirely sure which). 
> > Are you perhaps appending the element before setting all of it's 
> > attributes? 
> > 
> > > org.apache.batik.bridge.SVGAnimationElementBridge.initializeAnimation
> > > (SVGAnimationElementBridge.java:213)
> > >     at 
> > > org.apache.batik.bridge.SVGAnimationElementBridge.handleElement
> > > (SVGAnimationElementBridge.java:154)
> > >     at org.apache.batik.bridge.GVTBuilder.buildGraphicsNode
> > > (GVTBuilder.java:198)
> > >     at org.apache.batik.bridge.GVTBuilder.buildComposite
> > (GVTBuilder.java:171)
> > >     at org.apache.batik.bridge.GVTBuilder.buildGraphicsNode
> > > (GVTBuilder.java:219)
> > > ... 
> > > 
> > > -- 
> > > Dao Hodac 
> > 
> > 
> > 
> > -- 
> > Dao Hodac 
> 
> 
> 
> -- 
> Dao Hodac

This mail has originated outside your organization, either from an external partner or the
Global Internet.
Keep this in mind if you answer this message.
 

The information in this e-mail is confidential. The contents may not be disclosed or used
by anyone other than the addressee. Access to this e-mail by anyone else is unauthorised.
If you are not the intended recipient, please notify Airbus immediately and delete this e-mail.
Airbus cannot accept any responsibility for the accuracy or completeness of this e-mail as
it has been sent over public networks. If you have any concerns over the content of this message
or its Accuracy or Integrity, please contact Airbus immediately.
All outgoing e-mails from Airbus are checked using regularly updated virus scanning software
but you should take whatever measures you deem to be appropriate to ensure that this message
and any attachments are virus free.


Mime
View raw message