Java Code Examples for org.activiti.bpmn.model.BpmnModel#addGraphicInfo()

The following examples show how to use org.activiti.bpmn.model.BpmnModel#addGraphicInfo() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BpmnShapeParser.java    From activiti6-boot2 with Apache License 2.0 6 votes vote down vote up
public void parse(XMLStreamReader xtr, BpmnModel model) throws Exception {

    String id = xtr.getAttributeValue(null, ATTRIBUTE_DI_BPMNELEMENT);
    GraphicInfo graphicInfo = new GraphicInfo();

    String strIsExpanded = xtr.getAttributeValue(null, ATTRIBUTE_DI_IS_EXPANDED);
    if ("true".equalsIgnoreCase(strIsExpanded)) {
      graphicInfo.setExpanded(true);
    }

    BpmnXMLUtil.addXMLLocation(graphicInfo, xtr);
    while (xtr.hasNext()) {
      xtr.next();
      if (xtr.isStartElement() && ELEMENT_DI_BOUNDS.equalsIgnoreCase(xtr.getLocalName())) {
        graphicInfo.setX(Double.valueOf(xtr.getAttributeValue(null, ATTRIBUTE_DI_X)));
        graphicInfo.setY(Double.valueOf(xtr.getAttributeValue(null, ATTRIBUTE_DI_Y)));
        graphicInfo.setWidth(Double.valueOf(xtr.getAttributeValue(null, ATTRIBUTE_DI_WIDTH)));
        graphicInfo.setHeight(Double.valueOf(xtr.getAttributeValue(null, ATTRIBUTE_DI_HEIGHT)));

        model.addGraphicInfo(id, graphicInfo);
        break;
      } else if (xtr.isEndElement() && ELEMENT_DI_SHAPE.equalsIgnoreCase(xtr.getLocalName())) {
        break;
      }
    }
  }
 
Example 2
Source File: BpmnJsonConverter.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
private void readShapeDI(JsonNode objectNode, double parentX, double parentY, Map<String, JsonNode> shapeMap, Map<String, JsonNode> sourceRefMap, BpmnModel bpmnModel) {

    if (objectNode.get(EDITOR_CHILD_SHAPES) != null) {
      for (JsonNode jsonChildNode : objectNode.get(EDITOR_CHILD_SHAPES)) {

        String stencilId = BpmnJsonConverterUtil.getStencilId(jsonChildNode);
        if (STENCIL_SEQUENCE_FLOW.equals(stencilId) == false) {

          GraphicInfo graphicInfo = new GraphicInfo();

          JsonNode boundsNode = jsonChildNode.get(EDITOR_BOUNDS);
          ObjectNode upperLeftNode = (ObjectNode) boundsNode.get(EDITOR_BOUNDS_UPPER_LEFT);
          graphicInfo.setX(upperLeftNode.get(EDITOR_BOUNDS_X).asDouble() + parentX);
          graphicInfo.setY(upperLeftNode.get(EDITOR_BOUNDS_Y).asDouble() + parentY);

          ObjectNode lowerRightNode = (ObjectNode) boundsNode.get(EDITOR_BOUNDS_LOWER_RIGHT);
          graphicInfo.setWidth(lowerRightNode.get(EDITOR_BOUNDS_X).asDouble() - graphicInfo.getX() + parentX);
          graphicInfo.setHeight(lowerRightNode.get(EDITOR_BOUNDS_Y).asDouble() - graphicInfo.getY() + parentY);

          String childShapeId = jsonChildNode.get(EDITOR_SHAPE_ID).asText();
          bpmnModel.addGraphicInfo(BpmnJsonConverterUtil.getElementId(jsonChildNode), graphicInfo);

          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);
        }
      }
    }
  }
 
Example 3
Source File: BpmnJsonConverter.java    From lemon with Apache License 2.0 4 votes vote down vote up
private void readShapeDI(JsonNode objectNode, double parentX,
        double parentY, Map<String, JsonNode> shapeMap,
        Map<String, JsonNode> sourceRefMap, BpmnModel bpmnModel) {
    if (objectNode.get(EDITOR_CHILD_SHAPES) != null) {
        for (JsonNode jsonChildNode : objectNode.get(EDITOR_CHILD_SHAPES)) {
            String stencilId = BpmnJsonConverterUtil
                    .getStencilId(jsonChildNode);

            if (STENCIL_SEQUENCE_FLOW.equals(stencilId) == false) {
                GraphicInfo graphicInfo = new GraphicInfo();

                JsonNode boundsNode = jsonChildNode.get(EDITOR_BOUNDS);
                ObjectNode upperLeftNode = (ObjectNode) boundsNode
                        .get(EDITOR_BOUNDS_UPPER_LEFT);
                graphicInfo.setX(upperLeftNode.get(EDITOR_BOUNDS_X)
                        .asDouble() + parentX);
                graphicInfo.setY(upperLeftNode.get(EDITOR_BOUNDS_Y)
                        .asDouble() + parentY);

                ObjectNode lowerRightNode = (ObjectNode) boundsNode
                        .get(EDITOR_BOUNDS_LOWER_RIGHT);
                graphicInfo.setWidth(lowerRightNode.get(EDITOR_BOUNDS_X)
                        .asDouble() - graphicInfo.getX() + parentX);
                graphicInfo.setHeight(lowerRightNode.get(EDITOR_BOUNDS_Y)
                        .asDouble() - graphicInfo.getY() + parentY);

                String childShapeId = jsonChildNode.get(EDITOR_SHAPE_ID)
                        .asText();
                bpmnModel.addGraphicInfo(
                        BpmnJsonConverterUtil.getElementId(jsonChildNode),
                        graphicInfo);

                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);
            }
        }
    }
}