RepositoryService repositoryService= processEngine.getRepositoryService(); NewDeployment deploy= repositoryService.createDeployment(); deploy.addResourceFromClasspath("newSite.jpdl.xml") .addResourceFromClasspath("newSite.png");
action接收processInstanceId,(一般情况下processInstanceId与ExecutionId相同)得到流程图,并在当前activity上画框,来显示流程走到哪里。
public String showImage(){ ProcessInstance processInstance = executionService .findProcessInstanceById(pid); String processDefinitionId = processInstance.getProcessDefinitionId(); ProcessDefinition processDefinition = repositoryService .createProcessDefinitionQuery().processDefinitionId( processDefinitionId).uniqueResult(); Set<String> activityNames = processInstance.findActiveActivityNames(); BufferedImage image = null; for (String activityName : activityNames) { ActivityCoordinates ac = repositoryService.getActivityCoordinates( processInstance.getProcessDefinitionId(), activityName); InputStream is = repositoryService.getResourceAsStream( processDefinition.getDeploymentId(), processDefinition .getImageResourceName()); image = ImageIO.read(is); Graphics g = image.getGraphics(); g.setColor(new Color(255, 0, 0)); g.drawRect(ac.getX(), ac.getY(), ac.getWidth(), ac.getHeight()); g.dispose(); } ByteArrayOutputStream output = new ByteArrayOutputStream(); ImageIO.write(image, "PNG", output); ByteArrayInputStream input = new ByteArrayInputStream(output .toByteArray()); this.setInputStream(input); return SUCCESS; }structs里面配置result为stream类型,class交给spring处理没有集成的可以修改成原有路径
<action name="processImage" class="processImageAction"> <result type="stream"> <param name="contentType">image/png</param> <param name="inputName">inputStream</param> </result> </action>jsp页面显示
<img src="processImage.action?pid=<s:property value='id'/>"/>