Hi,

I'm a step further using the SVGAnimationEngine, but the resulting Image is empty because nothing is drawn :-(.
With Squiggle the SVG animation is correctly displayed.

This is the code I'm using:

       String parser = XMLResourceDescriptor.getXMLParserClassName();
       SAXSVGDocumentFactory f = new SAXSVGDocumentFactory(parser);
SVGDocument doc = f.createSVGDocument(findFile(pFilename).toString());
       UserAgentAdapter userAgent = new UserAgentAdapter();
       BridgeContext ctx = new BridgeContext(userAgent);
//parse document
       GVTBuilder builder = new GVTBuilder();
       GraphicsNode gvtRoot = null ;
       try {
           ctx.setDynamicState(BridgeContext.DYNAMIC);
           gvtRoot = builder.build(ctx, doc);
       }
       catch (BridgeException e) {
           new IOException("Error loading svg image", e);
       }
//create animation engine
       ctx.setAnimationLimitingNone();
       SVGAnimationEngine animationEngine = ctx.getAnimationEngine();
//draw image
       if(!mAnimationEngine.hasStarted()) {
           mAnimationEngine.start(System.currentTimeMillis());
       } else {
           mAnimationEngine.setCurrentTime(System.currentTimeMillis());
       }
       gvtRoot.paint(pGraphics);


Regards,
Oliver


Oliver Mihatsch schrieb:
Hi,

for a small java game I would like to pre-render SVG Animations into BufferedImages. Rendering should run in the same thread, without using classes which starts an own thread like the UpdateManager.

How can I apply the animation manually on the tree?

This is the code I'm using at the moment:

       //load image
       String parser = XMLResourceDescriptor.getXMLParserClassName();
       SAXSVGDocumentFactory f = new SAXSVGDocumentFactory(parser);
Document doc = f.createDocument(findFile(pFilename).toString());
       UserAgentAdapter userAgent = new UserAgentAdapter();
       BridgeContext ctx = new BridgeContext(userAgent);
       GVTBuilder builder = new GVTBuilder();

       GraphicsNode gvtRoot = null ;
       try {
           ctx.setDynamicState(BridgeContext.DYNAMIC);
           gvtRoot = builder.build(ctx, doc);
       }
       catch (BridgeException e) {
           new IOException("Error loading svg image", e);
       }

       //draw static image
       Graphics2D graphics = (Graphics2D) pGraphics.create();
       graphics.transform(mTransformation);
       gvtRoot.paint(graphics);


Thanks in advance,
Oliver



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]




---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to