xmlgraphics-batik-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From osci <jeff.cress...@gmail.com>
Subject Updating DOM before rendering fails to render properly
Date Fri, 23 Nov 2007 15:06:19 GMT

Hello,

I've created a class that extends JSVGCanvas and am attempting to modify the
DOM of an svg document before rendering it. With the code as I have it only
the modifications that I make are rendered.

The document displays a line of circles representing pages in a story. When
a page is read the corresponding circle is replaced with an image. The
replacement occurs by setting the visibility of the circle to 'hidden' and
the visibility of the image to 'visible'. When the program loads I want to
replace each circle with the alternate image for all pages that have were
read the last time the program was run.

The document loads correctly if I don't attempt to modify it:

http://www.nabble.com/file/p13913737/circle.png 

When I do modify it the pages that have been read show the alternate image
but the pages that have not been read do not show the circles, whose element
were unmodified:

http://www.nabble.com/file/p13913737/image.png 

I am trying to achieve this:

http://www.nabble.com/file/p13913737/desired-result.png 

The Java code is as follows:

public IndicatorPanel(SVGUserAgent ua, boolean eventsEnabled,
        boolean selectableText, int numPage, int startPage) {
    super(ua, eventsEnabled, selectableText);
    
    setDocumentState(JSVGCanvas.ALWAYS_DYNAMIC);
    
    File file = new
File(PathVariableHelper.replacePathVariables(PATH_INDICATOR));
    String parser = XMLResourceDescriptor.getXMLParserClassName();
    SAXSVGDocumentFactory f = new SAXSVGDocumentFactory(parser);
    try {
        doc = (SVGDocument) f.createDocument(file.toURL().toString());
        
        Element el = null;
        for(int i=1; i<startPage+1; i++){
            el = doc.getElementById(ID_CIRCLE+i);
                el.setAttributeNS(null, "visibility", "hidden");
            el = doc.getElementById(ID_LEAF+i);
                el.setAttributeNS(null, "visibility", "visible");
        }
        
    } catch (Exception ex) {
    // error handling code...
    }        

    setSVGDocument(doc);  
}

The relevant SVG code snippets for a circle image pair is as follows:
<symbol id="leaf">
   <image xlink:href="leaf.svg" x="6" y="12" width="68" height="58"
filter="url(#drop-shadow)"/>
</symbol>
		
<symbol id="circ">
   <circle id="c1" cx="40" cy="40" r="10" />
</symbol>

<use id="l1" xlink:href="#leaf" x="0" y="0" width="78" height="74"
visibility="hidden" />
<use id="c1" xlink:href="#circ" x="0" y="0" visibility="visible" />

Any assistance would be greatly appreciated.

Regards,
Jeff Cressman

-- 
View this message in context: http://www.nabble.com/Updating-DOM-before-rendering-fails-to-render-properly-tf4862192.html#a13913737
Sent from the Batik - Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org


Mime
View raw message