Hi,

I've been having this error for some time now and hoped the new Batik beta 
1.7 would have cleared it up, but no such luck.

I have some code which manages an SVG document by manipulating visibility 
and display attributes, as well as stroke and fill attributes.

Below I've attached a stack trace. My little piece of code that 
precipitates this traceback is:
        elm.setAttributeNS( null, "visibility", "hidden" );
or
        elm.removeAttributeNS( null, "visibility" );
In this case, the variable 'elm' is the object identified by id="elm621".

What is strange is that this works on most of the document. However, there 
are a few <g> elements in the document that it does not work on. Here is 
an example of an element on the visibility attribute is being changed 
where it fails:

<g transform="translate(294, 58)" id="elm621" rgr:dlevel="8" 
visibility="hidden">
        <g id="status" transform="translate(0, 0) scale(0.796875)">
                <use xlink:href="SYMLIB.SVG#symbol780" stroke="#72ea64" 
fill="#72ea64" display="inherit"/>
                <use xlink:href="SYMLIB.SVG#symbol779" stroke="#ff0000" 
fill="#ff0000" display="none"/>
        </g>
        <g id="appended">
                <use display="none" xlink:href="SYMLIB.SVG#symbol1364" 
transform="translate(18, -2) scale(0.301850)">
                </use>
                <use display="none" xlink:href="SYMLIB.SVG#symbol1364" 
transform="translate(24, -2) scale(0.301850)">
                </use>
                <use display="none" xlink:href="SYMLIB.SVG#symbol2512" 
transform="translate(30, -2) scale(0.301850)">
                </use>
        </g>
        <rgr:ranger type="discrete" pos="+" neg="-" 
presentation="symbolic" substation="STILWELL" point="R1621 79CO SW" 
appPos="3">
        </rgr:ranger>
</g>

When the code attempts to remove the visibility attribute on the above <g 
id="elm621"> element, the stacktrace occurs. However, the following (and 
this literally follows the above element in the SVG file) causes no error, 
and behaves as expected, i.e. the item becomes visible:
 
<g transform="translate(191, -58)" id="elm620" rgr:dlevel="4294967280" 
visibility="hidden">
        <g id="status" transform="translate(0, 0) scale(0.796875)">
                <use xlink:href="SYMLIB.SVG#symbol513" stroke="#72ea64" 
fill="#72ea64" display="inherit"/>
                <use xlink:href="SYMLIB.SVG#symbol511" stroke="#ff0000" 
fill="#ff0000" display="none"/>
        </g>
        <g id="appended">
                <use display="none" xlink:href="SYMLIB.SVG#symbol1364" 
transform="translate(17, 25) scale(0.850344)">
                </use>
                <use display="none" xlink:href="SYMLIB.SVG#symbol1364" 
transform="translate(33, 25) scale(0.850344)">
                </use>
                <use display="none" xlink:href="SYMLIB.SVG#symbol2512" 
transform="translate(50, 25) scale(0.850344)">
                </use>
        </g>
        <rgr:ranger type="discrete" pos="+" neg="-" 
presentation="symbolic" substation="STILWELL" point="R BKR R114" 
appPos="4">
        </rgr:ranger>
</g>


In spite of the inconsistency, I have isolated the cause of the problem. 
In bridge/BridgeContext.java, I placed some debug code around line 1677 
where the ClassCastException occurs. The exception occurs because 
elem.getParentNode() returns a org.apache.batik.dom.svg.SVGOMUseShadowRoot 
which does not cast to an Element.

It actually occurs on the following element within the above <g 
id="elm621">:

<use xlink:href="SYMLIB.SVG#symbol780" stroke="#72ea64" fill="#72ea64" 
display="inherit"/>

If I change display="inherit" to "none", the error goes away. Hopefully 
this is enough information for somebody to figure this out. What I still 
don't understand is the inconsistency of it. Why can I click on a button 
and have some elements appear, but others with the same layout don't? 
Well, it turns out that all of the elements that show this bug do have 
something in common. For example, every element within my SVG file which 
contains the reference xlink:href="SYMLIB.SVG#symbol780" provoke the 
error. Still, this makes very little sense to me. Here's the definition of 
symbol780 from the file SYMLIB.SVG:

                <g id="symbol780">
                        <title>OFF</title>
                        <g stroke="none" transform=" translate(0, 0)">
                                <text font-size="8" font-family="PED2, 
Arial" xml:space="preserve">OFF</text>
                        </g>
                </g>

That's as far as I can take it for now. I know the bug is apparently 
provoked by certain symbols, but I still do not understand why. What I 
definitely do know is that changing the display attribute from "inherit" 
to "none" works around the problem. As it turns out, my application sets 
the display attributes anyway, so I've got a workaround. Still, the above 
SVG should work.

If somebody has suggestions, or perhaps a bug fix for me to test, I'll be 
happy to give it a go.

Here's the stack trace:



Thanks,
Randy
java.lang.ClassCastException: org.apache.batik.dom.svg.SVGOMUseShadowRoot
        at 
org.apache.batik.bridge.BridgeContext$CSSPropertiesChangedListener.propertiesChanged(BridgeContext.java:1677)
        at 
org.apache.batik.css.engine.CSSEngine.firePropertiesChangedEvent(CSSEngine.java:1846)
        at 
org.apache.batik.css.engine.CSSEngine.propagateChanges(CSSEngine.java:2111)
        at 
org.apache.batik.css.engine.CSSEngine.invalidateProperties(CSSEngine.java:2047)
        at 
