class SVGRenderTargetImpl
        extends AbstractRenderTarget implements SVGTarget {

        private final Document document;
        private final Map<String, Element> topElements = new HashMap<>();
        private float scaleRatio = 1f;

        public SVGRenderTargetImpl(CanvasSize cs, boolean scaleStrokes) {
            DOMImplementation impl = SVGDOMImplementation.getDOMImplementation();
            DocumentType doctype = impl.createDocumentType(
                "svg",
                "-//W3C//DTD SVG 1.1//EN",
                "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd");
            document = impl.createDocument(SVGDOMImplementation.SVG_NAMESPACE_URI, "svg", doctype);

            // initializes CSS and SVG specific DOM interfaces
            UserAgent userAgent = new UserAgentAdapter();
            DocumentLoader loader = new DocumentLoader(userAgent);
            BridgeContext ctx = new BridgeContext(userAgent, loader);
            ctx.setDynamicState(BridgeContext.DYNAMIC);
            GVTBuilder builder = new GVTBuilder();
            builder.build(ctx, document);

            //Dimension
            SupportSize ss = new SupportSize(595F, 841F, LengthUnit.PIXELS);
            if (cs.getWidth() > cs.getHeight()) {
                ss = new SupportSize(
                    cs.getWidth() * ss.getHeightFloat() / cs.getHeight(),
                    ss.getHeightFloat(),
                    LengthUnit.PIXELS);
            } else if (cs.getHeight() > cs.getWidth()) {
                ss = new SupportSize(
                    ss.getWidthFloat(),
                    cs.getHeight() * ss.getWidthFloat() / cs.getWidth(),
                    LengthUnit.PIXELS);
            }

            // root element
            Element svgRoot = document.getDocumentElement();
            svgRoot.setAttributeNS(null, "width", cs.getWidth() + "");
            svgRoot.setAttributeNS(null, "height", cs.getHeight() + "");
            svgRoot.setAttributeNS(null, "version", "1.1");
            svgRoot.setAttributeNS(
                null,
                "viewBox",
                String.format(Locale.ENGLISH, "%f %f %f %f",
                    cs.getX(),
                    cs.getY(),
                    cs.getWidth(),
                    cs.getHeight()));

            //Scale & ratio
            if (scaleStrokes) {
                scaleRatio = ss.getWidthFloat() / cs.getWidth();
            }
        }

        @Override
        public Element getTopElement(String name) {<FILL_FUNCTION_BODY>}

        @Override
        public Document getDocument() {
            return document;
        }

        @Override
        public float getScaleRatio() {
            return scaleRatio;
        }

        @Override
        public Element createElement(String qualifiedName) {
            return document.createElementNS(SVGDOMImplementation.SVG_NAMESPACE_URI, qualifiedName);
        }

        @Override
        public Text createTextNode(String data) {
            return document.createTextNode(data);
        }

        @Override
        public String toHexString(Color color) {
            String str = Integer.toHexString(color.getRGB());

            for (int i = str.length(); i > 6; i--) {
                str = str.substring(1);
            }

            for (int i = str.length(); i < 6; i++) {
                str = "0" + str;
            }

            return "#" + str;
        }
    }

            Element topElement = topElements.get(name);
            if (topElement == null) {
                topElement = createElement("g");
                topElement.setAttribute("id", name);
                topElements.put(name, topElement);
                document.getDocumentElement().appendChild(topElement);
            }
            return topElement;
        
<no_super_class>