Search in sources :

Example 1 with DiagramElement

use of org.camunda.bpm.engine.repository.DiagramElement in project camunda-bpm-platform by camunda.

the class ProcessDiagramLayoutFactory method getBpmnProcessDiagramLayout.

/**
 * Provides positions and dimensions of elements in a BPMN process diagram as
 * provided by {@link RepositoryService#getProcessDiagram(String)}.
 *
 * @param bpmnXmlStream
 *          BPMN 2.0 XML document
 * @param imageStream
 *          BPMN 2.0 diagram in PNG format (JPEG and other formats supported
 *          by {@link ImageIO} may also work)
 * @return Layout of the process diagram
 * @return null when parameter imageStream is null
 */
public DiagramLayout getBpmnProcessDiagramLayout(Document bpmnModel, InputStream imageStream) {
    if (imageStream == null) {
        return null;
    }
    DiagramNode diagramBoundsXml = getDiagramBoundsFromBpmnDi(bpmnModel);
    DiagramNode diagramBoundsImage;
    if (isExportedFromAdonis50(bpmnModel)) {
        // Adonis header
        int offsetTop = 29;
        // Adonis footer
        int offsetBottom = 61;
        diagramBoundsImage = getDiagramBoundsFromImage(imageStream, offsetTop, offsetBottom);
    } else {
        diagramBoundsImage = getDiagramBoundsFromImage(imageStream);
    }
    Map<String, DiagramNode> listOfBounds = new HashMap<String, DiagramNode>();
    listOfBounds.put(diagramBoundsXml.getId(), diagramBoundsXml);
    // listOfBounds.putAll(getElementBoundsFromBpmnDi(bpmnModel));
    listOfBounds.putAll(fixFlowNodePositionsIfModelFromAdonis(bpmnModel, getElementBoundsFromBpmnDi(bpmnModel)));
    Map<String, DiagramElement> listOfBoundsForImage = transformBoundsForImage(diagramBoundsImage, diagramBoundsXml, listOfBounds);
    return new DiagramLayout(listOfBoundsForImage);
}
Also used : DiagramElement(org.camunda.bpm.engine.repository.DiagramElement) DiagramNode(org.camunda.bpm.engine.repository.DiagramNode) HashMap(java.util.HashMap) DiagramLayout(org.camunda.bpm.engine.repository.DiagramLayout)

Aggregations

HashMap (java.util.HashMap)1 DiagramElement (org.camunda.bpm.engine.repository.DiagramElement)1 DiagramLayout (org.camunda.bpm.engine.repository.DiagramLayout)1 DiagramNode (org.camunda.bpm.engine.repository.DiagramNode)1