使用modeler設計器,流程圖連線名稱是有顯示的,可是運行結果卻沒顯示。
找到網上2遍文章,說是activiti框架中的一個bug,要修改
DefaultProcessDiagramGenerator類的代碼:
https://blog.csdn.net/fgstudent/article/details/39916003
http://www.shareniu.com/article/61.htm框架
// Draw sequenceflow label
GraphicInfo labelGraphicInfo = bpmnModel.getLabelGraphicInfo(sequenceFlow.getId
());
if (labelGraphicInfo != null) {
processDiagramCanvas.drawLabel(sequenceFlow.getName(), labelGraphicInfo, false);
}
修改成:
// Draw sequenceflow label
GraphicInfo labelGraphicInfo = bpmnModel.getLabelGraphicInfo(sequenceFlow.getId
());
if (labelGraphicInfo != null) {
processDiagramCanvas.drawLabel(sequenceFlow.getName(), labelGraphicInfo, false);
}else {
GraphicInfo lineCenter = getLineCenter(graphicInfoList);
processDiagramCanvas.drawLabel(sequenceFlow.getName(), lineCenter, false);
}eclipse
可是上面文章的activiti版本是5.1六、5.22,本人項目用的是5.13(jdk爲1.6),沒有
DefaultProcessDiagramGenerator類,而是ProcessDiagramGenerator類,並且方法
drawLabel也不支持上面3個參數,須要5個參數,通過一番測試,終於解決。
下面是整個修改過程:
一、用反編譯工具jd-gui把項目的全部activiti的jar包反編譯保存爲源碼;工具
二、在eclipse中新建一個項目,把源碼放進去(jdk和項目保持一致設爲1.6,剛開始設爲1.8
,結果運行提示有錯誤),代碼在eclipse提示有錯誤的話,可不理會,只要項目會生成
class文件就行。測試
三、在eclipse中打開類ProcessDiagramGenerator(對應包爲activiti-engine-5.13.jar),
找到代碼
if (!drawedLabel) {
GraphicInfo labelGraphicInfo = bpmnModel.getLabelGraphicInfo(sequenceFlow.getId
());
if (labelGraphicInfo != null) {
int middleX = (int)((previousGraphicInfo.getX() + labelGraphicInfo.getX() +
(graphicInfo.getX() + labelGraphicInfo.getX())) / 2.0D);
int middleY = (int)((previousGraphicInfo.getY() + labelGraphicInfo.getY() +
(graphicInfo.getY() + labelGraphicInfo.getY())) / 2.0D);
middleX += 15;
processDiagramCanvas.drawLabel(sequenceFlow.getName(), middleX, middleY, (int)
labelGraphicInfo.getWidth(), (int)labelGraphicInfo.getHeight());
drawedLabel = true;
}
修改成
if (!drawedLabel) {
GraphicInfo labelGraphicInfo = bpmnModel.getLabelGraphicInfo(sequenceFlow.getId
());
if (labelGraphicInfo != null) {
processDiagramCanvas.drawLabel(sequenceFlow.getName(), (int)
labelGraphicInfo.getX(), (int)labelGraphicInfo.getY(), (int)
labelGraphicInfo.getWidth(), (int)labelGraphicInfo.getHeight());
drawedLabel = true;
}
保存,Eclipse會自動編譯,生成class文件,可看到ProcessDiagramGenerator.class,
ProcessDiagramGenerator$1.class至ProcessDiagramGenerator$20.class、
ProcessDiagramGenerator$ActivityDrawInstruction.class自動修改保存。ui
四、右鍵activiti-engine-5.13.jar用壓縮軟件如WinRAR打開,定位到
ProcessDiagramGenerator.class的所在位置,把第3步的class文件直接拖進去替換掉。.net
五、把第4步activiti-engine-5.13.jar替換如今項目的相應文件;設計
結束。htm