Ejemplo n.º 1
0
 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);
     }
 }
Ejemplo n.º 2
0
 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);
     }
 }