将JBPM5流程文件Flow File BPMN 2.0/BPMN (*.bpmn) 转换为 PNG(*.png) 图片文件的解决方案...

原文[url]http://cutelion.blog.hexun.com/70817647_d.html[/url]

[转]使用Joinwork Process Studio创建jBpm和Activiti流程定义文件 [url]http://arronzhen.iteye.com/blog/1545862[/url]

将JBPM5流程文件Flow File BPMN 2.0/BPMN (*.bpmn) 转换为 PNG (*.png) 图片文件的解决方案

最近在利用JBPM5开发流程应用,在eclipse安装的插件工具drools jbpm tools 5.2.0里面没有将流程文件导出为PNG格式的图片功能。这样没有图片就不能较直观地查看到当前流程走到了哪些节点。几经周折,找了很久,终于发现一个可以变通的方法,借助其它的流程工具来做到这一点。
[color=red][b]joinwork-process-studio[/b][/color]正好是这样的工具。下载地址:
[url]http://www.bpmn123.net/bpmn/20110823/joinwork-process-studio-v31%E5%8F%91%E5%B8%83.html[/url]
或者 [url]http://www.bpmn123.net/bpmn/20110823/joinwork-process-studio-%E4%B8%8B%E8%BD%BD.html[/url]

将joinwork-process-studio安装后,可以打开eclipse的workspace中已经建好的Flow File(BPMN 2.0/BPMN 文件),接下来可以选择"生成图片文件",可以生成PNG格式的图片。另外,选定节点后可以在“外观”中对节点填充颜色。


@RequestMapping(value = "/viewWorkFlow")
public void getCurrentNode(@RequestParam("processId") long processInstanceId, HttpServletRequest request,
HttpServletResponse response) throws IOException {

JBPM5Engine engine = new JBPM5Engine(entityManagerFactory,taskEntityManagerFactory,LEAVE_WORKFLOW_LEAVE);
ProcessInstance process = engine.getProcessInstance(processInstanceId);

WorkflowProcessInstance wfInstance = (WorkflowProcessInstance) process;
Iterator<NodeInstance> iterator = wfInstance.getNodeInstances().iterator();
NodeInstance nodeInstance = iterator.next();

//-------------------- send the work flow image ----------------------------------
PrintWriter out = response.getWriter();

//********** get the attributes eg : x,y,width,height .. *****************
String xpathFile = "leave.bpmn";
String nodeStr = "//bpmndi:BPMNDiagram/bpmndi:BPMNPlane/bpmndi:BPMNShape[@bpmnElement='_"+nodeInstance.getNodeId()+"']/dc:Bounds";
XPathUtils xPathUtils = new XPathUtils(xpathFile,nodeStr);
Map<String, String> attributes = xPathUtils.getAttributes();
Element rootEl = xPathUtils.getRootElement();

//************************************************************************


show the work flow image in page
int imageWidth = Integer.parseInt(rootEl.attributeValue("width") == null? "910" : rootEl.attributeValue("width"));
int imageHeight = Integer.parseInt(rootEl.attributeValue("height")== null ? "710" : rootEl.attributeValue("height"));


int nodeWidth = Integer.parseInt(attributes.get("width"));
int nodeHeight = Integer.parseInt(attributes.get("height"));
int nodeX = Integer.parseInt(attributes.get("x"));
int nodeY = Integer.parseInt(attributes.get("y"));
String imageUrl = request.getContextPath()+"/processImageServlet"; //流程URL
//流程图作为背景
out.println("<div style=\"position:relative;background-image:url("+imageUrl+");width:"+imageWidth+"px;height:"+imageHeight+"px;\">");
//输出当前节点位置
out.println("<div style=\"position:absolute;left:"+nodeX+"px;top:"+nodeY+"px;width:"+(nodeWidth-1)+"px;height:"+(nodeHeight-2)+"px;border:3px solid red\">");
out.println("</div>");
out.println("</div>");
out.flush();
out.close();


//!-------------------------------------------------------------------------------
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值