Package org.eclipse.dd.dc

Examples of org.eclipse.dd.dc.Bounds


                if(!foundAsTopLevel) {
                    for(FlowElement fe : flowElements) {
                        if(fe instanceof SubProcess) {
                            // find the subprocess bounds
                            Bounds subprocessBounds = getBoundsForShape(plane, fe);
                            if(subprocessBounds != null) {
                                updateShapeBoundsInSubprocess(plane, ele, (SubProcess) fe, subprocessBounds.getX(), subprocessBounds.getY());
                            }
                        }
                    }
                }
            }
View Full Code Here


    public void updateShapeBoundsInSubprocess(BPMNPlane plane, BaseElement ele, SubProcess sub, float parentX, float parentY) {
        boolean foundInSubprocess = false;
        for(FlowElement subEle : sub.getFlowElements()) {
            if(subEle.getId().equals(ele.getId())) {
                foundInSubprocess = true;
                Bounds subEleBounds = getBoundsForShape(plane, subEle);
                if(subEleBounds != null) {
                    subEleBounds.setX(subEleBounds.getX() + parentX);
                    subEleBounds.setY(subEleBounds.getY() + parentY);
                }
            }
        }

        if(!foundInSubprocess) {
            for(FlowElement subEle : sub.getFlowElements()) {
                if(subEle instanceof SubProcess) {
                    Bounds subEleBounds = getBoundsForShape(plane, subEle);
                    updateShapeBoundsInSubprocess(plane, ele, (SubProcess) subEle, subEleBounds.getX() + parentX, subEleBounds.getY() + parentY);
                }
            }
        }
    }
View Full Code Here

   
    private void createSubProcessDiagram(BPMNPlane plane, FlowElement flowElement, BpmnDiFactory factory) {
    SubProcess sp = (SubProcess) flowElement;
    for(FlowElement subProcessFlowElement : sp.getFlowElements()) {
      if(subProcessFlowElement instanceof SubProcess) {
        Bounds spb = _bounds.get(subProcessFlowElement.getId());
        if (spb != null) {
          BPMNShape shape = factory.createBPMNShape();
          shape.setBpmnElement(subProcessFlowElement);
          shape.setBounds(spb);
          plane.getPlaneElement().add(shape);
        }
        createSubProcessDiagram(plane, subProcessFlowElement, factory);
      } else if (subProcessFlowElement instanceof FlowNode) {
        Bounds spb = _bounds.get(subProcessFlowElement.getId());
        if (spb != null) {
          BPMNShape shape = factory.createBPMNShape();
          shape.setBpmnElement(subProcessFlowElement);
          shape.setBounds(spb);
          plane.getPlaneElement().add(shape);
        }
      } else if (subProcessFlowElement instanceof SequenceFlow) {
        SequenceFlow sequenceFlow = (SequenceFlow) subProcessFlowElement;
        BPMNEdge edge = factory.createBPMNEdge();
        edge.setBpmnElement(subProcessFlowElement);
        DcFactory dcFactory = DcFactory.eINSTANCE;
        Point point = dcFactory.createPoint();
        if(sequenceFlow.getSourceRef() != null) {
          Bounds sourceBounds = _bounds.get(sequenceFlow.getSourceRef().getId());
          point.setX(sourceBounds.getX() + (sourceBounds.getWidth()/2));
          point.setY(sourceBounds.getY() + (sourceBounds.getHeight()/2));
        }
        edge.getWaypoint().add(point);
        List<Point> dockers = _dockers.get(sequenceFlow.getId());
        for (int i = 1; i < dockers.size() - 1; i++) {
          edge.getWaypoint().add(dockers.get(i));
        }
        point = dcFactory.createPoint();
        if(sequenceFlow.getTargetRef() != null) {
          Bounds targetBounds = _bounds.get(sequenceFlow.getTargetRef().getId());
          point.setX(targetBounds.getX() + (targetBounds.getWidth()/2));
          point.setY(targetBounds.getY() + (targetBounds.getHeight()/2));
        }
        edge.getWaypoint().add(point);
        plane.getPlaneElement().add(edge);
      }
    }
    for (Artifact artifact : sp.getArtifacts()) {
            if (artifact instanceof TextAnnotation || artifact instanceof Group) {
              Bounds ba = _bounds.get(artifact.getId());
              if (ba != null) {
                BPMNShape shape = factory.createBPMNShape();
                shape.setBpmnElement(artifact);
                shape.setBounds(ba);
                plane.getPlaneElement().add(shape);
              }
            }
            if (artifact instanceof Association){
                Association association = (Association)artifact;
                BPMNEdge edge = factory.createBPMNEdge();
                edge.setBpmnElement(association);
                DcFactory dcFactory = DcFactory.eINSTANCE;
                Point point = dcFactory.createPoint();
                Bounds sourceBounds = _bounds.get(association.getSourceRef().getId());
                point.setX(sourceBounds.getX() + (sourceBounds.getWidth()/2));
                point.setY(sourceBounds.getY() + (sourceBounds.getHeight()/2));
                edge.getWaypoint().add(point);
                List<Point> dockers = _dockers.get(association.getId());
                for (int i = 1; i < dockers.size() - 1; i++) {
                        edge.getWaypoint().add(dockers.get(i));
                }
                point = dcFactory.createPoint();
                Bounds targetBounds = _bounds.get(association.getTargetRef().getId());
                point.setX(targetBounds.getX() + (targetBounds.getWidth()/2));
                point.setY(targetBounds.getY() + (targetBounds.getHeight()/2));
                edge.getWaypoint().add(point);
                plane.getPlaneElement().add(edge);
            }
        }
    }
