@Override
  public void press(MouseEvent e) {
    createdSegmentIndex = -1;
    FXCircleSegmentHandlePart hp = getHost();
    IVisualPart<Node, ? extends Node> anchorage =
        getHost().getAnchorages().keySet().iterator().next();

    disableRefreshVisuals(anchorage);
    init(getBendPolicy(anchorage));

    if (hp.getSegmentParameter() == 0.5) {
      // create new way point
      getBendPolicy(anchorage)
          .createAndSelectSegmentPoint(
              hp.getSegmentIndex(), new Point(e.getSceneX(), e.getSceneY()));

      // find other segment handle parts
      List<FXCircleSegmentHandlePart> parts =
          PartUtils.filterParts(
              PartUtils.getAnchoreds(getHost().getAnchorages().keySet()),
              FXCircleSegmentHandlePart.class);

      // sort parts by segment index and parameter
      Collections.<FXCircleSegmentHandlePart>sort(parts);

      // increment segment index of succeeding parts
      for (FXCircleSegmentHandlePart p : parts) {
        if (p.getSegmentIndex() > hp.getSegmentIndex()
            || (p.getSegmentIndex() == hp.getSegmentIndex() && p.getSegmentParameter() == 1)) {
          p.setSegmentIndex(p.getSegmentIndex() + 1);
        }
      }

      // adjust index and parameter of this segment handle part
      hp.setSegmentIndex(hp.getSegmentIndex() + 1);
      hp.setSegmentParameter(0);
      createdSegmentIndex = hp.getSegmentIndex();
    } else {
      // select existing way point
      getBendPolicy(anchorage)
          .selectSegmentPoint(
              hp.getSegmentIndex(),
              hp.getSegmentParameter(),
              new Point(e.getSceneX(), e.getSceneY()));
    }
  }
 private void setSegmentIndex(FXCircleSegmentHandlePart part, int value) {
   if (part.getSegmentIndex() != value) {
     part.setSegmentIndex(value);
   }
 }