Пример #1
0
 @Override
 public BezierFigure clone() {
   BezierFigure that = (BezierFigure) super.clone();
   that.path = this.path.clone();
   that.invalidate();
   return that;
 }
Пример #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);
     }
 }