端到端功能 节点展开后 范围标识框位置大小计算以及内部节点与连线的位置计算调整
This commit is contained in:
parent
0861887839
commit
c2a4fed841
Binary file not shown.
@ -7,6 +7,7 @@ import com.actionsoft.apps.coe.pal.pal.repository.designer.manage.CoeDesignerAPI
|
||||
import com.actionsoft.apps.coe.pal.pal.repository.designer.model.BaseModel;
|
||||
import com.actionsoft.apps.coe.pal.pal.repository.designer.relation.cache.DesignerShapeRelationCache;
|
||||
import com.actionsoft.apps.coe.pal.pal.repository.designer.relation.model.DesignerShapeRelationModel;
|
||||
import com.actionsoft.apps.coe.pal.pal.repository.designer.util.CoeDesignerUtil;
|
||||
import com.actionsoft.apps.coe.pal.pal.repository.designer.util.ShapeUtil;
|
||||
import com.actionsoft.bpms.util.ConsolePrinter;
|
||||
import com.actionsoft.bpms.util.UUIDGener;
|
||||
@ -31,17 +32,23 @@ public class GraphNodeExpandHandle {
|
||||
private JSONObject endToEndProcessDefine; // 总图的模型信息
|
||||
private JSONObject scopeLimitationShape; // 范围标注框
|
||||
|
||||
private double[] scopeLimitationShapeBeforePoi;
|
||||
|
||||
private final ReentrantLock lock = new ReentrantLock();
|
||||
|
||||
public GraphNodeExpandHandle(String repositoryId, String shapeId) {
|
||||
public GraphNodeExpandHandle(String repositoryId, String shapeId) throws AWSException{
|
||||
this.repositoryId = repositoryId;
|
||||
this.shapeId = shapeId;
|
||||
|
||||
apiManager = CoeDesignerAPIManager.getInstance();
|
||||
|
||||
readChildProcessDefine();
|
||||
readCurrentProcessDefine();
|
||||
toAssembleScopeLimitationShape();
|
||||
try {
|
||||
readChildProcessDefine();
|
||||
readCurrentProcessDefine();
|
||||
toAssembleScopeLimitationShape();
|
||||
} catch (AWSException e) {
|
||||
throw new AWSException(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -58,6 +65,8 @@ public class GraphNodeExpandHandle {
|
||||
String childProcessDefineStr = apiManager.getChildProcessDefine(repositoryId, 0, relationFileId);
|
||||
if (UtilString.isEmpty(childProcessDefineStr)){ // 初次读取 去源文件目录读取
|
||||
BaseModel childProcessBaseModel = apiManager.getDefinition(relationFileId, 0);
|
||||
if (childProcessBaseModel == null)
|
||||
throw new AWSException("当前子流程节点内部可能没有图形元素,可以去添加后展开");
|
||||
childProcessDefineStr = childProcessBaseModel.getDefinition();
|
||||
}
|
||||
childProcessDefine = JSONObject.parseObject(childProcessDefineStr);
|
||||
@ -109,6 +118,9 @@ public class GraphNodeExpandHandle {
|
||||
double scopeShapeW = childProcessEleMaxX.getDoubleValue("x") + childProcessEleMaxX.getDoubleValue("w") - childProcessEleMixX.getDoubleValue("x") + SubProcessConst.SCOPE_SHAPE_PADDING;
|
||||
double scopeShapeH = childProcessEleMaxY.getDoubleValue("y") + childProcessEleMaxY.getDoubleValue("h") - childProcessEleMinY.getDoubleValue("y") + SubProcessConst.SCOPE_SHAPE_PADDING;
|
||||
|
||||
// 计算下范围选择框在子流程所代表的模型文件的坐标
|
||||
scopeLimitationShapeBeforePoi = new double[]{childProcessEleMixX.getDoubleValue("x") - SubProcessConst.SCOPE_SHAPE_PADDING / 2, childProcessEleMinY.getDoubleValue("y") - SubProcessConst.SCOPE_SHAPE_PADDING / 2};
|
||||
|
||||
JSONObject elements = endToEndProcessDefine.getJSONObject("elements");
|
||||
// 找到当前要展开的子流程节点
|
||||
JSONObject currentExpandShape = elements.getJSONObject(shapeId);
|
||||
@ -211,21 +223,32 @@ public class GraphNodeExpandHandle {
|
||||
double scopeShapeX = scopeShapeProps.getDoubleValue("x");
|
||||
double scopeShapeY = scopeShapeProps.getDoubleValue("y");
|
||||
|
||||
double distanceX = scopeShapeX - scopeLimitationShapeBeforePoi[0];
|
||||
double distanceY = scopeShapeY - scopeLimitationShapeBeforePoi[1];
|
||||
|
||||
// 根据范围标注框的坐标 调整子流程所有元素的坐标
|
||||
JSONObject elements = childProcessDefine.getJSONObject("elements");
|
||||
for (String key : elements.keySet()) {
|
||||
JSONObject ele = elements.getJSONObject(key);
|
||||
JSONObject props = ele.getJSONObject("props");
|
||||
props.put("x", scopeShapeX + props.getDoubleValue("x"));
|
||||
props.put("y", scopeShapeY + props.getDoubleValue("y"));
|
||||
// 元素分为两类 一类为图形 一类为连线
|
||||
if ("linker".equals(ele.getString("name"))){ // 连线的话折点需要额外处理
|
||||
if ("linker".equals(ele.getString("name"))){ // 连线
|
||||
JSONObject from = ele.getJSONObject("from");
|
||||
from.put("x", distanceX + from.getDoubleValue("x"));
|
||||
from.put("y", distanceY + from.getDoubleValue("y"));
|
||||
JSONObject to = ele.getJSONObject("to");
|
||||
to.put("x", distanceX + to.getDoubleValue("x"));
|
||||
to.put("y", distanceY + to.getDoubleValue("y"));
|
||||
// 连线的话折点也需要处理
|
||||
JSONArray points = ele.getJSONArray("points");
|
||||
for (Object p : points) {
|
||||
JSONObject point = (JSONObject) p;
|
||||
point.put("x", point.getDoubleValue("x") + scopeShapeX);
|
||||
point.put("y", point.getDoubleValue("y") + scopeShapeY);
|
||||
point.put("x", point.getDoubleValue("x") + distanceX);
|
||||
point.put("y", point.getDoubleValue("y") + distanceY);
|
||||
}
|
||||
}else { // 图形
|
||||
JSONObject props = ele.getJSONObject("props");
|
||||
props.put("x", distanceX + props.getDoubleValue("x"));
|
||||
props.put("y", distanceY + props.getDoubleValue("y"));
|
||||
}
|
||||
|
||||
addEndToEndGraphElements(ele);
|
||||
|
||||
@ -310,9 +310,8 @@ public class SubProcessWeb extends ActionWeb {
|
||||
* @param direction 布局方向
|
||||
*/
|
||||
public String shapeNodeExpand(String repositoryId, String shapeId, String direction){
|
||||
|
||||
GraphNodeExpandHandle nodeExpandHandle = new GraphNodeExpandHandle(repositoryId, shapeId);
|
||||
try {
|
||||
GraphNodeExpandHandle nodeExpandHandle = new GraphNodeExpandHandle(repositoryId, shapeId);
|
||||
String define = nodeExpandHandle.handleNodeExpand(direction);
|
||||
ResponseObject ro = ResponseObject.newOkResponse("展开成功");
|
||||
ro.setData(define);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user