Package org.eclipse.dd.dc

Examples of org.eclipse.dd.dc.Bounds


        generator.writeObjectField("resourceId", findOutgoingAssociation(plane, textAnnotation).getId());
        generator.writeEndObject();
      }
      generator.writeEndArray();
   
      Bounds bounds = ((BPMNShape) findDiagramElement(plane, textAnnotation)).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.writeObjectField("resourceId", findOutgoingAssociation(plane, group).getId());
        generator.writeEndObject();
      }
      generator.writeEndArray();
   
      Bounds bounds = ((BPMNShape) findDiagramElement(plane, group)).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

            XMLInputFactory factory = XMLInputFactory.newInstance();
            XMLStreamReader reader = factory.createXMLStreamReader(new StringReader(gpd));
            while(reader.hasNext()) {
                if (reader.next() == XMLStreamReader.START_ELEMENT) {
                    if ("node".equals(reader.getLocalName())) {
                        Bounds b = DcFactory.eINSTANCE.createBounds();
                        String nodeName = null;
                        String nodeX = null;
                        String nodeY = null;
                        String nodeWidth = null;
                        String nodeHeight = null;
                        for (int i = 0 ; i < reader.getAttributeCount() ; i++) {
                            if ("name".equals(reader.getAttributeLocalName(i))) {
                                nodeName = reader.getAttributeValue(i);
                            } else if("x".equals(reader.getAttributeLocalName(i))) {
                                nodeX = reader.getAttributeValue(i);
                            } else if("y".equals(reader.getAttributeLocalName(i))) {
                                nodeY = reader.getAttributeValue(i);
                            } else if("width".equals(reader.getAttributeLocalName(i))) {
                                nodeWidth = reader.getAttributeValue(i);
                            } else if("height".equals(reader.getAttributeLocalName(i))) {
                                nodeHeight = reader.getAttributeValue(i);
                            }
                        }
                        b.setX(new Float(nodeX).floatValue());
                        b.setY(new Float(nodeY).floatValue());
                        b.setWidth(new Float(nodeWidth).floatValue());
                        b.setHeight(new Float(nodeHeight).floatValue());
                        _bounds.put(nodeName, b);
                    }
                }
            }

            for (RootElement rootElement: def.getRootElements()) {
                if (rootElement instanceof Process) {
                    Process process = (Process) rootElement;
                    BpmnDiFactory diFactory = BpmnDiFactory.eINSTANCE;
                    BPMNDiagram diagram = diFactory.createBPMNDiagram();
                    BPMNPlane plane = diFactory.createBPMNPlane();
                    plane.setBpmnElement(process);
                    diagram.setPlane(plane);
                    for (FlowElement flowElement: process.getFlowElements()) {
                        if (flowElement instanceof FlowNode) {
                            Bounds b = _bounds.get(flowElement.getId());
                            if (b != null) {
                                BPMNShape shape = diFactory.createBPMNShape();
                                shape.setBpmnElement(flowElement);
                                shape.setBounds(b);
                                plane.getPlaneElement().add(shape);
                            }
                        } else if (flowElement instanceof SequenceFlow) {
                            SequenceFlow sequenceFlow = (SequenceFlow) flowElement;
                            BPMNEdge edge = diFactory.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);
                        }
                    }
View Full Code Here

                parser.nextToken();
                parser.nextToken();
                Integer y1 = parser.getIntValue();
                parser.nextToken();
                parser.nextToken();
                Bounds b = DcFactory.eINSTANCE.createBounds();
                b.setX(x1);
                b.setY(y1);
                b.setWidth(x2 - x1);
                b.setHeight(y2 - y1);
                this._bounds.put(resourceId, b);
            } else if ("dockers".equals(fieldname)) {
                // "dockers":[{"x":50,"y":40},{"x":353.5,"y":115},{"x":353.5,"y":152},{"x":50,"y":40}],
              List<Point> dockers = new ArrayList<Point>();
              JsonToken nextToken = parser.nextToken();
View Full Code Here

           
        }
    }
   
    private List<String> marshallLanes(Lane lane, BPMNPlane plane, JsonGenerator generator, int xOffset, int yOffset, String preProcessingData, Definitions def) throws JsonGenerationException, IOException {
      Bounds bounds = ((BPMNShape) findDiagramElement(plane, lane)).getBounds();
      List<String> nodeRefIds = new ArrayList<String>();
      if(bounds != null) {
        generator.writeStartObject();
        generator.writeObjectField("resourceId", lane.getId());
        Map<String, Object> laneProperties = new LinkedHashMap<String, Object>();
        if(lane.getName() != null) {
          laneProperties.put("name", unescapeXML(lane.getName()));
        } else {
          laneProperties.put("name", "");
        }
       
        Iterator<FeatureMap.Entry> iter = lane.getAnyAttribute().iterator();
        boolean foundBgColor = false;
        boolean foundBrColor = false;
        boolean foundFontColor = false;
        boolean foundSelectable = false;
          while(iter.hasNext()) {
              FeatureMap.Entry entry = iter.next();
              if(entry.getEStructuralFeature().getName().equals("background-color")) {
                laneProperties.put("bgcolor", entry.getValue());
                foundBgColor = true;
              }
              if(entry.getEStructuralFeature().getName().equals("border-color")) {
                laneProperties.put("bordercolor", entry.getValue());
                foundBrColor = true;
              }
              if(entry.getEStructuralFeature().getName().equals("fontsize")) {
                laneProperties.put("fontsize", entry.getValue());
                foundBrColor = true;
              }
              if(entry.getEStructuralFeature().getName().equals("color")) {
                laneProperties.put("fontcolor", entry.getValue());
                foundFontColor = true;
              }
              if(entry.getEStructuralFeature().getName().equals("selectable")) {
                laneProperties.put("isselectable", entry.getValue());
                foundSelectable = true;
              }
          }
          if(!foundBgColor) {
            laneProperties.put("bgcolor", defaultBgColor_Swimlanes);
          }
         
          if(!foundBrColor) {
            laneProperties.put("bordercolor", defaultBrColor);
          }
         
          if(!foundFontColor) {
            laneProperties.put("fontcolor", defaultFontColor);
          }
         
          if(!foundSelectable) {
            laneProperties.put("isselectable", "true");
          }
       
        marshallProperties(laneProperties, generator);
        generator.writeObjectFieldStart("stencil");
        generator.writeObjectField("id", "Lane");
        generator.writeEndObject();
        generator.writeArrayFieldStart("childShapes");
        for (FlowElement flowElement: lane.getFlowNodeRefs()) {
          nodeRefIds.add(flowElement.getId());
          // we dont want an offset here!
          marshallFlowElement(flowElement, plane, generator, 0, 0, preProcessingData, def);
        }
        generator.writeEndArray();
        generator.writeArrayFieldStart("outgoing");
        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();
        generator.writeEndObject();
      } else {
        // dont marshall the lane unless it has BPMNDI info (eclipse editor does not generate it for lanes currently.
View Full Code Here

     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    public NotificationChain basicSetBounds(Bounds newBounds, NotificationChain msgs) {
        Bounds oldBounds = bounds;
        bounds = newBounds;
        if (eNotificationRequired()) {
            ENotificationImpl notification = new ENotificationImpl(this, Notification.SET,
                    DiPackage.SHAPE__BOUNDS, oldBounds, newBounds);
            if (msgs == null)
View Full Code Here

     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    public NotificationChain basicSetBounds(Bounds newBounds, NotificationChain msgs) {
        Bounds oldBounds = bounds;
        bounds = newBounds;
        if (eNotificationRequired()) {
            ENotificationImpl notification = new ENotificationImpl(this, Notification.SET,
                    DiPackage.LABEL__BOUNDS, oldBounds, newBounds);
            if (msgs == null)
View Full Code Here

            if (result == null)
                result = defaultCase(theEObject);
            return result;
        }
        case DcPackage.BOUNDS: {
            Bounds bounds = (Bounds) theEObject;
            T result = caseBounds(bounds);
            if (result == null)
                result = defaultCase(theEObject);
            return result;
        }
View Full Code Here

   * @param shapesArrayNode
   * @param x
   * @param y
   */
  public void addLaneElements(Lane lane,Process mainProcess,List<FlowElement> laneFlowElements,Definitions model,ArrayNode shapesArrayNode,double x,double y){
    Bounds laneGraphicInfo =BpmnModelUtil.getBpmnShape(model, lane.getId()).getBounds();
      ObjectNode laneNode = BpmnJsonConverterUtil.createChildShape(lane.getId(), STENCIL_LANE,
          laneGraphicInfo.getX()-x + laneGraphicInfo.getWidth(), laneGraphicInfo.getY()-y + laneGraphicInfo.getHeight(),
          laneGraphicInfo.getX()-x, laneGraphicInfo.getY()-y);
      ObjectNode lanePropertiesNode = objectMapper.createObjectNode();
      lanePropertiesNode.put("parentpool", "");
      lanePropertiesNode.put("parentlane", "");
      lanePropertiesNode.put("showcaption", "true");
      lanePropertiesNode.put("bgcolor", "#FFFFCC");
      lanePropertiesNode.put("bordercolor", "#000000");
      lanePropertiesNode.put(PROPERTY_OVERRIDE_ID, lane.getId());
      lanePropertiesNode.put(PROPERTY_NAME, lane.getName());
     
      laneNode.put(EDITOR_SHAPE_PROPERTIES, lanePropertiesNode);
      ArrayNode dockArrayNode = objectMapper.createArrayNode();
      laneNode.put("dockers", dockArrayNode);
      laneNode.put("outgoing", dockArrayNode);
      shapesArrayNode.add(laneNode);
      ArrayNode elementShapesArrayNode = objectMapper.createArrayNode();
      laneNode.put(EDITOR_CHILD_SHAPES, elementShapesArrayNode);
     
      for (FlowElement flowElement : mainProcess.getFlowElements()) {
        if (lane.getFlowNodeRefs().contains(flowElement)) {
          Class<? extends BaseBpmnJsonConverter> converter = convertersToJsonMap.get(flowElement.getClass());
          if (converter != null) {
            try {
              converter.newInstance().convertToJson(flowElement, this, model, elementShapesArrayNode,
                  laneGraphicInfo.getX(), laneGraphicInfo.getY());
              laneFlowElements.add(flowElement);
            } catch (Exception e) {
              LOGGER.error("Error converting {}", flowElement, e);
            }
          }
        }
      }
      if(lane.getChildLaneSet() != null){
        for(Lane tmpLane :lane.getChildLaneSet().getLanes()){
          addLaneElements(tmpLane,mainProcess,laneFlowElements,model,elementShapesArrayNode,laneGraphicInfo.getX(),laneGraphicInfo.getY());
        }
      }
  }
View Full Code Here

       
        String stencilId = BpmnJsonConverterUtil.getStencilId(jsonChildNode);
        if (STENCIL_SEQUENCE_FLOW.equals(stencilId) == false) {
         
          String elementId = BpmnJsonConverterUtil.getElementId(jsonChildNode);
        Bounds graphicInfo=DcFactory.eINSTANCE.createBounds();
        BPMNShape bpmnShape=BpmnDiFactory.eINSTANCE.createBPMNShape();
        bpmnShape.setBounds(graphicInfo);
        bpmnShape.setId(BpmnJsonConverterUtil.getFormatShapeId(elementId));
          JsonNode boundsNode = jsonChildNode.get(EDITOR_BOUNDS);
          ObjectNode upperLeftNode = (ObjectNode) boundsNode.get(EDITOR_BOUNDS_UPPER_LEFT);
          double upLeftX = upperLeftNode.get(EDITOR_BOUNDS_X).asDouble();
          double upLeftY = upperLeftNode.get(EDITOR_BOUNDS_Y).asDouble();
          //坐标修正
          if(DI_CIRCLES.contains(stencilId)){
            upLeftX -= REVERSION_X;
            upLeftY -= REVERSION_Y;
          }
          graphicInfo.setX((float)(upLeftX + parentX ));
          graphicInfo.setY((float)(upLeftY + parentY ));
         
          ObjectNode lowerRightNode = (ObjectNode) boundsNode.get(EDITOR_BOUNDS_LOWER_RIGHT);
          graphicInfo.setWidth((float)(lowerRightNode.get(EDITOR_BOUNDS_X).asDouble() - graphicInfo.getX() + parentX));
          graphicInfo.setHeight((float)(lowerRightNode.get(EDITOR_BOUNDS_Y).asDouble() - graphicInfo.getY() + parentY));
         
          String childShapeId = jsonChildNode.get(EDITOR_SHAPE_ID).asText();
         
          //bpmnShape.setBpmnElement(BpmnModelUtil.getBaseElement(bpmnModel, BpmnJsonConverterUtil.getElementId(jsonChildNode)));
          //这里注释掉的以后需要实现 bpmnModel.addGraphicInfo(BpmnJsonConverterUtil.getElementId(jsonChildNode), graphicInfo);
          bpmnModel.getDiagrams().get(0).getPlane().getPlaneElement().add(bpmnShape);
          shapeMap.put(childShapeId, jsonChildNode);
         
          ArrayNode outgoingNode = (ArrayNode) jsonChildNode.get("outgoing");
          if (outgoingNode != null && outgoingNode.size() > 0) {
            for (JsonNode outgoingChildNode : outgoingNode) {
              JsonNode resourceNode = outgoingChildNode.get(EDITOR_SHAPE_ID);
              if (resourceNode != null) {
                sourceRefMap.put(resourceNode.asText(), jsonChildNode);
              }
            }
          }
         
          readShapeDI(jsonChildNode, graphicInfo.getX(), graphicInfo.getY(), shapeMap, sourceRefMap, bpmnModel);
        }
      }
    }
  }
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.