View Full Code Here

            plane.setBpmnElement(process);
            diagram.setPlane(plane);
          // first process flowNodes
            for (FlowElement flowElement: process.getFlowElements()) {
              if (flowElement instanceof FlowNode) {
                Bounds b = _bounds.get(flowElement.getId());
                if (b != null) {
                  BPMNShape shape = factory.createBPMNShape();
                  shape.setBpmnElement(flowElement);
                  shape.setBounds(b);
                  plane.getPlaneElement().add(shape);
                  if(flowElement instanceof BoundaryEvent) {
                    BPMNEdge edge = factory.createBPMNEdge();
                    edge.setBpmnElement(flowElement);
                    List<Point> dockers = _dockers.get(flowElement.getId());
                    DcFactory dcFactory = DcFactory.eINSTANCE;
                    Point addedDocker = dcFactory.createPoint();
                    for (int i = 0; i < dockers.size(); i++) {
                      edge.getWaypoint().add(dockers.get(i));
                      if(i == 0) {
                        addedDocker.setX(dockers.get(i).getX());
                        addedDocker.setY(dockers.get(i).getY());
                      }
                    }
                    if(dockers.size() == 1) {
                      edge.getWaypoint().add(addedDocker);
                    }
                    plane.getPlaneElement().add(edge);
                  }
                }
                // check if its a subprocess
                if(flowElement instanceof SubProcess) {
                  createSubProcessDiagram(plane, flowElement, factory);
                }
              } else if(flowElement instanceof DataObject) {
                Bounds b = _bounds.get(flowElement.getId());
                if (b != null) {
                  BPMNShape shape = factory.createBPMNShape();
                  shape.setBpmnElement(flowElement);
                  shape.setBounds(b);
                  plane.getPlaneElement().add(shape);
                }
              }
              else if (flowElement instanceof SequenceFlow) {
                SequenceFlow sequenceFlow = (SequenceFlow) flowElement;
                BPMNEdge edge = factory.createBPMNEdge();
              edge.setBpmnElement(flowElement);
              DcFactory dcFactory = DcFactory.eINSTANCE;
              Point point = dcFactory.createPoint();
              if(sequenceFlow.getSourceRef() != null) {
                Bounds sourceBounds = _bounds.get(sequenceFlow.getSourceRef().getId());
                point.setX(sourceBounds.getX() + (sourceBounds.getWidth()/2));
                point.setY(sourceBounds.getY() + (sourceBounds.getHeight()/2));
              }
              edge.getWaypoint().add(point);
              List<Point> dockers = _dockers.get(sequenceFlow.getId());
              for (int i = 1; i < dockers.size() - 1; i++) {
                edge.getWaypoint().add(dockers.get(i));
              }
              point = dcFactory.createPoint();
              if(sequenceFlow.getTargetRef() != null) {
                Bounds targetBounds = _bounds.get(sequenceFlow.getTargetRef().getId());
                point.setX(targetBounds.getX() + (targetBounds.getWidth()/2));
                point.setY(targetBounds.getY() + (targetBounds.getHeight()/2));
              }
              edge.getWaypoint().add(point);
              plane.getPlaneElement().add(edge);
              }
            }
            // artifacts
                if (process.getArtifacts() != null){
                    for (Artifact artifact : process.getArtifacts()) {
                        if (artifact instanceof TextAnnotation || artifact instanceof Group) {
                          Bounds b = _bounds.get(artifact.getId());
                          if (b != null) {
                            BPMNShape shape = factory.createBPMNShape();
                            shape.setBpmnElement(artifact);
                            shape.setBounds(b);
                            plane.getPlaneElement().add(shape);
                          }
                        }
                        if (artifact instanceof Association){
                            Association association = (Association)artifact;
                            BPMNEdge edge = factory.createBPMNEdge();
                            edge.setBpmnElement(association);
                            DcFactory dcFactory = DcFactory.eINSTANCE;
                            Point point = dcFactory.createPoint();
                            Bounds sourceBounds = _bounds.get(association.getSourceRef().getId());
                            point.setX(sourceBounds.getX() + (sourceBounds.getWidth()/2));
                            point.setY(sourceBounds.getY() + (sourceBounds.getHeight()/2));
                            edge.getWaypoint().add(point);
                            List<Point> dockers = _dockers.get(association.getId());
                            for (int i = 1; i < dockers.size() - 1; i++) {
                                    edge.getWaypoint().add(dockers.get(i));
                            }
                            point = dcFactory.createPoint();
                            Bounds targetBounds = _bounds.get(association.getTargetRef().getId());
                            point.setX(targetBounds.getX()); // TODO check
                            point.setY(targetBounds.getY() + (targetBounds.getHeight()/2));
                            edge.getWaypoint().add(point);
                            plane.getPlaneElement().add(edge);
                        }
                    }
                }
            // lanes
            if(process.getLaneSets() != null && process.getLaneSets().size() > 0) {
              for(LaneSet ls : process.getLaneSets()) {
                for(Lane lane : ls.getLanes()) {
                  Bounds b = _bounds.get(lane.getId());
                    if (b != null) {
                      BPMNShape shape = factory.createBPMNShape();
                      shape.setBpmnElement(lane);
                      shape.setBounds(b);
                      plane.getPlaneElement().add(shape);
View Full Code Here

            }
          }
        }
       
        BPMNShape shape = (BPMNShape) findDiagramElement(plane, node);
        Bounds bounds = shape.getBounds();
        correctEventNodeSize(shape);
        generator.writeObjectFieldStart("bounds");
        generator.writeObjectFieldStart("lowerRight");
        generator.writeObjectField("x", bounds.getX() + bounds.getWidth() - xOffset);
        generator.writeObjectField("y", bounds.getY() + bounds.getHeight() - yOffset);
        generator.writeEndObject();
        generator.writeObjectFieldStart("upperLeft");
        generator.writeObjectField("x", bounds.getX() - xOffset);
        generator.writeObjectField("y", bounds.getY() - yOffset);
        generator.writeEndObject();
        generator.writeEndObject();
    }
