コード例 #1
0
  public static void updateDIEdge(Diagram diagram, Connection connection, Class clazz) {
    try {
      ModelHandler modelHandler =
          ModelHandlerLocator.getModelHandler(
              connection.getLink().getBusinessObjects().get(0).eResource());

      EObject be = BusinessObjectUtil.getFirstElementOfType(connection, clazz);
      BPMNEdge edge = (BPMNEdge) modelHandler.findDIElement(diagram, (BaseElement) be);
      Point point = DcFactory.eINSTANCE.createPoint();

      List<Point> waypoint = edge.getWaypoint();
      waypoint.clear();

      GraphicsAlgorithm graphicsAlgorithm = connection.getStart().getGraphicsAlgorithm();
      // FIXME connections must create anchors!!!
      if (graphicsAlgorithm != null) {
        point.setX(graphicsAlgorithm.getX());
        point.setY(graphicsAlgorithm.getY());
      } else {
        point.setX(connection.getStart().getParent().getGraphicsAlgorithm().getX());
        point.setY(connection.getStart().getParent().getGraphicsAlgorithm().getY());
      }
      waypoint.add(point);

      if (connection instanceof FreeFormConnectionImpl) {
        FreeFormConnectionImpl freeForm = (FreeFormConnectionImpl) connection;
        EList<org.eclipse.graphiti.mm.algorithms.styles.Point> bendpoints =
            freeForm.getBendpoints();
        for (org.eclipse.graphiti.mm.algorithms.styles.Point bp : bendpoints) {
          addBendPoint(freeForm, point);
        }
      }

      point = DcFactory.eINSTANCE.createPoint();
      graphicsAlgorithm = connection.getEnd().getGraphicsAlgorithm();
      if (graphicsAlgorithm != null) {
        point.setX(graphicsAlgorithm.getX());
        point.setY(graphicsAlgorithm.getY());
      } else {
        point.setX(connection.getEnd().getParent().getGraphicsAlgorithm().getX());
        point.setY(connection.getEnd().getParent().getGraphicsAlgorithm().getY());
      }
      waypoint.add(point);

    } catch (IOException e) {
      Activator.logError(e);
    }
  }
コード例 #2
0
 static void addBendPoint(FreeFormConnectionImpl freeForm, Point point) {
   freeForm
       .getBendpoints()
       .add(Graphiti.getGaService().createPoint((int) point.getX(), (int) point.getY()));
 }