more info www.naraicoms.com
From: Thomas DeWeese <[EMAIL PROTECTED]> Reply-To: "Batik Users" <[EMAIL PROTECTED]> To: Batik Users <[EMAIL PROTECTED]> Subject: Re: Not able to run scripts in Batik Date: Thu, 22 Jan 2004 08:34:36 -0500
Gurleen Randhawa wrote:
I tried the sample script provided on the Batik web site , but I got the following error
We do not eval script elements when they are added to the document (the logic here is a little fuzzy but goes something like - what would we do if you 'removed' one - best to say they aren't 'dynamic' entities).
You can eval script from Java fairly easily (psudo code): try { String myScript = ...; Interpreter i=bridgeContext.getInterpreter("text/ecmascript"); i.evaluate(myScript); } catch (InterpreterException ie) { ... }
You can get the BridgeContext from the JSVGCanvas. Of course you need to make sure you do this from the UpdateManager thread.
SVG Error : 'showDialog' not defined
This is the code that I wrote
// Root Element
SVGSVGElement currentRoot = currentSVGDoc.getRootElement()
// create the script
Element elem = currentSVGDoc.createElementNS(null, "script");
elem.setAttributeNS(null, "type","text/ecmascript");
Text text = new GenericText("function showDialog(msg) {alert(msg);} " , (AbstractDocument)svgComp.getSVGDocument());
elem.appendChild(text);
currentRoot.appendChild(elem); // create the circle element
Element circle = currentSVGDoc.createElementNS(SVGConstants.SVG_NAMESPACE_URI, "circle");
circle.setAttributeNS(null, "cx", "137.5");
circle.setAttributeNS(null, "r", "20");
circle.setAttributeNS(null, "cy", "110");
circle.setAttributeNS(null, "style", "fill:crimson");
circle.setAttributeNS(null, "onmouseover","showDialog('onmousemove')");
currentRoot.appendChild(circle);
The sample script that I used is shown here
http://xml.apache.org/batik/scripting.html#howToUseScripting Thanks
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
_________________________________________________________________
Add photos to your messages with MSN 8. Get 2 months FREE*. http://join.msn.com/?page=features/featuredemail
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
