xmlgraphics-batik-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Kerschbaum Michael " <m.kerschb...@pke.at>
Subject Updating Dom Tree outside of the UpdateManagerThread for printing ?
Date Thu, 03 Feb 2011 08:39:13 GMT
Hello,
 
I have a general question ! I would like to print an svg that is
currently visible on the screen. To do that i'am cloning the original
svg document with that code :
 
Document docOrg = svgDoc; // original document

DOMImplementation impl = docOrg.getImplementation();

Document docNew; // new document

docNew = impl.createDocument("http://www.w3.org/2000/svg", "svg", null);

docNew.replaceChild(docNew.importNode(docOrg.getDocumentElement(),
true),

docNew.getDocumentElement());

SVGDocument doc = (SVGDocument) docNew;

((AbstractDocument) doc).setDocumentURI(svgDoc.getURL());

Thats the easy part. But there is an own Animation ( a Thread that sets
some Elements visible and invisible to get a blink animation) ! In the
print this elements should be visible! So i copy the original svg at
anytime and set all elements to visible again. 

Element[] elements = ag.getAnimation().getAllElements(true);

if (elements != null || elements.length > 0) {

    logger.debug("Cleaning up cloned document for printing (e.g. current
blinking elements => visible) ...");

    logger.debug("Will clean up " + elements.length + " elements !");

    for (int i = 0; i < elements.length; i++) {

        String id = elements[i].getAttribute("id");

        Element elt = doc.getElementById(id);

        elt.setAttributeNS(null, "visibility", "visible");

    }

    logger.debug("Cleaned up cloned document for printing.");

}

But this is not done in the UpdateManagerThread ! because i will not
wait with invokeAndWait  ?! Could this be a problem ? I mean after that
i print the copied document and then i gets garbage collected => so i
don't do anything with it ?

mfg
 
Michael Kerschbaum

Mime
View raw message