protected static GraphicInfo getLineCenter(List<GraphicInfo> graphicInfoList) { GraphicInfo gi = new GraphicInfo(); xPoints[0] = (int) previousGraphicInfo.getX(); yPoints[0] = (int) previousGraphicInfo.getY(); xPoints[i] = (int) graphicInfo.getX(); yPoints[i] = (int) graphicInfo.getY(); Math.pow((int) graphicInfo.getX() - (int) previousGraphicInfo.getX(), 2) + Math.pow((int) graphicInfo.getY() - (int) previousGraphicInfo.getY(), 2) ); GraphicInfo graphicInfo2 = graphicInfoList.get(p2); double AB = (int) graphicInfo2.getX() - (int) graphicInfo1.getX(); double OA = (int) graphicInfo2.getY() - (int) graphicInfo1.getY(); double OB = lengths[p2] - lengths[p1]; double ob = m - lengths[p1]; double mx = graphicInfo1.getX() + ab; double my = graphicInfo1.getY() + oa; gi.setX(mx); gi.setY(my); return gi;
int x = (int) graphicInfo.getX(); int y = (int) graphicInfo.getY(); int width = (int) graphicInfo.getWidth(); int height = (int) graphicInfo.getHeight(); GraphicInfo eventInfo = new GraphicInfo(); eventInfo.setX(x + width * (1 - scale) / 2); eventInfo.setY(y + height * (1 - scale) / 2); eventInfo.setWidth(width * scale); eventInfo.setHeight(height * scale); drawCatchingEvent(null, eventInfo,
private GraphicInfo createGraphicInfo(double x, double y) { GraphicInfo graphicInfo = new GraphicInfo(); graphicInfo.setX(x); graphicInfo.setY(y); return graphicInfo; }
protected GraphicInfo createDiagramInterchangeInformation(FlowElement flowElement, int x, int y, int width, int height) { GraphicInfo graphicInfo = new GraphicInfo(); graphicInfo.setX(x); graphicInfo.setY(y); graphicInfo.setWidth(width); graphicInfo.setHeight(height); graphicInfo.setElement(flowElement); bpmnModel.addGraphicInfo(flowElement.getId(), graphicInfo); return graphicInfo; }
if (!STENCIL_SEQUENCE_FLOW.equals(stencilId)) { GraphicInfo graphicInfo = new GraphicInfo(); graphicInfo.setX(upperLeftNode.get(EDITOR_BOUNDS_X).asDouble() + parentX); graphicInfo.setY(upperLeftNode.get(EDITOR_BOUNDS_Y).asDouble() + parentY); graphicInfo.setWidth(lowerRightNode.get(EDITOR_BOUNDS_X).asDouble() - graphicInfo.getX() + parentX); graphicInfo.setHeight(lowerRightNode.get(EDITOR_BOUNDS_Y).asDouble() - graphicInfo.getY() + parentY); graphicInfo.getX(), graphicInfo.getY(), shapeMap, sourceRefMap,
protected void createDiagramInterchangeInformation(BaseElement element, List<mxPoint> waypoints) { List<GraphicInfo> graphicInfoForWaypoints = new ArrayList<GraphicInfo>(); for (mxPoint waypoint : waypoints) { GraphicInfo graphicInfo = new GraphicInfo(); graphicInfo.setElement(element); graphicInfo.setX(waypoint.getX()); graphicInfo.setY(waypoint.getY()); graphicInfoForWaypoints.add(graphicInfo); } bpmnModel.addFlowGraphicInfoList(element.getId(), graphicInfoForWaypoints); }
public void createBPMNEdge(String key, List<GraphicInfo> graphicList) { FlowElement flowElement = bpmnModel.getFlowElement(key); if (flowElement != null && sequenceFlows.containsKey(key)) { TransitionImpl sequenceFlow = sequenceFlows.get(key); List<Integer> waypoints = new ArrayList<Integer>(); for (GraphicInfo waypointInfo : graphicList) { waypoints.add((int) waypointInfo.getX()); waypoints.add((int) waypointInfo.getY()); } sequenceFlow.setWaypoints(waypoints); } else if (bpmnModel.getArtifact(key) != null) { // it's an association, so nothing to do } else { GraphicInfo graphicInfo = null; if (graphicList != null && graphicList.size() > 0) { graphicInfo = graphicList.get(0); } else { graphicInfo = new GraphicInfo(); } bpmnModel.addProblem("Invalid reference in 'bpmnElement' attribute, sequenceFlow " + key + " not found", graphicInfo); } }
protected void generateActivityDiagramInterchangeElements() { for (String flowElementId : generatedVertices.keySet()) { Object vertex = generatedVertices.get(flowElementId); mxCellState cellState = graph.getView().getState(vertex); GraphicInfo subProcessGraphicInfo = createDiagramInterchangeInformation(handledFlowElements.get(flowElementId), (int) cellState.getX(), (int) cellState.getY(), (int) cellState.getWidth(), (int) cellState.getHeight()); // The DI for the elements of a subprocess are generated without // knowledge of the rest of the graph // So we must translate all it's elements with the x and y of the // subprocess itself if (handledFlowElements.get(flowElementId) instanceof SubProcess) { // Always expanded when auto layouting subProcessGraphicInfo.setExpanded(true); } } }
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; } } }
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); } } } }
protected void convertElementToJson(ObjectNode propertiesNode, BaseElement baseElement) { SubProcess subProcess = (SubProcess) baseElement; propertiesNode.put("activitytype", "Event-Sub-Process"); propertiesNode.put("subprocesstype", "Embedded"); ArrayNode subProcessShapesArrayNode = objectMapper.createArrayNode(); GraphicInfo graphicInfo = model.getGraphicInfo(subProcess.getId()); processor.processFlowElements(subProcess, model, subProcessShapesArrayNode, formKeyMap, decisionTableKeyMap, graphicInfo.getX(), graphicInfo.getY()); flowElementNode.set("childShapes", subProcessShapesArrayNode); }
private GraphicInfo createGraphicInfo(double x, double y) { GraphicInfo graphicInfo = new GraphicInfo(); graphicInfo.setX(x); graphicInfo.setY(y); return graphicInfo; }
protected void createDiagramInterchangeInformation(SequenceFlow sequenceFlow, List<mxPoint> waypoints) { List<GraphicInfo> graphicInfoForWaypoints = new ArrayList<GraphicInfo>(); for (mxPoint waypoint : waypoints) { GraphicInfo graphicInfo = new GraphicInfo(); graphicInfo.setElement(sequenceFlow); graphicInfo.setX(waypoint.getX()); graphicInfo.setY(waypoint.getY()); graphicInfoForWaypoints.add(graphicInfo); } bpmnModel.addFlowGraphicInfoList(sequenceFlow.getId(), graphicInfoForWaypoints); }
public void drawErrorStartEvent(String id, GraphicInfo graphicInfo) { drawNoneStartEvent(id, graphicInfo); int imageX = (int) (graphicInfo.getX() + (graphicInfo.getWidth() / 4)); int imageY = (int) (graphicInfo.getY() + (graphicInfo.getHeight() / 4)); ERROR_THROW_IMAGE.drawIcon(imageX, imageY, ICON_PADDING, g); }
protected void translateNestedSubprocessElements(SubProcess subProcess) { GraphicInfo subProcessGraphicInfo = bpmnModel.getLocationMap().get(subProcess.getId()); double subProcessX = subProcessGraphicInfo.getX(); double subProcessY = subProcessGraphicInfo.getY(); List<SubProcess> nestedSubProcesses = new ArrayList<SubProcess>(); for (FlowElement flowElement : subProcess.getFlowElements()) { if (flowElement instanceof SequenceFlow) { List<GraphicInfo> graphicInfos = bpmnModel.getFlowLocationMap().get(flowElement.getId()); for (GraphicInfo graphicInfo : graphicInfos) { graphicInfo.setX(graphicInfo.getX() + subProcessX + subProcessMargin); graphicInfo.setY(graphicInfo.getY() + subProcessY + subProcessMargin); } } else if (flowElement instanceof DataObject == false) { // Regular element GraphicInfo graphicInfo = bpmnModel.getLocationMap().get(flowElement.getId()); graphicInfo.setX(graphicInfo.getX() + subProcessX + subProcessMargin); graphicInfo.setY(graphicInfo.getY() + subProcessY + subProcessMargin); } if (flowElement instanceof SubProcess) { nestedSubProcesses.add((SubProcess) flowElement); } } // Continue for next level of nested subprocesses for (SubProcess nestedSubProcess : nestedSubProcesses) { translateNestedSubprocessElements(nestedSubProcess); } }
xtr.next(); if (xtr.isStartElement() && ELEMENT_DI_BOUNDS.equalsIgnoreCase(xtr.getLocalName())) { GraphicInfo graphicInfo = new GraphicInfo(); BpmnXMLUtil.addXMLLocation(graphicInfo, xtr); graphicInfo.setX(Double.valueOf(xtr.getAttributeValue(null, ATTRIBUTE_DI_X)).intValue()); graphicInfo.setY(Double.valueOf(xtr.getAttributeValue(null, ATTRIBUTE_DI_Y)).intValue()); graphicInfo.setWidth(Double.valueOf(xtr.getAttributeValue(null, ATTRIBUTE_DI_WIDTH)).intValue()); graphicInfo.setHeight(Double.valueOf(xtr.getAttributeValue(null, ATTRIBUTE_DI_HEIGHT)).intValue()); model.addLabelGraphicInfo(id, graphicInfo); break; GraphicInfo graphicInfo = new GraphicInfo(); BpmnXMLUtil.addXMLLocation(graphicInfo, xtr); graphicInfo.setX(Double.valueOf(xtr.getAttributeValue(null, ATTRIBUTE_DI_X)).intValue()); graphicInfo.setY(Double.valueOf(xtr.getAttributeValue(null, ATTRIBUTE_DI_Y)).intValue()); wayPointList.add(graphicInfo);
public void createBPMNEdge(String key, List<GraphicInfo> graphicList) { FlowElement flowElement = bpmnModel.getFlowElement(key); if (flowElement instanceof SequenceFlow) { SequenceFlow sequenceFlow = (SequenceFlow) flowElement; List<Integer> waypoints = new ArrayList<Integer>(); for (GraphicInfo waypointInfo : graphicList) { waypoints.add((int) waypointInfo.getX()); waypoints.add((int) waypointInfo.getY()); } sequenceFlow.setWaypoints(waypoints); } else if (bpmnModel.getArtifact(key) != null) { // it's an association, so nothing to do } else { LOGGER.warn("Invalid reference in 'bpmnElement' attribute, sequenceFlow " + key + " not found"); } }