AnsweredAssumed Answered

Shift between repositoryService.getProcessDiagram() and repositoryService.getProcessDiagramLayout()

Question asked by jacek on Oct 18, 2013
Latest reply on Oct 18, 2013 by martin.grofcik
Hi,

I need to provide process diagram with marked current state of exdcution.
I use repositoryService.getProcessDiagram() image, and draw on it, using nodes positions from repositoryService.getProcessDiagramLayout().
But sometimes (on some processes) I have a shift (several points) between diagram received from getProcessDiagram method and positions received from getProcessDiagramLayout method.

Is this a bug, or i am doing it wrong?

Examle code:

ProcessInstance processInstance = processEngine.getRuntimeService().createProcessInstanceQuery().processInstanceId(processId).singleResult();
String processDefinitionId = processInstance.getProcessDefinitionId();

InputStream diagramInputStream = processEngine.getRepositoryService().getProcessDiagram(processDefinitionId);
DiagramLayout diagramLayout = processEngine.getRepositoryService().getProcessDiagramLayout(processDefinitionId);

BufferedImage diagramImage = ImageIO.read(diagramInputStream);
Graphics graphics = diagramImage.getGraphics();

List<Execution> executions = processEngine.getRuntimeService().createExecutionQuery().processInstanceId(processId).list();
graphics.setColor(new Color(240, 100, 30));
for (Execution execution : executions) {
   DiagramNode node = diagramLayout.getNode(execution.getActivityId());
   if (node != null) {
      graphics.drawRoundRect(node.getX().intValue(), node.getY().intValue(), node.getWidth().intValue(), node.getHeight().intValue(), 25, 25);
   }
}

ByteArrayOutputStream diagramOutputStream = new ByteArrayOutputStream();
ImageIO.write(diagramImage, "PNG", diagramOutputStream);


Spring configuration:

  <bean id="processEngineConfiguration" class="org.activiti.spring.SpringProcessEngineConfiguration">
    …….
    <property name="deploymentResources" value="classpath*:/process/*.bpmn" />
  </bean>

  <bean id="processEngine" class="org.activiti.spring.ProcessEngineFactoryBean">
    <property name="processEngineConfiguration" ref="processEngineConfiguration" />
  </bean>

Outcomes