コード例 #1
0
  @Override
  protected ContainerShape createPictogramElement(IAddContext context, IRectangle bounds) {

    T addedGateway = getBusinessObject(context);
    IGaService gaService = Graphiti.getGaService();
    IPeService peService = Graphiti.getPeService();

    int x = bounds.getX();
    int y = bounds.getY();
    int width = bounds.getWidth();
    int height = bounds.getHeight();

    // Create a container for the gateway-symbol
    final ContainerShape newShape =
        peService.createContainerShape(context.getTargetContainer(), true);
    final Rectangle gatewayRect = gaService.createInvisibleRectangle(newShape);
    gaService.setLocationAndSize(gatewayRect, x, y, width, height);

    Shape gatewayShape = peService.createShape(newShape, false);
    Polygon gateway = GraphicsUtil.createGateway(gatewayShape, width, height);
    StyleUtil.applyStyle(gateway, addedGateway);
    gaService.setLocationAndSize(gateway, 0, 0, width, height);

    return newShape;
  }
コード例 #2
0
  /**
   * Move bendpoints after the resize operation took place
   *
   * @param context
   */
  @Deprecated
  protected void moveAllBendpoints(IResizeShapeContext context) {

    Shape shape = context.getShape();

    IRectangle postResizeBounds = LayoutUtil.getAbsoluteBounds(shape);

    if (postResizeBounds.getX() == preResizeBounds.getX()
        && postResizeBounds.getY() == preResizeBounds.getY()) {

      // no resize from top left
      // no need to adjust bendpoints
      return;
    }

    int deltaX = (postResizeBounds.getX() - preResizeBounds.getX());
    int deltaY = (postResizeBounds.getY() - preResizeBounds.getY());

    Set<Connection> connectionsToMove = new HashSet<Connection>();

    // move connections contained in the resized shape
    connectionsToMove.addAll(calculateContainerConnections(context));

    for (Connection connection : connectionsToMove) {

      if (connection instanceof FreeFormConnection) {
        Layouter.layoutConnectionAfterShapeMove(connection, getFeatureProvider());
        moveConnectionBendpoints((FreeFormConnection) connection, deltaX, deltaY);
      }
    }
  }
コード例 #3
0
  /**
   * Move child shapes during a resize operation.
   *
   * @param context
   */
  protected void moveChildShapes(IResizeShapeContext context) {

    Shape shape = context.getShape();

    if (!(shape instanceof ContainerShape)) {
      return;
    }

    IRectangle postResizeBounds = LayoutUtil.getAbsoluteBounds(shape);

    if (postResizeBounds.getX() == preResizeBounds.getX()
        && postResizeBounds.getY() == preResizeBounds.getY()) {

      // no resize from top left
      // no need to adjust bendpoints / children positions
      return;
    }

    int deltaX = preResizeBounds.getX() - postResizeBounds.getX();
    int deltaY = preResizeBounds.getY() - postResizeBounds.getY();

    FeatureSupport.moveChildren(
        (ContainerShape) shape, point(deltaX, deltaY), getFeatureProvider());
  }