View Full Code Here

    }
   
    private void correctEventNodeSize(BPMNShape shape) {
      BaseElement element = shape.getBpmnElement();
    if (element instanceof Event) {
      Bounds bounds = shape.getBounds();
      float width = bounds.getWidth();
      float height = bounds.getHeight();
      if (width != 30 || height != 30) {
        bounds.setWidth(30);
        bounds.setHeight(30);
        float x = bounds.getX();
        float y = bounds.getY();
          x = x - ((30 - width)/2);
          y = y - ((30 - height)/2);
        bounds.setX(x);
        bounds.setY(y);
      }
    } else if (element instanceof Gateway) {
      Bounds bounds = shape.getBounds();
      float width = bounds.getWidth();
      float height = bounds.getHeight();
      if (width != 40 || height != 40) {
        bounds.setWidth(40);
        bounds.setHeight(40);
        float x = bounds.getX();
        float y = bounds.getY();
          x = x - ((40 - width)/2);
          y = y - ((40 - height)/2);
        bounds.setX(x);
        bounds.setY(y);
      }
      }
    }
View Full Code Here

            }
        }

      generator.writeEndArray();
     
      Bounds bounds = ((BPMNShape) findDiagramElement(plane, dataObject)).getBounds();
      generator.writeObjectFieldStart("bounds");
      generator.writeObjectFieldStart("lowerRight");
      generator.writeObjectField("x", bounds.getX() + bounds.getWidth() - xOffset);
      generator.writeObjectField("y", bounds.getY() + bounds.getHeight() - yOffset);
      generator.writeEndObject();
      generator.writeObjectFieldStart("upperLeft");
      generator.writeObjectField("x", bounds.getX() - xOffset);
      generator.writeObjectField("y", bounds.getY() - yOffset);
      generator.writeEndObject();
      generator.writeEndObject();
  }
