java - Creating an SVGIcon using a valid svg xml with SVGSalamander -


i have .xml document valid svg image.

i want load icon different colors. not.

as solution firstly read xml file string , replace color's using simple string.replace()

now must create svgicon using new xml content.

is posssible svg salamander library.

with svg salamander:

get diagram cache , call recursive search , replace:

svgdiagram diagram = svgcache.getsvguniverse().getdiagram(uri); setstroke(color.black, gethexstring(color.green), diagram.getroot()); 

code functions:

private void setstroke(color fromcolor, string tocolor, svgelement node) throws svgexception {     if (node.hasattribute("stroke", animationelement.at_css)) {         styleattribute abs = node.getstyleabsolute("stroke");         color = abs.getcolorvalue();         if (was.equals(fromcolor)) {             abs.setstringvalue(tocolor);         }     }     (int = 0; < node.getnumchildren(); ++i) {         setstroke(fromcolor, tocolor, node.getchild(i));     } }  private string gethexstring(color color) {     return string.format("#%06x", (0xffffff & color.getrgb())); } 

Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -