private void writeLineElement(IXMLElement parent, SVGPathFigure f) throws IOException {
     IXMLElement elem = parent.createElement("area");
     if (writePolyAttributes(elem, f, new GrowStroke((float) (getStrokeTotalWidth(f) / 2d), (float) getStrokeTotalWidth(f)).
             createStrokedShape(new Line2D.Double(
             f.getStartPoint(), f.getEndPoint()
             )))) {
         parent.addChild(elem);
     }
 }
 private void writePolygonElement(IXMLElement parent, SVGPathFigure f) throws IOException {
     IXMLElement elem = parent.createElement("area");
     if (writePolyAttributes(elem, f, new GrowStroke((float) (getStrokeTotalWidth(f) / 2d), (float) getStrokeTotalWidth(f)).
             createStrokedShape(f.getChild(0).getBezierPath())
             )) {
         parent.addChild(elem);
     }
 }
 protected void writeElement(IXMLElement parent, Figure f) throws IOException {
     if (f instanceof SVGEllipseFigure) {
         writeEllipseElement(parent, (SVGEllipseFigure) f);
     } else if (f instanceof SVGGroupFigure) {
         writeGElement(parent, (SVGGroupFigure) f);
     } else if (f instanceof SVGImageFigure) {
         writeImageElement(parent, (SVGImageFigure)  f);
     } else if (f instanceof SVGPathFigure) {
         SVGPathFigure path = (SVGPathFigure) f;
         if (path.getChildCount() == 1) {
             BezierFigure bezier = (BezierFigure) path.getChild(0);
             boolean isLinear = true;
             for (int i=0, n = bezier.getNodeCount(); i < n; i++) {
                 if (bezier.getNode(i).getMask() != 0) {
                     isLinear = false;
                     break;
                 }
             }
             if (isLinear) {
                 if (bezier.isClosed()) {
                     writePolygonElement(parent, path);
                 } else {
                     if (bezier.getNodeCount() == 2) {
                         writeLineElement(parent, path);
                     } else  {
                         writePolylineElement(parent, path);
                     }
                 }
             } else {
                 writePathElement(parent, path);
             }
         } else {
             writePathElement(parent, path);
         }
     } else if (f instanceof SVGRectFigure) {
         writeRectElement(parent, (SVGRectFigure) f);
     } else if (f instanceof SVGTextFigure) {
         writeTextElement(parent, (SVGTextFigure) f);
     } else if (f instanceof SVGTextAreaFigure) {
         writeTextAreaElement(parent, (SVGTextAreaFigure) f);
     } else {
         System.out.println("Unable to write: "+f);
     }
 }
 private void writePathElement(IXMLElement parent, SVGPathFigure f) throws IOException {
     GrowStroke growStroke = new GrowStroke((float) (getStrokeTotalWidth(f) / 2d), (float) getStrokeTotalWidth(f));
     BasicStroke basicStroke = new BasicStroke((float) getStrokeTotalWidth(f));
     for (Figure child : f.getChildren()) {
         SVGBezierFigure bezier = (SVGBezierFigure) child;
         IXMLElement elem = parent.createElement("area");
         if (bezier.isClosed()) {
             writePolyAttributes(elem, f, growStroke.
                     createStrokedShape(bezier.getBezierPath())
                     );
         } else {
             writePolyAttributes(elem, f, basicStroke.
                     createStrokedShape(bezier.getBezierPath())
                     );
         }
         parent.addChild(elem);
     }
 }