View Full Code Here

                }
            }
      }
      generator.writeEndObject();
      generator.writeArrayFieldStart("childShapes");
      Bounds bounds = ((BPMNShape) findDiagramElement(plane, subProcess)).getBounds();
      for (FlowElement flowElement: subProcess.getFlowElements()) {
        // dont want to set the offset
        marshallFlowElement(flowElement, plane, generator, 0, 0, preProcessingData, def);
      }
      for (Artifact artifact: subProcess.getArtifacts()) {
        marshallArtifact(artifact, plane, generator, 0, 0, preProcessingData, def);
      }
      generator.writeEndArray();
      generator.writeArrayFieldStart("outgoing");
      for (BoundaryEvent boundaryEvent: subProcess.getBoundaryEventRefs()) {
          generator.writeStartObject();
          generator.writeObjectField("resourceId", boundaryEvent.getId());
          generator.writeEndObject();
        }
      for (SequenceFlow outgoing: subProcess.getOutgoing()) {
          generator.writeStartObject();
          generator.writeObjectField("resourceId", outgoing.getId());
          generator.writeEndObject();
        }
      // subprocess boundary events
      Process process = (Process) plane.getBpmnElement();
        for(FlowElement fe : process.getFlowElements()) {
          if(fe instanceof BoundaryEvent) {
            if(((BoundaryEvent) fe).getAttachedToRef().getId().equals(subProcess.getId())) {
              generator.writeStartObject();
                    generator.writeObjectField("resourceId", fe.getId());
                    generator.writeEndObject();
            }
          }
        }
      generator.writeEndArray();
     
      generator.writeObjectFieldStart("bounds");
      generator.writeObjectFieldStart("lowerRight");
      generator.writeObjectField("x", bounds.getX() + bounds.getWidth() - xOffset);
      generator.writeObjectField("y", bounds.getY() + bounds.getHeight() - yOffset);
      generator.writeEndObject();
      generator.writeObjectFieldStart("upperLeft");
      generator.writeObjectField("x", bounds.getX() - xOffset);
      generator.writeObjectField("y", bounds.getY() - yOffset);
      generator.writeEndObject();
      generator.writeEndObject();
  }
View Full Code Here

        generator.writeStartObject();
        generator.writeObjectField("resourceId", sequenceFlow.getTargetRef().getId());
        generator.writeEndObject();
        generator.writeEndArray();
       
        Bounds sourceBounds = ((BPMNShape) findDiagramElement(plane, sequenceFlow.getSourceRef())).getBounds();
        Bounds targetBounds = ((BPMNShape) findDiagramElement(plane, sequenceFlow.getTargetRef())).getBounds();
        generator.writeArrayFieldStart("dockers");
        generator.writeStartObject();
        generator.writeObjectField("x", sourceBounds.getWidth() / 2);
        generator.writeObjectField("y", sourceBounds.getHeight() / 2);
        generator.writeEndObject();
        List<Point> waypoints = ((BPMNEdge) findDiagramElement(plane, sequenceFlow)).getWaypoint();
        for (int i = 1; i < waypoints.size() - 1; i++) {
          Point waypoint = waypoints.get(i);
            generator.writeStartObject();
            generator.writeObjectField("x", waypoint.getX());
            generator.writeObjectField("y", waypoint.getY());
            generator.writeEndObject();
        }
        generator.writeStartObject();
        generator.writeObjectField("x", targetBounds.getWidth() / 2);
        generator.writeObjectField("y", targetBounds.getHeight() / 2);
        generator.writeEndObject();
        generator.writeEndArray();
    }
View Full Code Here

        generator.writeStartObject();
        generator.writeObjectField("resourceId", association.getTargetRef().getId());
        generator.writeEndObject();
        generator.writeEndArray();
       
        Bounds sourceBounds = ((BPMNShape) findDiagramElement(plane, association.getSourceRef())).getBounds();

        Bounds targetBounds = null;
        float tbx = 0;
        float tby = 0;
        if(findDiagramElement(plane, association.getTargetRef()) instanceof BPMNShape) {
            targetBounds = ((BPMNShape) findDiagramElement(plane, association.getTargetRef())).getBounds();
        } else if(findDiagramElement(plane, association.getTargetRef()) instanceof BPMNEdge) {
            // connect it to first waypoint on edge
            List<Point> waypoints = ((BPMNEdge) findDiagramElement(plane, association.getTargetRef())).getWaypoint();
            if(waypoints != null && waypoints.size() > 0) {
                tbx = waypoints.get(0).getX();
                tby = waypoints.get(0).getY();
            }

        }
        generator.writeArrayFieldStart("dockers");
        generator.writeStartObject();
        generator.writeObjectField("x", sourceBounds.getWidth() / 2);
        generator.writeObjectField("y", sourceBounds.getHeight() / 2);
        generator.writeEndObject();
        List<Point> waypoints = ((BPMNEdge) findDiagramElement(plane, association)).getWaypoint();
        for (int i = 1; i < waypoints.size() - 1; i++) {
          Point waypoint = waypoints.get(i);
            generator.writeStartObject();
            generator.writeObjectField("x", waypoint.getX());
            generator.writeObjectField("y", waypoint.getY());
            generator.writeEndObject();
        }
        if(targetBounds != null) {
            generator.writeStartObject();
            generator.writeObjectField("x", targetBounds.getWidth() / 2);
            generator.writeObjectField("y", targetBounds.getHeight() / 2);
            generator.writeEndObject();
            generator.writeEndArray();
        } else {
            generator.writeStartObject();
            generator.writeObjectField("x", tbx);
View Full Code Here

TOP

Related Classes of org.eclipse.dd.dc.Bounds

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.