Пример #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);
     }
 }
 @Override
 public void transform(AffineTransform tx) {
   if (get(TRANSFORM) != null
       || (tx.getType() & (AffineTransform.TYPE_TRANSLATION)) != tx.getType()) {
     if (get(TRANSFORM) == null) {
       TRANSFORM.setClone(this, tx);
     } else {
       AffineTransform t = TRANSFORM.getClone(this);
       t.preConcatenate(tx);
       set(TRANSFORM, t);
     }
   } else {
     super.transform(tx);
   }
 }
 @Override
 protected Point2D.Double chop(Figure target, Point2D.Double from) {
   BezierFigure bf = (BezierFigure) getConnectorTarget(target);
   return bf.chop(from);
 }
 @Override
 public final Collection<Handle> createSecondaryHandles() {
   LinkedList<Handle> list = new LinkedList<Handle>();
   if (((ConnectionFigure) getOwner()).getLiner() == null && savedLiner == null) {
     int index = getBezierNodeIndex();
     BezierFigure f = getBezierFigure();
     BezierPath.Node v = f.getNode(index);
     if ((v.mask & BezierPath.C1_MASK) != 0 && (index != 0 || f.isClosed())) {
       list.add(new BezierControlPointHandle(f, index, 1));
     }
     if ((v.mask & BezierPath.C2_MASK) != 0 && (index < f.getNodeCount() - 1 || f.isClosed())) {
       list.add(new BezierControlPointHandle(f, index, 2));
     }
     if (index > 0 || f.isClosed()) {
       int i = (index == 0) ? f.getNodeCount() - 1 : index - 1;
       v = f.getNode(i);
       if ((v.mask & BezierPath.C2_MASK) != 0) {
         list.add(new BezierControlPointHandle(f, i, 2));
       }
     }
     if (index < f.getNodeCount() - 2 || f.isClosed()) {
       int i = (index == f.getNodeCount() - 1) ? 0 : index + 1;
       v = f.getNode(i);
       if ((v.mask & BezierPath.C1_MASK) != 0) {
         list.add(new BezierControlPointHandle(f, i, 1));
       }
     }
   }
   return list;
 }
 @Override
 public void invalidate() {
   super.invalidate();
   cachedDrawingArea = null;
 }