Package org.eclipse.graphiti.mm.algorithms

Examples of org.eclipse.graphiti.mm.algorithms.GraphicsAlgorithm


            (int) activityBounds.getWidth(), (int) activityBounds.getHeight());
  }

  public static PositionOnLine getPositionOnLineUsingAbsoluteCoordinates(Shape eventShape, Shape activityShape) {
    IPeService peService = Graphiti.getPeService();
    GraphicsAlgorithm eventGa = eventShape.getGraphicsAlgorithm();
    ILocation eventLoc = peService.getLocationRelativeToDiagram(eventShape);
    GraphicsAlgorithm activityGa = activityShape.getGraphicsAlgorithm();
    ILocation activityLoc = peService.getLocationRelativeToDiagram(activityShape);

    return getPositionOnLine(eventLoc.getX(), eventLoc.getY(), eventGa.getWidth(), eventGa.getHeight(),
            activityLoc.getX(), activityLoc.getY(), activityGa.getWidth(), activityGa.getHeight());
  }
View Full Code Here


    if (isDefault) {
      if (cond != null) {
        peService.deletePictogramElement(cond);
      }
      def = createDefaultConnectionDecorator(connection);
      GraphicsAlgorithm ga = def.getGraphicsAlgorithm();
      ga.setForeground(manageColor(connection,StyleUtil.CLASS_FOREGROUND));
    } else {
      if (def != null) {
        peService.deletePictogramElement(def);
      }
      if (flow.getConditionExpression() != null && flow.getSourceRef() instanceof Activity) {
        cond = createConditionalConnectionDecorator(connection);
        GraphicsAlgorithm ga = cond.getGraphicsAlgorithm();
        ga.setFilled(true);
        ga.setForeground(manageColor(connection,StyleUtil.CLASS_FOREGROUND));
        ga.setBackground(manageColor(connection,IColorConstant.WHITE));
      }
    }

    peService.setPropertyValue(connection, IS_DEFAULT_FLOW_PROPERTY,
        Boolean.toString(isDefault));
View Full Code Here

    ConnectionDecorator def = decorators.getFirst();
    ConnectionDecorator cond = decorators.getSecond();

    if (flow.getConditionExpression() != null && flow.getSourceRef() instanceof Activity && def == null) {
      ConnectionDecorator decorator = createConditionalConnectionDecorator(connection);
      GraphicsAlgorithm ga = decorator.getGraphicsAlgorithm();
      ga.setFilled(true);
      ga.setForeground(manageColor(connection, StyleUtil.CLASS_FOREGROUND));
      ga.setBackground(manageColor(connection, IColorConstant.WHITE));
    } else if (cond != null) {
      peService.deletePictogramElement(cond);
    }

    peService.setPropertyValue(connection, IS_CONDITIONAL_FLOW_PROPERTY,
View Full Code Here

    Object o = getBusinessObjectForPictogramElement(context.getTargetContainer());
    if (o == null || !(o instanceof Activity)) {
      return false;
    }

    GraphicsAlgorithm ga = context.getTargetContainer().getGraphicsAlgorithm();
    return BoundaryEventPositionHelper.canCreateEventAt(context, ga, 10);
  }
