Hi Jonathan, Oh sorry, I didn't catched that, you're right.
Which version of batik do you use? 1.7 or some newer svn build? Regards, Fabian > Hi Fabian, > > Note that although the Elements in the example are created at the beginning of the example, the listener code block runs after the document is loaded (after theGVTTreeBuilderEvent is fired). > > > On Mon, Mar 15, 2010 at 5:45 AM, Fabian Unfried <i...@funfried.de<mailto:i...@funfried.de>> wrote: > Hi Jonathan, > > first of all thanks for your reply, but if you create the elements (rect and > animate) and then create the document and load it, it should be the same if > you already drawn the elements in a svg file and open it. > > Maybe I didn't mention that exactly, my problem is that I have already opened > a svg file in my application and then would like to add an animation, but if > I do this like in your example, it won't be animated. > > > Kind Regards, > > > Fabian > > > Hi Fabian, > > > > It is usually a case of getting the correct attributes. Batik tends to > follow the standard a bit more closely that some other implementations. The > following code works for me...posted sans the JFrame init...assumes a class > member JSVGCanvas named svgCanvas. > > > > private void runDemo() { > > svgCanvas.setDocumentState(JSVGCanvas.ALWAYS_DYNAMIC); > > svgCanvas.addGVTTreeBuilderListener(new GVTTreeBuilderAdapter() { > > @Override > > public void gvtBuildCompleted(GVTTreeBuilderEvent e) { > > > svgCanvas.getUpdateManager().getUpdateRunnableQueue().invokeLater(new > Runnable() { > > public void run() { > > Element rect = > svgCanvas.getSVGDocument().createElementNS(SVGDOMImplementation.SVG_NAMESPACE_URI, > SVGConstants.SVG_RECT_TAG); > > rect.setAttributeNS(null, > SVGConstants.SVG_X_ATTRIBUTE, "100"); > > rect.setAttributeNS(null, > SVGConstants.SVG_Y_ATTRIBUTE, "100"); > > rect.setAttributeNS(null, > SVGConstants.SVG_WIDTH_ATTRIBUTE, "100"); > > rect.setAttributeNS(null, > SVGConstants.SVG_HEIGHT_ATTRIBUTE, "100"); > > rect.setAttributeNS(null, > SVGConstants.SVG_FILL_ATTRIBUTE, "#2222ee"); > > Element animate = > svgCanvas.getSVGDocument().createElementNS(SVGDOMImplementation.SVG_NAMESPACE_URI, > SVGConstants.SVG_ANIMATE_TAG); > > animate.setAttributeNS(null, > SVGConstants.SVG_ATTRIBUTE_NAME_ATTRIBUTE, > SVGConstants.SVG_OPACITY_ATTRIBUTE); > > animate.setAttributeNS(null, > SVGConstants.SVG_VALUES_ATTRIBUTE, "1;0"); > > animate.setAttributeNS(null, > SVGConstants.SVG_DUR_ATTRIBUTE, "3s"); > > animate.setAttributeNS(null, > SVGConstants.SVG_REPEAT_COUNT_ATTRIBUTE, "indefinite"); > > rect.appendChild(animate); > > > svgCanvas.getSVGDocument().getDocumentElement().appendChild(rect); > > } > > }); > > } > > }); > > Document doc = > SVGDOMImplementation.getDOMImplementation().createDocument(SVGDOMImplementation.SVG_NAMESPACE_URI, "svg", > null); > > svgCanvas.setSVGDocument((SVGDocument) doc); > > } > > > > > > > > > > > > On Fri, Mar 12, 2010 at 8:35 AM, Fabian Unfried > <i...@funfried.de<mailto:i...@funfried.de><mailto:i...@funfried.de<mailto:i...@funfried.de>>> wrote: > > Hi, > > > > I would like to know how to handle animations with batik, especially the > > animate tag. > > > > If I put the following svg code into an svg graphic and open it with a java > > application with batik all works just fine and it'll be animated: > > > > <rect x="100" y="100" width="500" height="500"> > > <animate attributeType="CSS" attributeName="opacity" > calcMode="discrete" > > from="1" to="0" dur="1s" repeatCount="indefinite" /> > > </rect> > > > > > > But what do I have to do, if I want to do exactly this during runtime? > > > > I've tried this: > > > > > > SVGOMAnimationElement animate = (SVGOMAnimationElement) > > this.svgDocument.createElementNS(SVGDOMImplementation.SVG_NAMESPACE_URI, > > SVG12Constants.SVG_ANIMATE_TAG); > > animate.setAttribute("dur", "1s"); > > animate.setAttribute("values", "0; 0; 1; 1"); > > animate.setAttribute("keyTimes", "0; 0.5; 0.7; 1.0"); > > animate.setAttribute("attributeName", "opacity"); > > animate.setAttribute("attributeType", "CSS"); > > animate.setAttribute("repeatCount", "indefinite"); > > > > rect.appendChild(animate); > > > > animate.beginElement(); > > > > > > but this didn't get animated, so I've tried to use the SVGAnimationEngine, > but > > I'm not sure how to use the addAnimation() method, or even if I need to do > > that: > > > > SVGAnimationEngine aEngine = getSVGAnimationEngine(); > > aEngine.addAnimation((AnimationTarget) rect, > > SVGAnimationEngine.ANIM_TYPE_CSS, "?", "?", AbstractAnimation???); > > > > How can I setup an AbstractAnimation? > > > > > > > > Any help is very appreciated > > > > Thanks in advance. > > > > Kind regards, > > > > Fabian > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: > batik-users-unsubscr...@xmlgraphics.apache.org<mailto:batik-users-unsubscr...@xmlgraphics.apache.org><mailto:batik-users-unsubscr...@xmlgraphics.apache.org<mailto:batik-users-unsubscr...@xmlgraphics.apache.org>> > > For additional commands, e-mail: > batik-users-h...@xmlgraphics.apache.org<mailto:batik-users-h...@xmlgraphics.apache.org><mailto:batik-users-h...@xmlgraphics.apache.org<mailto:batik-users-h...@xmlgraphics.apache.org>> > > > > > > > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: batik-users-unsubscr...@xmlgraphics.apache.org<mailto:batik-users-unsubscr...@xmlgraphics.apache.org> > For additional commands, e-mail: batik-users-h...@xmlgraphics.apache.org<mailto:batik-users-h...@xmlgraphics.apache.org> > > > -- Fabian Unfried Software Engineer Zebra Enterprise Solutions Rossfelder Str. 65/5, 74564 Crailsheim, Germany T+49 7951 9636xx F+49 7951 963611 funfr...@zebra.com www.zebra.com/zes Navis * WhereNet * proveo * Multispectral Solutions Managing Directors Zebra Enterprise Solutions GmbH: William Walsh, Michael Smiley Registered Office: Ulm, HRB 721672 VAT Number: DE225496806 - CONFIDENTIAL- This email and any files transmitted with it are confidential, and may also be legally privileged. If you are not the intended recipient, you may not review, use, copy, or distribute this message. If you receive this email in error, please notify the sender immediately by reply email and then delete this email. --------------------------------------------------------------------- To unsubscribe, e-mail: batik-users-unsubscr...@xmlgraphics.apache.org For additional commands, e-mail: batik-users-h...@xmlgraphics.apache.org