xmlgraphics-batik-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Roger Critchlow" <...@elf.org>
Subject Re: modifying css in live svg document
Date Wed, 10 May 2006 03:56:31 GMT
Hi Shin --

So I've done it your way, parsing out the style element CDATA and then
modifying it with the CDATA mutation operators in the DOM
updateThread.

But I don't see any change in the rendered graphics until I trigger a
redraw with a mouseover.

So I need to tweak the rendered elements so they pick up the new style?

-- rec --

On 4/10/06, sugawara <sugawara@humane-systems.co.jp> wrote:
> Hi Roger,
>
> To hack the style sheet;
> ---- following must run under a RunnableQueue thread, needless to say ----
> SVGSVGElement root = document.getRootElement();
> SVGOMStyleElement style =
> (SVGOMStyleElement)getFirstChildByNodeName(root,"style");
> for (Node node=style.getFirstChild(); node!=null;
> node=node.getNextSibling()) {
>     if (node.getNodeType()==Node.CDATA_SECTION_NODE) {
>         CDATASection cdata = (CDATASection)node;
>         String value = cdata.getNodeValue();
>         int indx=0,indx1=0,indx2;
>         switch (textType) {
>         case GText.BLOCKNAME:   indx = value.indexOf(".bname");  break;
>         case GText.PORTNAME:    indx = value.indexOf(".pname");  break;
>         case GText.RESULT:              indx = value.indexOf(".result"); break;
>         }
>         indx1 = value.indexOf("fill:", indx);
>         if (indx1 < 0) {
>             indx1 = value.indexOf('}', indx);
>             cdata.insertData(indx1, ";fill:"+color);
>         } else {
>             indx1 += 5;
>             indx2 = value.indexOf('}', indx1);
>             cdata.replaceData(indx1, (indx2-indx1), color);
>         }
>         return;
>     }
> }
>
> public static Element getFirstChildByNodeName(Element parent, String
> nodeName) {
>     for (Node node=parent.getFirstChild(); node!=null;
> node=node.getNextSibling()) {
>         if (node.getNodeType()==Node.ELEMENT_NODE &&
> nodeName.equals(node.getNodeName()))
>             return (Element)node;
>         }
>     return null;
> }

---------------------------------------------------------------------
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