Ejemplo n.º 1
0
    @Override
    public SVGDocument toSVG(ConcreteDiagram cd) {
      /*
       * Use a Plain drawer to generate an SVG Document, then
       * "post-process" any SVG circles in the document to convert them
       * into "sketches".
       */
      SVGDocument document = (new PlainCircleSVGDrawer()).toSVG(cd);
      // return document;

      // find each circle in the document and turn it into a sketch. We
      // need to keep track of the circles and their eventual replacements
      // as each circle is replaced by 10's of smaller circles, thus the
      // DOM updates and we get the 10's of circles in our NodeList circles.
      NodeList circles = document.getElementsByTagName("circle");
      List<Node> replaceable = nodeListToList(circles);
      for (Node n : replaceable) {
        Node circleAsSketch = circleToSketch(document, (SVGCircleElement) n);
        n.getParentNode().replaceChild(circleAsSketch, n);
      }

      return document;
    }