// This sample shows how to create unconnected links programmatically,
  // how to manipulate individual link points,
  // and how to make a link preserve its geometric shape.

  // Create an unconnected link
  DiagramLink link = diagram.getFactory().createDiagramLink(
    new Point2D.Float(4040)new Point2D.Float(15080));
  link.setStyle(LinkStyle.Polyline);
  link.setSegmentCount(4);

  // Modify the control points
  Random r = new Random();
  for (int i = 1; i < link.getControlPoints().size() 1; i++)
  {
    Point2D.Float point = (Point2D.Float)link.getControlPoints().get(i).clone();
    point.x += (float)r.nextInt(2010f;
    point.y += (float)r.nextInt(6030f;
    link.getControlPoints().set(i, point);
  }

  // It is necessary to invoke updateFromPoints in order to update
  // the arrowheads geometry and various internal variables
  link.updateFromPoints();

  // Preserve the link's shape while its end points are being moved 
  link.setRetainForm(true);