Package org.eclipse.graphiti.mm.pictograms

Examples of org.eclipse.graphiti.mm.pictograms.Anchor


  /**
   * Connects two DISPEL elements.
   */
  public Connection create(ICreateConnectionContext context) {

    Anchor sAnchor = context.getSourceAnchor();
   
    //Move the source anchor to CI if we have a literal
    Object o = getBusinessObjectForPictogramElement(sAnchor.getParent());
    if (Utility.isObjectLiteral(o)) {
      PictogramElement pe = getFeatureProvider(
          ).getPictogramElementForBusinessObject(
              Utility.getParentLocalVariableStatement(
                  (EObject) o));
      if (pe instanceof AnchorContainer) {
        sAnchor = ((AnchorContainer) pe).getAnchors().get(0);
      }
    }
   
    Anchor tAnchor = context.getTargetAnchor();
   
    ConnectionStatement cs = createAndAddConnectionStatement(
        sAnchor, tAnchor);

    // add connection for business object
View Full Code Here


  public static Anchor getAnchor(PictogramElement element) {
    if (element instanceof AnchorContainer) {
      AnchorContainer container = (AnchorContainer) element;
      EList<Anchor> anchors = container.getAnchors();
      if (anchors != null && anchors.size() > 0) {
        Anchor answer = anchors.get(0);
        return answer;
      }
    }
    return null;
  }
View Full Code Here

    // 3.a. create new CreateConnectionContext
    {
      CreateConnectionContext ccc = new CreateConnectionContext();
      ccc.setSourcePictogramElement(pe);
      Anchor anchor = null;
      if (pe instanceof Anchor) {
        anchor = (Anchor) pe;
      } else if (pe instanceof AnchorContainer) {
        // assume, that our shapes always have chopbox anchors
        anchor = Graphiti.getPeService().getChopboxAnchor((AnchorContainer) pe);
View Full Code Here

        if (srcState == destState) {
          Activator.getLogger().debug("Should not be the same element for different nodes: " + route + " and " + node);
        }
        connectContext.setSourcePictogramElement(srcState);
        connectContext.setTargetPictogramElement(destState);
        Anchor srcAnchor = DiagramUtils.getAnchor(srcState);
        Anchor destAnchor = DiagramUtils.getAnchor(destState);
        if (srcAnchor != null && destAnchor != null) {
          connectContext.setSourceAnchor(srcAnchor);
          connectContext.setTargetAnchor(destAnchor);
          if (createFeature.canCreate(connectContext)) {
            createFeature.execute(connectContext);
View Full Code Here

      if (srcState == destState) {
        Activator.getLogger().warning("Should not be the same element for different nodes: " + context.getPictogramElements()[0].getLink().getBusinessObjects().get(0) + " and " + node);
      }
      connectContext.setSourcePictogramElement(srcState);
      connectContext.setTargetPictogramElement(destState);
      Anchor srcAnchor = DiagramUtils.getAnchor(srcState);
      Anchor destAnchor = DiagramUtils.getAnchor(destState);
      if (destAnchor != null) {
        connectContext.setSourceAnchor(srcAnchor);
        connectContext.setTargetAnchor(destAnchor);
        if (createFeature.canCreate(connectContext)) {
          createFeature.execute(connectContext);
View Full Code Here

  public static Map<AnchorLocation, BoundaryAnchor> getBoundaryAnchors(Shape s) {
    Map<AnchorLocation, BoundaryAnchor> map = new HashMap<AnchorLocation, AnchorUtil.BoundaryAnchor>(4);
    Iterator<Anchor> iterator = s.getAnchors().iterator();
    while (iterator.hasNext()) {
      Anchor anchor = iterator.next();
      String property = Graphiti.getPeService().getPropertyValue(anchor, BOUNDARY_FIXPOINT_ANCHOR);
      if (property != null && anchor instanceof FixPointAnchor) {
        BoundaryAnchor a = new BoundaryAnchor();
        a.anchor = (FixPointAnchor) anchor;
        a.locationType = AnchorLocation.getLocation(property);
View Full Code Here

  private static void deleteEmptyAdHocAnchors(Shape s) {
    List<Integer> indexes = new ArrayList<Integer>();

    for (int i = s.getAnchors().size()-1; i>=0; --i) {
      Anchor a = s.getAnchors().get(i);
      if (!(a instanceof FixPointAnchor)) {
        continue;
      }

      if (peService.getProperty(a, BOUNDARY_FIXPOINT_ANCHOR) == null && a.getIncomingConnections().isEmpty()
          && a.getOutgoingConnections().isEmpty()) {
        indexes.add(i);
      }
    }

    for (int i : indexes) {
View Full Code Here

  @SuppressWarnings("unchecked")
  public PictogramElement add(IAddContext context) {
    IAddConnectionContext addConContext = (IAddConnectionContext) context;
    SequenceFlow addedSequenceFlow = (SequenceFlow) context.getNewObject();
   
    Anchor sourceAnchor = null;
    Anchor targetAnchor = null;
    if(addConContext.getSourceAnchor() == null) {
      EList<Shape> shapeList = getDiagram().getChildren();
      for (Shape shape : shapeList) {
        FlowNode flowNode = (FlowNode) getBusinessObjectForPictogramElement(shape.getGraphicsAlgorithm().getPictogramElement());
        if(flowNode == null || flowNode.getId() == null || addedSequenceFlow.getSourceRef() == null ||
                addedSequenceFlow.getTargetRef() == null) continue;
        if(flowNode.getId().equals(addedSequenceFlow.getSourceRef())) {
          EList<Anchor> anchorList = ((ContainerShape) shape).getAnchors();
          for (Anchor anchor : anchorList) {
            if(anchor instanceof ChopboxAnchor) {
              sourceAnchor = anchor;
              break;
            }
          }
        }
       
        if(flowNode.getId().equals(addedSequenceFlow.getTargetRef())) {
          EList<Anchor> anchorList = ((ContainerShape) shape).getAnchors();
          for (Anchor anchor : anchorList) {
            if(anchor instanceof ChopboxAnchor) {
              targetAnchor = anchor;
              break;
            }
          }
        }
      }
    } else {
      sourceAnchor = addConContext.getSourceAnchor();
      targetAnchor = addConContext.getTargetAnchor();
    }
   
    if(sourceAnchor == null || targetAnchor == null) {
      return null;
    }

    IPeCreateService peCreateService = Graphiti.getPeCreateService();
    // CONNECTION WITH POLYLINE
    FreeFormConnection connection = peCreateService.createFreeFormConnection(getDiagram());
    connection.setStart(sourceAnchor);
    connection.setEnd(targetAnchor);
    sourceAnchor.getOutgoingConnections().add(connection);
    targetAnchor.getIncomingConnections().add(connection);

    Bpmn2MemoryModel model = ModelHandler.getModel(EcoreUtil.getURI(getDiagram()));
   
    FlowElement sourceElement = model.getFlowElement(addedSequenceFlow.getSourceRef());
    FlowElement targetElement = model.getFlowElement(addedSequenceFlow.getTargetRef());
View Full Code Here

    return canCreate;
  }

  @Override
  public Connection create(ICreateConnectionContext context) {
    final Anchor sourceAnchor = context.getSourceAnchor();
    final Anchor targetAnchor = context.getTargetAnchor();
   
    final BaseElement sourceBo = getBaseElement(sourceAnchor)
    final BaseElement targetBo = getBaseElement(targetAnchor);
   
    if (sourceBo == null || targetBo == null) {
View Full Code Here

      }
    }
  }

  private void drawSequenceFlow(SequenceFlow sequenceFlow, Bpmn2MemoryModel model) {
    Anchor sourceAnchor = null;
    Anchor targetAnchor = null;
    ContainerShape sourceShape = (ContainerShape) getDiagramTypeProvider().getFeatureProvider().getPictogramElementForBusinessObject(
            model.getFlowElement(sequenceFlow.getSourceRef()));

    if (sourceShape == null) {
      return;
View Full Code Here

TOP

Related Classes of org.eclipse.graphiti.mm.pictograms.Anchor

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.