@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;
 }
 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);
     }
 }