I have found this for example, but this things does not work for me. My code: (actually, I need to catch endEvent event, but even DOMActivate does not work)
My svg file:Code:InputStream svgDemoStream = getClass().getResourceAsStream("/res/egg.svg"); SVGImage svgImage = (SVGImage) SVGImage.createImage(svgDemoStream, null); svgCanvas = svgImage; svgCanvas.setViewportHeight(getHeight()); svgCanvas.setViewportWidth(getWidth()); Document doc = svgImage.getDocument(); SVGSVGElement svg = (SVGSVGElement) doc.getDocumentElement(); SVGElement anim = (SVGElement) doc.getElementById("anim_transform"); SVGAnimator svgAnimator = SVGAnimator.createAnimator(svgCanvas); svgAnimator.play(); anim.addEventListener("DOMActivate", new EventListener() { public void handleEvent(Event evt) { System.out.println("ANIMATION ENDED 111"); } }, false); SVGElement image = (SVGElement) doc.getElementById("image"); image.addEventListener("DOMActivate", new EventListener() { public void handleEvent(Event evt) { System.out.println("ANIMATION ENDED 111"); } }, false); svg.addEventListener("DOMActivate", new EventListener() { public void handleEvent(Event evt) { System.out.println("ANIMATION ENDED 222"); } }, false);
Code:<?xml version="1.0" encoding="UTF-8" standalone="no"?> <!-- Created with Inkscape (http://www.inkscape.org/) --> <svg xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:cc="http://creativecommons.org/ns#" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:svg="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" id="svg3339" version="1.1" inkscape:version="0.48.4 r9939" sodipodi:docname="egg3.png"> <metadata id="metadata3345"> <rdf:RDF> <cc:Work rdf:about=""> <dc:format>image/svg+xml</dc:format> <dc:type rdf:resource="http://purl.org/dc/dcmitype/StillImage" /> <dc:title></dc:title> </cc:Work> </rdf:RDF> </metadata> <defs id="defs3343" /> <sodipodi:namedview pagecolor="#ffffff" bordercolor="#666666" borderopacity="1" objecttolerance="10" gridtolerance="10" guidetolerance="10" inkscape:pageopacity="0" inkscape:pageshadow="2" inkscape:window-width="640" inkscape:window-height="480" id="namedview3341" showgrid="false" inkscape:zoom="1" inkscape:cx="26" inkscape:cy="34.5" inkscape:window-x="483" inkscape:window-y="229" inkscape:window-maximized="0" inkscape:current-layer="svg3339" /> <image width="52" height="68" xlink:href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADQAAABFCAYAAAAFBsWPAAAABHNCSVQICAgIfAhkiAAAEHRJREFU......AABJRU5ErkJggg== " id="image" x="0" y="0" > <animateTransform id="anim_transform" attributeName="transform" begin="0s" dur="2s" type="rotate" from="0 26 34" to="360 26 34" repeatCount="2" /> <animateMotion from="0,0" to="100,100" dur="4s" fill="freeze"/> </image> </svg>

Reply With Quote

