Examples of IPeCreateService


Examples of org.eclipse.graphiti.services.IPeCreateService

  public PictogramElement add(IAddContext context) {
    final ExclusiveGateway addedGateway = (ExclusiveGateway) context.getNewObject();
    final ContainerShape parent = context.getTargetContainer();

    // CONTAINER SHAPE WITH CIRCLE
    final IPeCreateService peCreateService = Graphiti.getPeCreateService();
    final ContainerShape containerShape = peCreateService.createContainerShape(parent, true);

    // check whether the context has a size (e.g. from a create feature)
    // otherwise define a default size for the shape
    final int width = context.getWidth() <= 0 ? 40 : context.getWidth();
    final int height = context.getHeight() <= 0 ? 40 : context.getHeight();

    final IGaService gaService = Graphiti.getGaService();

    Polygon polygon;
    {
      int xy[] = new int[] { 0, 20, 20, 0, 40, 20, 20, 40, 0, 20 };
      final Polygon invisiblePolygon = gaService.createPolygon(containerShape, xy);
      invisiblePolygon.setFilled(false);
      invisiblePolygon.setLineVisible(false);
      gaService.setLocationAndSize(invisiblePolygon, context.getX(), context.getY(), width, height);

      // create and set visible circle inside invisible circle
      polygon = gaService.createPolygon(invisiblePolygon, xy);
      polygon.setParentGraphicsAlgorithm(invisiblePolygon);
      polygon.setStyle(StyleUtil.getStyleForEvent(getDiagram()));
      gaService.setLocationAndSize(polygon, 0, 0, width, height);

      // create link and wire it
      link(containerShape, addedGateway);
    }
   
    {
      final Shape shape = peCreateService.createShape(containerShape, false);
     
      final Polyline polyline = gaService.createPolyline(shape, new int[] { width - 10, 10, 10, height - 10 });
      polyline.setLineWidth(5);
      polyline.setStyle(StyleUtil.getStyleForEvent(getDiagram()));
    }
   
    {
      final Shape shape = peCreateService.createShape(containerShape, false);
      final Polyline polyline = gaService.createPolyline(shape, new int[] { 10, 10, width - 10, height - 10});
      polyline.setLineWidth(5);
      polyline.setStyle(StyleUtil.getStyleForEvent(getDiagram()));
    }

    {
      // add a chopbox anchor to the shape
      peCreateService.createChopboxAnchor(containerShape);
      final BoxRelativeAnchor boxAnchor = peCreateService.createBoxRelativeAnchor(containerShape);
      boxAnchor.setRelativeWidth(0.51);
      boxAnchor.setRelativeHeight(0.10);
      boxAnchor.setReferencedGraphicsAlgorithm(polygon);
      final Ellipse ellipse = ActivitiUiUtil.createInvisibleEllipse(boxAnchor, gaService);
      gaService.setLocationAndSize(ellipse, 0, 0, 0, 0);
    }

    {
      // add a another chopbox anchor to the shape
      peCreateService.createChopboxAnchor(containerShape);
      final BoxRelativeAnchor boxAnchor2 = peCreateService.createBoxRelativeAnchor(containerShape);
      boxAnchor2.setRelativeWidth(0.51);
      boxAnchor2.setRelativeHeight(0.93);
      boxAnchor2.setReferencedGraphicsAlgorithm(polygon);
      final Ellipse ellipse = ActivitiUiUtil.createInvisibleEllipse(boxAnchor2, gaService);
      gaService.setLocationAndSize(ellipse, 0, 0, 0, 0);
View Full Code Here

Examples of org.eclipse.graphiti.services.IPeCreateService

  public PictogramElement add(IAddContext context) {
    final Gateway addedGateway = (Gateway) context.getNewObject();
    final ContainerShape parent = context.getTargetContainer();

    // CONTAINER SHAPE WITH CIRCLE
    final IPeCreateService peCreateService = Graphiti.getPeCreateService();
    final ContainerShape containerShape = peCreateService.createContainerShape(parent, true);

    // check whether the context has a size (e.g. from a create feature)
    // otherwise define a default size for the shape
    final int width = context.getWidth() <= 0 ? 40 : context.getWidth();
    final int height = context.getHeight() <= 0 ? 40 : context.getHeight();

    final IGaService gaService = Graphiti.getGaService();

    Polygon polygon;
    {
      int xy[] = new int[] { 0, 20, 20, 0, 40, 20, 20, 40, 0, 20 };
      final Polygon invisiblePolygon = gaService.createPolygon(containerShape, xy);
      invisiblePolygon.setFilled(false);
      invisiblePolygon.setLineVisible(false);
      gaService.setLocationAndSize(invisiblePolygon, context.getX(), context.getY(), width, height);

      // create and set visible circle inside invisible circle
      polygon = gaService.createPolygon(invisiblePolygon, xy);
      polygon.setParentGraphicsAlgorithm(invisiblePolygon);
      polygon.setStyle(StyleUtil.getStyleForEvent(getDiagram()));
      gaService.setLocationAndSize(polygon, 0, 0, width, height);

      // create link and wire it
      link(containerShape, addedGateway);
    }
   
    {
      final Shape shape = peCreateService.createShape(containerShape, false);
     
      final Polyline polyline = gaService.createPolyline(shape, new int[] { 6, 19, width - 6, 19 });
      polyline.setLineWidth(5);
      polyline.setStyle(StyleUtil.getStyleForEvent(getDiagram()));
    }
   
    {
      final Shape shape = peCreateService.createShape(containerShape, false);
     
      final Polyline polyline = gaService.createPolyline(shape, new int[] { 18, 6, 18, height - 6 });
      polyline.setLineWidth(5);
      polyline.setStyle(StyleUtil.getStyleForEvent(getDiagram()));
    }

    {
      // add a chopbox anchor to the shape
      peCreateService.createChopboxAnchor(containerShape);
      final BoxRelativeAnchor boxAnchor = peCreateService.createBoxRelativeAnchor(containerShape);
      boxAnchor.setRelativeWidth(0.51);
      boxAnchor.setRelativeHeight(0.10);
      boxAnchor.setReferencedGraphicsAlgorithm(polygon);
      final Ellipse ellipse = ActivitiUiUtil.createInvisibleEllipse(boxAnchor, gaService);
      gaService.setLocationAndSize(ellipse, 0, 0, 0, 0);
    }

    {
      // add a another chopbox anchor to the shape
      peCreateService.createChopboxAnchor(containerShape);
      final BoxRelativeAnchor boxAnchor2 = peCreateService.createBoxRelativeAnchor(containerShape);
      boxAnchor2.setRelativeWidth(0.51);
      boxAnchor2.setRelativeHeight(0.93);
      boxAnchor2.setReferencedGraphicsAlgorithm(polygon);
      final Ellipse ellipse = ActivitiUiUtil.createInvisibleEllipse(boxAnchor2, gaService);
      gaService.setLocationAndSize(ellipse, 0, 0, 0, 0);
View Full Code Here

Examples of org.eclipse.graphiti.services.IPeCreateService

   
    if (sourceAnchor == null || targetAnchor == null) {
      return null;
    }
   
    final IPeCreateService peCreateService = Graphiti.getPeCreateService();
   
    // CONNECTION WITH POLYLINE
    final FreeFormConnection connection = peCreateService.createFreeFormConnection(getDiagram());
   
    connection.setStart(sourceAnchor);
    connection.setEnd(targetAnchor);
   
    sourceAnchor.getOutgoingConnections().add(connection);
View Full Code Here

Examples of org.eclipse.graphiti.services.IPeCreateService

  @Override
  public PictogramElement add(IAddContext context) {
    final TextAnnotation annotation = (TextAnnotation) context.getNewObject();
   
    final IPeCreateService peCreateService = Graphiti.getPeCreateService();
    final ContainerShape containerShape = peCreateService.createContainerShape(context.getTargetContainer(), true);
   
    final IGaService gaService = Graphiti.getGaService();
   
    // TODO: we currently only support horizontal lanes!!!
    final int height = Math.max(50, context.getHeight());
    final int width = Math.max(100, context.getWidth());
    final int commentEdge = 20;
   
    final Rectangle rect = gaService.createInvisibleRectangle(containerShape);
    gaService.setLocationAndSize(rect, context.getX(), context.getY(), width, height);
   
    final Shape lineShape = peCreateService.createShape(containerShape, false);
    final Polyline line
      = gaService.createPolyline(lineShape
          , new int[] { commentEdge, 0, 0, 0, 0, height, commentEdge, height });
    line.setStyle(StyleUtil.getStyleForTask(getDiagram()));
    line.setLineWidth(2);
    gaService.setLocationAndSize(line, 0, 0, commentEdge, height);
   
    final Shape textShape = peCreateService.createShape(containerShape, false);
    final MultiText text = gaService.createDefaultMultiText(getDiagram(), textShape, annotation.getText());
    text.setStyle(StyleUtil.getStyleForTask(getDiagram()));
    text.setVerticalAlignment(Orientation.ALIGNMENT_TOP);
    if (OSUtil.getOperatingSystem() == OSEnum.Mac) {
      text.setFont(gaService.manageFont(getDiagram(), text.getFont().getName(), 11));
    }
    gaService.setLocationAndSize(text, 5, 5, width - 5, height - 5);
   
    // link both, the container as well as the text shape so direct editing works together
    // with updating and property handling
    link(containerShape, annotation);
    link(textShape, annotation);
   
    peCreateService.createChopboxAnchor(containerShape);
     
    layoutPictogramElement(containerShape);
   
    return containerShape;
  }
View Full Code Here

Examples of org.eclipse.graphiti.services.IPeCreateService

  public PictogramElement add(IAddContext context) {
    final Event addedEvent = (Event) context.getNewObject();
    final ContainerShape parent = context.getTargetContainer();

    // CONTAINER SHAPE WITH CIRCLE
    final IPeCreateService peCreateService = Graphiti.getPeCreateService();
    final ContainerShape containerShape = peCreateService.createContainerShape(parent, true);

    // check whether the context has a size (e.g. from a create feature)
    // otherwise define a default size for the shape
    final int width = context.getWidth() <= 0 ? 35 : context.getWidth();
    final int height = context.getHeight() <= 0 ? 35 : context.getHeight();

    final IGaService gaService = Graphiti.getGaService();

    Ellipse circle;
    {
      final Ellipse invisibleCircle = gaService.createEllipse(containerShape);
      invisibleCircle.setFilled(false);
      invisibleCircle.setLineVisible(false);
      gaService.setLocationAndSize(invisibleCircle, context.getX(), context.getY(), width, height);

      // create and set visible circle inside invisible circle
      circle = gaService.createEllipse(invisibleCircle);
      circle.setParentGraphicsAlgorithm(invisibleCircle);
      circle.setStyle(StyleUtil.getStyleForEvent(getDiagram()));
      if (addedEvent instanceof EndEvent == true) {
        circle.setLineWidth(3);
      }
      gaService.setLocationAndSize(circle, 0, 0, width, height);

      // create link and wire it
      link(containerShape, addedEvent);
    }
   
    {
      final Shape shape = peCreateService.createShape(containerShape, false);
      final Image image = gaService.createImage(shape, PluginImage.IMG_ALFRESCO_LOGO.getImageKey());

      gaService.setLocationAndSize(image, 10, 10, IMAGE_SIZE, IMAGE_SIZE);
    }

    // add a chopbox anchor to the shape
    peCreateService.createChopboxAnchor(containerShape);
   
    // create an additional box relative anchor at middle-right
    final BoxRelativeAnchor boxAnchor = peCreateService.createBoxRelativeAnchor(containerShape);
    boxAnchor.setRelativeWidth(1.0);
    boxAnchor.setRelativeHeight(0.51);
    boxAnchor.setReferencedGraphicsAlgorithm(circle);
    final Ellipse ellipse = ActivitiUiUtil.createInvisibleEllipse(boxAnchor, gaService);
    gaService.setLocationAndSize(ellipse, 0, 0, 0, 0);
View Full Code Here

Examples of org.eclipse.graphiti.services.IPeCreateService

  public PictogramElement add(IAddContext context) {
    final Task addedTask = (Task) context.getNewObject();
    final ContainerShape parent = context.getTargetContainer();

    // CONTAINER SHAPE WITH ROUNDED RECTANGLE
    final IPeCreateService peCreateService = Graphiti.getPeCreateService();
    final ContainerShape containerShape = peCreateService.createContainerShape(parent, true);
    final IGaService gaService = Graphiti.getGaService();

    int width = 0;
    int height = 0;
    GraphicsAlgorithm algorithm = null;

    // check whether the context has a size (e.g. from a create feature)
    // otherwise define a default size for the shape
    width = context.getWidth() <= 0 ? 105 : context.getWidth();
    height = context.getHeight() <= 0 ? 55 : context.getHeight();

    RoundedRectangle roundedRectangle; // need to access it later
    {
      // create invisible outer rectangle expanded by
      // the width needed for the anchor
      final Rectangle invisibleRectangle = gaService.createInvisibleRectangle(containerShape);
      gaService.setLocationAndSize(invisibleRectangle, context.getX(), context.getY(), width, height);

      // create and set visible rectangle inside invisible rectangle
      roundedRectangle = gaService.createRoundedRectangle(invisibleRectangle, 20, 20);
      algorithm = roundedRectangle;
      roundedRectangle.setParentGraphicsAlgorithm(invisibleRectangle);
      roundedRectangle.setStyle(StyleUtil.getStyleForTask(getDiagram()));
      gaService.setLocationAndSize(roundedRectangle, 0, 0, width, height);

      // create link and wire it
      link(containerShape, addedTask);
    }

    // SHAPE WITH TEXT
    {
      // create shape for text
      final Shape shape = peCreateService.createShape(containerShape, false);

      // create and set text graphics algorithm
      final MultiText text = gaService.createDefaultMultiText(getDiagram(), shape, addedTask.getName());
      text.setStyle(StyleUtil.getStyleForTask(getDiagram()));
      text.setHorizontalAlignment(Orientation.ALIGNMENT_CENTER);
      text.setVerticalAlignment(Orientation.ALIGNMENT_CENTER);
      if (OSUtil.getOperatingSystem() == OSEnum.Mac) {
        text.setFont(gaService.manageFont(getDiagram(), text.getFont().getName(), 11));
      }

      gaService.setLocationAndSize(text, 0, 20, width, 30);
    
      // create link and wire it
      link(shape, addedTask);

      // provide information to support direct-editing directly
      // after object creation (must be activated additionally)
      final IDirectEditingInfo directEditingInfo = getFeatureProvider().getDirectEditingInfo();
      // set container shape for direct editing after object creation
      directEditingInfo.setMainPictogramElement(containerShape);
      // set shape and graphics algorithm where the editor for
      // direct editing shall be opened after object creation
      directEditingInfo.setPictogramElement(shape);
      directEditingInfo.setGraphicsAlgorithm(text);
    }

    {
      final Shape shape = peCreateService.createShape(containerShape, false);
      final Image image = gaService.createImage(shape, getIcon(addedTask));

      gaService.setLocationAndSize(image, 5, 5, IMAGE_SIZE, IMAGE_SIZE);
    }
   
    {
      final Shape shape = peCreateService.createShape(containerShape, false);
      final Image image = gaService.createImage(shape, PluginImage.IMG_ALFRESCO_LOGO.getImageKey());

      gaService.setLocationAndSize(image, 85, 3, IMAGE_SIZE, IMAGE_SIZE);
    }

    // add a chopbox anchor to the shape
    peCreateService.createChopboxAnchor(containerShape);

    // create an additional box relative anchor at middle-right
    final BoxRelativeAnchor boxAnchor = peCreateService.createBoxRelativeAnchor(containerShape);
    boxAnchor.setRelativeWidth(1.0);
    boxAnchor.setRelativeHeight(0.51);
    boxAnchor.setReferencedGraphicsAlgorithm(algorithm);
    final Ellipse ellipse = ActivitiUiUtil.createInvisibleEllipse(boxAnchor, gaService);
    gaService.setLocationAndSize(ellipse, 0, 0, 0, 0);
View Full Code Here

Examples of org.eclipse.graphiti.services.IPeCreateService

    final CallActivity addedCallActivity = (CallActivity) context.getNewObject();
    final ContainerShape parent = context.getTargetContainer();

    // CONTAINER SHAPE WITH ROUNDED RECTANGLE
    final IPeCreateService peCreateService = Graphiti.getPeCreateService();
    final ContainerShape containerShape = peCreateService.createContainerShape(parent, true);

    // EList<Property> props = containerShape.getProperties();

    // check whether the context has a size (e.g. from a create feature)
    // otherwise define a default size for the shape
    final int width = context.getWidth() <= 0 ? 105 : context.getWidth();
    final int height = context.getHeight() <= 0 ? 55 : context.getHeight();

    final IGaService gaService = Graphiti.getGaService();
    RoundedRectangle roundedRectangle; // need to access it later
    {
      // create invisible outer rectangle expanded by
      // the width needed for the anchor
      final Rectangle invisibleRectangle = gaService.createInvisibleRectangle(containerShape);
      gaService.setLocationAndSize(invisibleRectangle, context.getX(), context.getY(), width, height);

      // create and set visible rectangle inside invisible rectangle
      roundedRectangle = gaService.createRoundedRectangle(invisibleRectangle, 5, 5);
      roundedRectangle.setParentGraphicsAlgorithm(invisibleRectangle);
      roundedRectangle.setStyle(StyleUtil.getStyleForTask(getDiagram()));
      roundedRectangle.setLineWidth(3);
      gaService.setLocationAndSize(roundedRectangle, 0, 0, width, height);

      // create link and wire it
      link(containerShape, addedCallActivity);
    }

    // SHAPE WITH TEXT
    {
      // create shape for text
      final Shape shape = peCreateService.createShape(containerShape, false);

      // create and set text graphics algorithm
      final MultiText text = gaService.createDefaultMultiText(getDiagram(), shape, addedCallActivity.getName());
      text.setStyle(StyleUtil.getStyleForTask(getDiagram()));
      text.setHorizontalAlignment(Orientation.ALIGNMENT_CENTER);
      text.setVerticalAlignment(Orientation.ALIGNMENT_CENTER);
      Font font = null;
      if (OSUtil.getOperatingSystem() == OSEnum.Mac) {
        font = gaService.manageFont(getDiagram(), text.getFont().getName(), 11, false, true);
      } else {
        font = gaService.manageDefaultFont(getDiagram(), false, true);
      }
      text.setFont(font);

      gaService.setLocationAndSize(text, 0, 20, width, 30);

      // create link and wire it
      link(shape, addedCallActivity);

      // provide information to support direct-editing directly
      // after object creation (must be activated additionally)
      final IDirectEditingInfo directEditingInfo = getFeatureProvider().getDirectEditingInfo();
      // set container shape for direct editing after object creation
      directEditingInfo.setMainPictogramElement(containerShape);
      // set shape and graphics algorithm where the editor for
      // direct editing shall be opened after object creation
      directEditingInfo.setPictogramElement(shape);
      directEditingInfo.setGraphicsAlgorithm(text);
    }

    {
      final Shape shape = peCreateService.createShape(containerShape, false);
      final Image image = gaService.createImage(shape, getIcon());

      // calculate position for icon
      final int iconWidthAndHeight = 10;
      final int padding = 5;
      final int xPos = (roundedRectangle.getWidth() / 2) - (iconWidthAndHeight / 2);
      final int yPos = roundedRectangle.getHeight() - padding - iconWidthAndHeight;

      gaService.setLocationAndSize(image, xPos, yPos, iconWidthAndHeight, iconWidthAndHeight);
    }

    // add a chopbox anchor to the shape
    peCreateService.createChopboxAnchor(containerShape);

    final BoxRelativeAnchor boxAnchor = peCreateService.createBoxRelativeAnchor(containerShape);
    boxAnchor.setRelativeWidth(1.0);
    boxAnchor.setRelativeHeight(0.51);
    boxAnchor.setReferencedGraphicsAlgorithm(roundedRectangle);
    final Ellipse ellipse = ActivitiUiUtil.createInvisibleEllipse(boxAnchor, gaService);
    gaService.setLocationAndSize(ellipse, 0, 0, 0, 0);
View Full Code Here

Examples of org.eclipse.graphiti.services.IPeCreateService

  public PictogramElement add(IAddContext context) {
    final Event addedEvent = (Event) context.getNewObject();
    final ContainerShape parent = context.getTargetContainer();

    // CONTAINER SHAPE WITH CIRCLE
    final IPeCreateService peCreateService = Graphiti.getPeCreateService();
    final ContainerShape containerShape = peCreateService.createContainerShape(parent, true);

    // check whether the context has a size (e.g. from a create feature)
    // otherwise define a default size for the shape
    final int width = context.getWidth() <= 0 ? 35 : context.getWidth();
    final int height = context.getHeight() <= 0 ? 35 : context.getHeight();

    final IGaService gaService = Graphiti.getGaService();

    Ellipse circle;
    {
      final Ellipse invisibleCircle = gaService.createEllipse(containerShape);
      invisibleCircle.setFilled(false);
      invisibleCircle.setLineVisible(false);
      gaService.setLocationAndSize(invisibleCircle, context.getX(), context.getY(), width, height);

      // create and set visible circle inside invisible circle
      circle = gaService.createEllipse(invisibleCircle);
      circle.setParentGraphicsAlgorithm(invisibleCircle);
      circle.setStyle(StyleUtil.getStyleForEvent(getDiagram()));
      gaService.setLocationAndSize(circle, 0, 0, width, height);

      // create link and wire it
      link(containerShape, addedEvent);
    }

    {
      final Shape shape = peCreateService.createShape(containerShape, false);
      final Image image = gaService.createImage(shape, PluginImage.IMG_BOUNDARY_TIMER.getImageKey());
      image.setWidth(20);
      image.setHeight(20);
      gaService.setLocationAndSize(image, (width - 20) / 2, (height - 20) / 2, 20, 20);
    }

    // add a chopbox anchor to the shape
    peCreateService.createChopboxAnchor(containerShape);
    if (!(addedEvent instanceof EndEvent)) {

      // create an additional box relative anchor at middle-right
      final BoxRelativeAnchor boxAnchor = peCreateService.createBoxRelativeAnchor(containerShape);
      boxAnchor.setRelativeWidth(1.0);
      boxAnchor.setRelativeHeight(0.51);
      boxAnchor.setReferencedGraphicsAlgorithm(circle);
      final Ellipse ellipse = ActivitiUiUtil.createInvisibleEllipse(boxAnchor, gaService);
      gaService.setLocationAndSize(ellipse, 0, 0, 0, 0);
View Full Code Here

Examples of org.eclipse.graphiti.services.IPeCreateService

  public PictogramElement add(IAddContext context) {
    final Event addedEvent = (Event) context.getNewObject();
    final ContainerShape parent = context.getTargetContainer();

    // CONTAINER SHAPE WITH CIRCLE
    final IPeCreateService peCreateService = Graphiti.getPeCreateService();
    final ContainerShape containerShape = peCreateService.createContainerShape(parent, true);

    // check whether the context has a size (e.g. from a create feature)
    // otherwise define a default size for the shape
    final int width = context.getWidth() <= 35 ? 35 : context.getWidth();
    final int height = context.getHeight() <= 35 ? 35 : context.getHeight();

    final IGaService gaService = Graphiti.getGaService();

    Ellipse circle;
    {
      final Ellipse invisibleCircle = gaService.createEllipse(containerShape);
      invisibleCircle.setFilled(false);
      invisibleCircle.setLineVisible(false);
      gaService.setLocationAndSize(invisibleCircle, context.getX(), context.getY(), width, height);

      // create and set visible circle inside invisible circle
      circle = gaService.createEllipse(invisibleCircle);
      circle.setParentGraphicsAlgorithm(invisibleCircle);
      circle.setStyle(StyleUtil.getStyleForEvent(getDiagram()));
      circle.setLineWidth(3);
      gaService.setLocationAndSize(circle, 0, 0, width, height);

      // create link and wire it
      link(containerShape, addedEvent);
    }

    {
      final Shape shape = peCreateService.createShape(containerShape, false);
      final Image image = gaService.createImage(shape, PluginImage.IMG_ENDEVENT_TERMINATE.getImageKey());

      gaService.setLocationAndSize(image, 5, 5, 25, 25);
    }

    // add a chopbox anchor to the shape
    peCreateService.createChopboxAnchor(containerShape);
    if (!(addedEvent instanceof EndEvent)) {

      // create an additional box relative anchor at middle-right
      final BoxRelativeAnchor boxAnchor = peCreateService.createBoxRelativeAnchor(containerShape);
      boxAnchor.setRelativeWidth(1.0);
      boxAnchor.setRelativeHeight(0.51);
      boxAnchor.setReferencedGraphicsAlgorithm(circle);
      final Ellipse ellipse = ActivitiUiUtil.createInvisibleEllipse(boxAnchor, gaService);
      gaService.setLocationAndSize(ellipse, 0, 0, 0, 0);
View Full Code Here

Examples of org.eclipse.graphiti.services.IPeCreateService

  public PictogramElement add(IAddContext context) {
    final Event addedEvent = (Event) context.getNewObject();
    final ContainerShape parent = context.getTargetContainer();

    // CONTAINER SHAPE WITH CIRCLE
    final IPeCreateService peCreateService = Graphiti.getPeCreateService();
    final ContainerShape containerShape = peCreateService.createContainerShape(parent, true);

    // check whether the context has a size (e.g. from a create feature)
    // otherwise define a default size for the shape
    final int width = context.getWidth() <= 0 ? 35 : context.getWidth();
    final int height = context.getHeight() <= 0 ? 35 : context.getHeight();

    final IGaService gaService = Graphiti.getGaService();

    Ellipse circle;
    {
      final Ellipse invisibleCircle = gaService.createEllipse(containerShape);
      invisibleCircle.setFilled(false);
      invisibleCircle.setLineVisible(false);
      gaService.setLocationAndSize(invisibleCircle, context.getX(), context.getY(), width, height);

      // create and set visible circle inside invisible circle
      circle = gaService.createEllipse(invisibleCircle);
      circle.setParentGraphicsAlgorithm(invisibleCircle);
      circle.setStyle(StyleUtil.getStyleForEvent(getDiagram()));
      gaService.setLocationAndSize(circle, 0, 0, width, height);

      // create link and wire it
      link(containerShape, addedEvent);
    }

    {
      final Shape shape = peCreateService.createShape(containerShape, false);
      final Image image = gaService.createImage(shape, PluginImage.IMG_STARTEVENT_MESSAGE.getImageKey());
      image.setWidth(20);
      image.setHeight(20);
      gaService.setLocationAndSize(image, (width - 20) / 2, (height - 20) / 2, 20, 20);
    }

    // add a chopbox anchor to the shape
    peCreateService.createChopboxAnchor(containerShape);
    if (!(addedEvent instanceof EndEvent)) {

      // create an additional box relative anchor at middle-right
      final BoxRelativeAnchor boxAnchor = peCreateService.createBoxRelativeAnchor(containerShape);
      boxAnchor.setRelativeWidth(1.0);
      boxAnchor.setRelativeHeight(0.51);
      boxAnchor.setReferencedGraphicsAlgorithm(circle);
      final Ellipse ellipse = ActivitiUiUtil.createInvisibleEllipse(boxAnchor, gaService);
      gaService.setLocationAndSize(ellipse, 0, 0, 0, 0);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.