View Full Code Here

  @Override
  public boolean layout(ILayoutContext context) {
    boolean layout = false;

    PictogramElement element = context.getPictogramElement();
    GraphicsAlgorithm eventGa = element.getGraphicsAlgorithm();
    BoundaryEvent event = BusinessObjectUtil.getFirstElementOfType(element, BoundaryEvent.class);

    PictogramElement activityContainer = BusinessObjectUtil.getFirstBaseElementFromDiagram(getDiagram(),
            event.getAttachedToRef());
    GraphicsAlgorithm activityGa = activityContainer.getGraphicsAlgorithm();

    PositionOnLine pos = BoundaryEventPositionHelper.getPositionOnLineProperty(element);

    switch (pos.getLineType()) {
    case X:
View Full Code Here

    ContainerShape containerShape = (ContainerShape) context.getPictogramElement();

    Object property = context.getProperty("activity.move");
    if (property != null && (Boolean) property) {
      IGaService gaService = Graphiti.getGaService();
      GraphicsAlgorithm ga = containerShape.getGraphicsAlgorithm();
      gaService.setLocation(ga, ga.getX() + context.getDeltaX(), ga.getY() + context.getDeltaY());
    } else {
      BoundaryEvent event = BusinessObjectUtil.getFirstElementOfType(containerShape, BoundaryEvent.class);
      PictogramElement activityContainer = BusinessObjectUtil.getFirstBaseElementFromDiagram(getDiagram(),
          event.getAttachedToRef());
      PositionOnLine newPos = BoundaryEventPositionHelper.getPositionOnLineUsingAbsoluteCoordinates(
View Full Code Here

    Bpmn2MemoryModel model = ModelHandler.getModel(EcoreUtil.getURI(getDiagram()));
   
    FlowElement sourceElement = model.getFlowElement(addedSequenceFlow.getSourceRef());
    FlowElement targetElement = model.getFlowElement(addedSequenceFlow.getTargetRef());
   
    GraphicsAlgorithm sourceGraphics = getPictogramElement(sourceElement).getGraphicsAlgorithm();
    GraphicsAlgorithm targetGraphics = getPictogramElement(targetElement).getGraphicsAlgorithm();
   
    List<GraphicInfo> bendpointList = null;
    if(addConContext.getProperty("org.activiti.designer.bendpoints") != null) {
      bendpointList = (List<GraphicInfo>) addConContext.getProperty("org.activiti.designer.bendpoints");
    }
   
    if(bendpointList != null && bendpointList.size() >= 0) {
      for (GraphicInfo graphicInfo : bendpointList) {
        Point bendPoint = StylesFactory.eINSTANCE.createPoint();
        bendPoint.setX((int)graphicInfo.getX());
        bendPoint.setY((int)graphicInfo.getY());
        connection.getBendpoints().add(bendPoint);
      }
     
    } else {
     
      Shape sourceShape = (Shape) getPictogramElement(sourceElement);
      ILocation sourceShapeLocation = Graphiti.getLayoutService().getLocationRelativeToDiagram(sourceShape);
      int sourceX = sourceShapeLocation.getX();
      int sourceY = sourceShapeLocation.getY();
     
      Shape targetShape = (Shape) getPictogramElement(targetElement);
      ILocation targetShapeLocation = Graphiti.getLayoutService().getLocationRelativeToDiagram(targetShape);
      int targetX = targetShapeLocation.getX();
      int targetY = targetShapeLocation.getY();
     
      if (sourceElement instanceof Gateway && targetElement instanceof Gateway == false) {
        if (((sourceGraphics.getY() + 10) < targetGraphics.getY()
            || (sourceGraphics.getY() - 10) > targetGraphics.getY())  &&
            (sourceGraphics.getX() + (sourceGraphics.getWidth() / 2)) < targetGraphics.getX()) {
         
          boolean subProcessWithBendPoint = false;
          if(targetElement instanceof SubProcess) {
            int middleSub = targetGraphics.getY() + (targetGraphics.getHeight() / 2);
            if((sourceGraphics.getY() + 20) < middleSub || (sourceGraphics.getY() - 20) > middleSub) {
              subProcessWithBendPoint = true;
            }
          }
         
          if(targetElement instanceof SubProcess == false || subProcessWithBendPoint == true) {
            Point bendPoint = StylesFactory.eINSTANCE.createPoint();
            bendPoint.setX(sourceX + 20);
            bendPoint.setY(targetY + (targetGraphics.getHeight() / 2));
            connection.getBendpoints().add(bendPoint);
          }
        }
      } else if (targetElement instanceof Gateway) {
        if (((sourceGraphics.getY() + 10) < targetGraphics.getY()
            || (sourceGraphics.getY() - 10) > targetGraphics.getY()) &&
            (sourceGraphics.getX() + sourceGraphics.getWidth()) < targetGraphics.getX()) {
         
          boolean subProcessWithBendPoint = false;
          if(sourceElement instanceof SubProcess) {
            int middleSub = sourceGraphics.getY() + (sourceGraphics.getHeight() / 2);
            if((middleSub + 20) < targetGraphics.getY() || (middleSub - 20) > targetGraphics.getY()) {
              subProcessWithBendPoint = true;
            }
          }
         
          if(sourceElement instanceof SubProcess == false || subProcessWithBendPoint == true) {
            Point bendPoint = StylesFactory.eINSTANCE.createPoint();
            bendPoint.setX(targetX + 20);
            bendPoint.setY(sourceY + (sourceGraphics.getHeight() / 2));
            connection.getBendpoints().add(bendPoint);
          }
        }
      } else if (targetElement instanceof EndEvent) {
        int middleSource = sourceGraphics.getY() + (sourceGraphics.getHeight() / 2);
        int middleTarget = targetGraphics.getY() + (targetGraphics.getHeight() / 2);
        if (((middleSource + 10) < middleTarget &&
            (sourceGraphics.getX() + sourceGraphics.getWidth()) < targetGraphics.getX()) ||
           
            ((middleSource - 10) > middleTarget &&
            (sourceGraphics.getX() + sourceGraphics.getWidth()) < targetGraphics.getX())) {
         
          Point bendPoint = StylesFactory.eINSTANCE.createPoint();
          bendPoint.setX(targetX + (targetGraphics.getWidth() / 2));
          bendPoint.setY(sourceY + (sourceGraphics.getHeight() / 2));
          connection.getBendpoints().add(bendPoint);
        }
      }
    }
View Full Code Here

  }

  @Override
  public boolean layout(ILayoutContext context) {
    final ContainerShape containerShape = (ContainerShape) context.getPictogramElement();
    final GraphicsAlgorithm ga = containerShape.getGraphicsAlgorithm();
    final IGaService gaService = Graphiti.getGaService();
   
    boolean changed = false;
   
    if (ga.getWidth() < 100) {
      // we deny anything smaller than 100 pixels width
      ga.setWidth(100);
     
      changed = true;
    }
   
    if (ga.getHeight() < 50) {
      // we deny anything smaller than 50 pixels height
      ga.setHeight(50);
     
      changed = true;
    }
   
    int containerWidth = ga.getWidth();
    int containerHeight = ga.getHeight();
   
    for (final Shape shape : containerShape.getChildren()) {
      final GraphicsAlgorithm shapeGa = shape.getGraphicsAlgorithm();
      final IDimension size = gaService.calculateSize(shapeGa);
     
      if (containerWidth != size.getWidth() && shapeGa instanceof MultiText) {
        gaService.setWidth(shapeGa, containerWidth - 5);
       
View Full Code Here

  }

  @Override
  public void execute(ICustomContext context) {
    Shape element = (Shape) context.getProperty("org.activiti.designer.changetype.pictogram");
    GraphicsAlgorithm elementGraphics = element.getGraphicsAlgorithm();
    int x = elementGraphics.getX();
    int y = elementGraphics.getY();
   
    CreateContext taskContext = new CreateContext();
    ContainerShape targetContainer = (ContainerShape) element.getContainer();
    taskContext.setTargetContainer(targetContainer);
    taskContext.setLocation(x, y);
    taskContext.setHeight(elementGraphics.getHeight());
    taskContext.setWidth(elementGraphics.getWidth());
   
    FlowNode oldObject = (FlowNode) getFeatureProvider().getBusinessObjectForPictogramElement(element);
    if (oldObject instanceof BoundaryEvent) {
      BoundaryEvent boundaryEvent = (BoundaryEvent) oldObject;
      ContainerShape parentShape = (ContainerShape) getFeatureProvider().getPictogramElementForBusinessObject(boundaryEvent.getAttachedToRef());
View Full Code Here

      }
    }

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

    switch (baseShape) {
    case ACTIVITY:
      // check whether the context has a size (e.g. from a create feature)
      // otherwise define a default size for the shape
View Full Code Here

TOP

Related Classes of org.eclipse.graphiti.mm.algorithms.GraphicsAlgorithm

Copyright © 2018 www.massapicom. 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.