org.apache.batik.css.engine.CSSEngine.propagateChanges(CSSEngine.java:2146)
        at 
org.apache.batik.css.engine.CSSEngine.invalidateProperties(CSSEngine.java:2047)
        at 
org.apache.batik.css.engine.CSSEngine.propagateChanges(CSSEngine.java:2146)
        at 
org.apache.batik.css.engine.CSSEngine.invalidateProperties(CSSEngine.java:2047)
        at 
org.apache.batik.css.engine.CSSEngine.propagateChanges(CSSEngine.java:2146)
        at 
org.apache.batik.css.engine.CSSEngine.invalidateProperties(CSSEngine.java:2047)
        at 
org.apache.batik.css.engine.CSSEngine.nonCSSPresentationalHintUpdated(CSSEngine.java:2248)
        at 
org.apache.batik.css.engine.CSSEngine.handleAttrModified(CSSEngine.java:2347)
        at 
org.apache.batik.css.engine.CSSEngine$CSSNavigableDocumentHandler.attrModified(CSSEngine.java:2497)
        at 
org.apache.batik.dom.svg.SVGOMDocument$DOMAttrModifiedListenerWrapper.handleEvent(SVGOMDocument.java:641)
        at 
org.apache.batik.dom.events.EventSupport.fireEventListeners(EventSupport.java:317)
        at 
org.apache.batik.dom.events.EventSupport.fireEventListeners(EventSupport.java:359)
        at 
org.apache.batik.dom.events.EventSupport.dispatchEvent(EventSupport.java:276)
        at 
org.apache.batik.dom.AbstractNode.dispatchEvent(AbstractNode.java:1011)
        at 
org.apache.batik.dom.AbstractElement.fireDOMAttrModifiedEvent(AbstractElement.java:649)
        at 
org.apache.batik.dom.svg.AbstractElement$ExtendedNamedNodeHashMap.removeNamedItemNS(AbstractElement.java:312)
        at 
org.apache.batik.dom.AbstractElement.removeAttributeNS(AbstractElement.java:281)
        at com.abbnm.ranger.ZoomListener.declutterShow(ZoomListener.java:587)
        at com.abbnm.ranger.ZoomListener.toggleDeclutter(ZoomListener.java:731)
        at com.abbnm.ranger.ZoomListener$2$1.run(ZoomListener.java:668)
        at org.apache.batik.util.RunnableQueue.run(RunnableQueue.java:237)
        at java.lang.Thread.run(Thread.java:613)
show: elm627
java.lang.ClassCastException: org.apache.batik.dom.svg.SVGOMUseShadowRoot
        at 
org.apache.batik.bridge.BridgeContext$CSSPropertiesChangedListener.propertiesChanged(BridgeContext.java:1677)
        at 
org.apache.batik.css.engine.CSSEngine.firePropertiesChangedEvent(CSSEngine.java:1846)
        at 
org.apache.batik.css.engine.CSSEngine.propagateChanges(CSSEngine.java:2111)
        at 
org.apache.batik.css.engine.CSSEngine.invalidateProperties(CSSEngine.java:2047)
        at 
org.apache.batik.css.engine.CSSEngine.propagateChanges(CSSEngine.java:2146)
        at 
org.apache.batik.css.engine.CSSEngine.invalidateProperties(CSSEngine.java:2047)
        at 
org.apache.batik.css.engine.CSSEngine.propagateChanges(CSSEngine.java:2146)
        at 
org.apache.batik.css.engine.CSSEngine.invalidateProperties(CSSEngine.java:2047)
        at 
org.apache.batik.css.engine.CSSEngine.propagateChanges(CSSEngine.java:2146)
        at 
org.apache.batik.css.engine.CSSEngine.invalidateProperties(CSSEngine.java:2047)
        at 
org.apache.batik.css.engine.CSSEngine.nonCSSPresentationalHintUpdated(CSSEngine.java:2248)
        at 
org.apache.batik.css.engine.CSSEngine.handleAttrModified(CSSEngine.java:2347)
        at 
org.apache.batik.css.engine.CSSEngine$CSSNavigableDocumentHandler.attrModified(CSSEngine.java:2497)
        at 
org.apache.batik.dom.svg.SVGOMDocument$DOMAttrModifiedListenerWrapper.handleEvent(SVGOMDocument.java:641)
        at 
org.apache.batik.dom.events.EventSupport.fireEventListeners(EventSupport.java:317)
        at 
org.apache.batik.dom.events.EventSupport.fireEventListeners(EventSupport.java:359)
        at 
org.apache.batik.dom.events.EventSupport.dispatchEvent(EventSupport.java:276)
        at 
org.apache.batik.dom.AbstractNode.dispatchEvent(AbstractNode.java:1011)
        at 
org.apache.batik.dom.AbstractElement.fireDOMAttrModifiedEvent(AbstractElement.java:649)
        at 
org.apache.batik.dom.svg.AbstractElement$ExtendedNamedNodeHashMap.removeNamedItemNS(AbstractElement.java:312)
        at 
org.apache.batik.dom.AbstractElement.removeAttributeNS(AbstractElement.java:281)
        at com.abbnm.ranger.ZoomListener.declutterShow(ZoomListener.java:587)
        at com.abbnm.ranger.ZoomListener.toggleDeclutter(ZoomListener.java:731)
        at com.abbnm.ranger.ZoomListener$2$1.run(ZoomListener.java:668)
        at org.apache.batik.util.RunnableQueue.run(RunnableQueue.java:237)
        at java.lang.Thread.run(Thread.java:613)
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to