流程图创建图片时箭头异常问题处理

This commit is contained in:
446052889@qq.com 2022-09-01 15:51:38 +08:00
parent b5372b1120
commit 02e87d2141
3 changed files with 46 additions and 1 deletions

View File

@ -1182,4 +1182,45 @@ public class CoeDesignerShapeAPIManager {
return definition.toString();
}
/**
* 处理连线箭头问题
* @param define
* @return
*/
public String updateLinkArrow(String define) {
JSONObject definition = JSONObject.parseObject(define);
JSONObject elements = definition.getJSONObject("elements");
Map<String, Map<String, PALMethodAttributeModel>> shapeAttrMap = new HashMap<>();
Iterator<String> it = elements.keySet().iterator();
while (it.hasNext()) {
String shapeId = it.next();
JSONObject shape = elements.getJSONObject(shapeId);
String shapeName = shape.getString("name");
if ("linker".equals(shapeName)) {
JSONArray points = shape.getJSONArray("points");
if (points == null) {
points = new JSONArray();
}
if (points.isEmpty()) {
JSONObject from = shape.getJSONObject("from");
JSONObject to = shape.getJSONObject("to");
if (from != null && to != null) {
int fromX = from.getInteger("x");
int fromY = from.getInteger("y");
int toX = to.getInteger("x");
int toY = to.getInteger("y");
JSONObject obj = new JSONObject();
obj.put("x", ((double) (fromX + toX)) /2);
obj.put("y", ((double) (fromY + toY)) /2);
points.add(obj);
}
}
shape.put("points", points);
elements.put(shapeId, shape);
}
}
return definition.toString();
}
}

View File

@ -1,5 +1,7 @@
package com.actionsoft.apps.coe.pal.pal.repository.designer.io.image;
import com.actionsoft.apps.coe.pal.pal.repository.designer.CoeDesignerShapeAPIManager;
import com.actionsoft.apps.coe.pal.pal.repository.designer.manage.CoeDesignerAPIManager;
import com.actionsoft.bpms.bpmn.modeler.util.draw.ChartGraphics;
import com.actionsoft.bpms.util.UtilFile;
import com.actionsoft.apps.coe.pal.pal.repository.designer.model.BaseModel;
@ -33,10 +35,12 @@ public class CoeDesignerImage {
//保存图片
ChartGraphics brush = new ChartGraphics();
if (bigImage) {
// 处理连线箭头问题
String define = CoeDesignerShapeAPIManager.getInstance().updateLinkArrow(model.getDefinition());
String pathname =model.getPath()+model.getUUID()+".png";
byte[] desginerImg = null;
try {
desginerImg = brush.draw(model.getDefinition(), null, null); // 获得原图
desginerImg = brush.draw(define, null, null); // 获得原图
create(pathname, desginerImg);
} catch (Exception e) {
e.printStackTrace();