Take a look at the CSS DOM specification, in particular:
http://www.w3.org/TR/2000/REC-DOM-Level-2-Style-20001113/css.html#CSS-CSSStyleDeclaration-setProperty
setProperty takes three arguments not two. The third is priority, this is typically "important" (override everything) or "" (normal priority - which is used most commonly).
Doug Schepers wrote:
Hi-
I've been coding with an eye mostly toward ASV, so I'm fairly new to much of Batik (though I've used things like the font convertor for a while). Forgive me if I ask dumb or ASV-centric questions. I'm testing some of my code on Squiggle/Batik1.5, and I've runn into a few errors that I may have taken for granted in ASV.
I'm wondering why I can't use: myElement.style.setProperty('fill', 'blue')
I can set style as an attribute, but not as a style property (see sample [1]); it complains it can't find the setProperty method (see output [2]).
Is this the wrong way to do it? Or is this method simply not supported in Batik?
Thanks- -Doug
[1] <?xml version='1.0' standalone='no'?> <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"> <svg width='100%' height='100%' xmlns='http://www.w3.org/2000/svg'>
<script type='text/ecmascript'><![CDATA[ function SetFillStyle(evt) { //assign value to property evt.target.style.setProperty('fill', 'blue'); }
function SetFillAttribute(evt) { //assign value to attribute evt.target.setAttributeNS(null, 'fill', 'blue'); }
]]></script>
<circle cx='25' cy='25' r='20' style='fill:orange; ' onclick='SetFillStyle(evt)'/> <circle cx='125' cy='25' r='20' fill='orange' onclick='SetFillAttribute(evt)'/>
</svg>
[2] org.mozilla.javascript.EvaluatorException: Can't find method org.apache.batik.css.dom.CSSOMStyleDeclaration.setProperty(string,string). (Inline Script; line 5)
at org.mozilla.javascript.DefaultErrorReporter.runtimeError(DefaultErrorReporte r.java:76) at org.mozilla.javascript.Context.reportRuntimeError(Context.java:591) at org.mozilla.javascript.Context.reportRuntimeError(Context.java:630) at org.mozilla.javascript.Context.reportRuntimeError1(Context.java:606) at org.mozilla.javascript.NativeJavaMethod.call(NativeJavaMethod.java:198) at org.mozilla.javascript.ScriptRuntime.call(ScriptRuntime.java:1191) at org.mozilla.javascript.gen.c1.call(Inline Script:5) at org.mozilla.javascript.optimizer.OptRuntime.callSimple(OptRuntime.java:275) at org.mozilla.javascript.gen.c6.call(<SVG>:1) at org.mozilla.javascript.gen.c6.exec(<SVG>) at org.apache.batik.script.rhino.RhinoInterpreter.evaluate(Unknown Source) at org.apache.batik.bridge.ScriptingEnvironment.runEventHandler(Unknown Source) at org.apache.batik.bridge.ScriptingEnvironment$ScriptingEventListener.handleEv ent(Unknown Source) at org.apache.batik.dom.events.EventSupport.fireEventListeners(Unknown Source) at org.apache.batik.dom.events.EventSupport.dispatchEvent(Unknown Source) at org.apache.batik.dom.AbstractNode.dispatchEvent(Unknown Source) at org.apache.batik.bridge.BridgeEventSupport$Listener.dispatchMouseEvent(Unkno wn Source) at org.apache.batik.bridge.BridgeEventSupport$Listener.dispatchMouseEvent(Unkno wn Source) at org.apache.batik.bridge.BridgeEventSupport$Listener.mouseClicked(Unknown Source) at org.apache.batik.gvt.event.AWTEventDispatcher.processMouseEvent(Unknown Source) at org.apache.batik.gvt.event.AWTEventDispatcher.dispatchMouseEvent(Unknown Source) at org.apache.batik.gvt.event.AWTEventDispatcher.dispatchEvent(Unknown Source) at org.apache.batik.gvt.event.AWTEventDispatcher.mouseClicked(Unknown Source) at org.apache.batik.swing.svg.JSVGComponent$22.run(Unknown Source) at org.apache.batik.util.RunnableQueue.run(Unknown Source) at java.lang.Thread.run(Unknown Source)
--------------------------------------------------------------------- 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]