Пример #1
0
  public void reconnectElements() {
    if (connection == null) {
      connection = new Connection(this);
    }

    if (getNestedPatterns().isEmpty()) {
      connection.connect(timerEvent, Direction.BOTTOM, placeHolder, Direction.TOP);
    } else {
      connection.connect(
          timerEvent, Direction.BOTTOM, getNestedPattern().getFirstElement(), Direction.TOP);
    }
  }
  public static void create(
      Pattern draggedPattern, Pattern ownerPattern, Collection<PlaceHolder> placeHolders) {
    if (!(ownerPattern.getOMReference() instanceof ActivityHolder)) {
      return;
    }

    if (draggedPattern.getParent() == ownerPattern) {
      return;
    }

    ActivityHolder holder = (ActivityHolder) ownerPattern.getOMReference();

    BpelEntity child = holder.getActivity();

    if ((child == null)
        || (child instanceof Sequence)
        || (ownerPattern instanceof CollapsedPattern)) {
      return;
    }

    Pattern p = ((CompositePattern) ownerPattern).getNestedPattern(child);

    Connection c1 = getInboundConnection(p);
    Connection c2 = getOutboundConnection(p);

    FPoint center1 = null;
    FPoint center2 = null;

    if (c1 != null) {
      FPath path = c1.getPath();
      if (p instanceof CompositePattern) {
        CompositePattern composite = (CompositePattern) p;
        BorderElement border = composite.getBorder();

        if (border != null) {
          path = path.subtract(border.getShape());
        }
      }
      double pathLength = path.length();
      center1 = path.point((pathLength >= 20) ? ((pathLength - 10) / pathLength) : 0.5f);
    } else {
      VisualElement e = null;
      if (p instanceof CompositePattern) {
        CompositePattern composite = (CompositePattern) p;
        e = composite.getBorder();
      }

      if (e == null) {
        e = p.getFirstElement();
      }

      center1 = new FPoint(e.getCenterX(), e.getY() - 10);
    }

    if (c2 != null) {
      FPath path = c2.getPath();
      if (p instanceof CompositePattern) {
        CompositePattern composite = (CompositePattern) p;
        BorderElement border = composite.getBorder();

        if (border != null) {
          path = path.subtract(border.getShape());
        }
      }
      double pathLength = path.length();
      center2 = path.point((pathLength >= 20) ? (10 / pathLength) : 0.5f);
    } else {
      if (p instanceof CompositePattern) {
        CompositePattern composite = (CompositePattern) p;

        VisualElement e = composite.getBorder();

        if (e == null) {
          e = p.getLastElement();
        }

        center2 = new FPoint(e.getCenterX(), e.getY() + e.getHeight() + 10);
      } else {
        VisualElement e = p.getLastElement();
        center2 = new FPoint(e.getCenterX(), e.getY() + e.getHeight() + 10);
      }
    }

    placeHolders.add(
        new ImpliciteSequencePlaceHolder(ownerPattern, draggedPattern, center1.x, center1.y));
    placeHolders.add(
        new ImpliciteSequencePlaceHolder(ownerPattern, draggedPattern, center2.x, center2.y, true));
  }