/** * Clone a single SVG element. * * @param source * The source SVG element. * @return Returns the clone. */ private static Element clone(Element source) { if (source == null || source.getNodeName() == null) { return null; } if ("#text".equals(source.getNodeName())) { return Document.get().createTextNode(source.getNodeValue()).cast(); } Element clone = createElementNS(Dom.NS_SVG, source.getNodeName()); cloneAttributes(source, clone); for (int i = 0; i < source.getChildCount(); i++) { Element child = source.getChild(i).cast(); clone.appendChild(clone(child)); } return clone; }
/** * Clone a single SVG element. * * @param source * The source SVG element. * @return Returns the clone. */ private static Element clone(Element source) { if (source == null || source.getNodeName() == null) { return null; } if ("#text".equals(source.getNodeName())) { return Document.get().createTextNode(source.getNodeValue()).cast(); } Element clone = createElementNS(Dom.NS_SVG, source.getNodeName()); cloneAttributes(source, clone); for (int i = 0; i < source.getChildCount(); i++) { Element child = source.getChild(i).cast(); clone.appendChild(clone(child)); } return clone; }
/** * Clone a single SVG element. * * @param source * The source SVG element. * @return Returns the clone. */ public Element cloneSvgElement(Element source) { if (source == null || source.getNodeName() == null) { return null; } if ("#text".equals(source.getNodeName())) { return Document.get().createTextNode(source.getNodeValue()).cast(); } Element clone = createElementNS(Dom.NS_SVG, source.getNodeName(), Dom.createUniqueId()); cloneAttributes(source, clone); for (int i = 0; i < source.getChildCount(); i++) { Element child = source.getChild(i).cast(); clone.appendChild(cloneSvgElement(child)); } return clone; }