端到端功能 节点展开部分代码提交
This commit is contained in:
parent
9ca7ae12d2
commit
7e4770bc14
Binary file not shown.
@ -1,5 +1,6 @@
|
|||||||
package com.actionsoft.apps.coe.method.process.subprocess.graph;
|
package com.actionsoft.apps.coe.method.process.subprocess.graph;
|
||||||
|
|
||||||
|
import com.actionsoft.apps.coe.method.process.subprocess.constant.LinkerDefConstant;
|
||||||
import com.actionsoft.apps.coe.method.process.subprocess.constant.SubProcessConst;
|
import com.actionsoft.apps.coe.method.process.subprocess.constant.SubProcessConst;
|
||||||
import com.actionsoft.apps.coe.method.process.subprocess.mode.Node;
|
import com.actionsoft.apps.coe.method.process.subprocess.mode.Node;
|
||||||
import com.actionsoft.apps.coe.pal.pal.repository.designer.manage.CoeDesignerAPIManager;
|
import com.actionsoft.apps.coe.pal.pal.repository.designer.manage.CoeDesignerAPIManager;
|
||||||
@ -7,6 +8,7 @@ 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.cache.DesignerShapeRelationCache;
|
||||||
import com.actionsoft.apps.coe.pal.pal.repository.designer.relation.model.DesignerShapeRelationModel;
|
import com.actionsoft.apps.coe.pal.pal.repository.designer.relation.model.DesignerShapeRelationModel;
|
||||||
import com.actionsoft.apps.coe.pal.pal.repository.designer.util.ShapeUtil;
|
import com.actionsoft.apps.coe.pal.pal.repository.designer.util.ShapeUtil;
|
||||||
|
import com.actionsoft.bpms.util.UUIDGener;
|
||||||
import com.actionsoft.bpms.util.UtilString;
|
import com.actionsoft.bpms.util.UtilString;
|
||||||
import com.actionsoft.exception.AWSException;
|
import com.actionsoft.exception.AWSException;
|
||||||
import com.alibaba.fastjson.JSONArray;
|
import com.alibaba.fastjson.JSONArray;
|
||||||
@ -163,7 +165,11 @@ public class GraphNodeExpandHandle {
|
|||||||
double[][] vertexPosition = expandAdjMatrix.getVertexPosition(elements);
|
double[][] vertexPosition = expandAdjMatrix.getVertexPosition(elements);
|
||||||
// 7、构建新的连线
|
// 7、构建新的连线
|
||||||
NodeExpandLinkerRender linkerRender = new NodeExpandLinkerRender(vertexPosition, expandAdjMatrix);
|
NodeExpandLinkerRender linkerRender = new NodeExpandLinkerRender(vertexPosition, expandAdjMatrix);
|
||||||
linkerRender.toAssembleLinker(direction);
|
JSONArray linkers = linkerRender.toAssembleLinker(direction);
|
||||||
|
for (Object o : linkers) {
|
||||||
|
JSONObject linker = (JSONObject) o;
|
||||||
|
addEndToEndGraphElements(linker);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -415,9 +421,99 @@ class NodeExpandLinkerRender{
|
|||||||
this.expandAdjMatrix = expandAdjMatrix;
|
this.expandAdjMatrix = expandAdjMatrix;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据连线方向 组装连线
|
||||||
|
* @param direction 连线方向
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
public JSONArray toAssembleLinker(String direction){
|
public JSONArray toAssembleLinker(String direction){
|
||||||
JSONArray linkers = new JSONArray();
|
JSONArray linkers = new JSONArray();
|
||||||
|
for (int i = 0; i < vertexPosition.length; i++) {
|
||||||
|
double[] fromPoi = vertexPosition[i];
|
||||||
|
List<Integer> nextNodeIndex = expandAdjMatrix.getNeighbors(i);
|
||||||
|
if (nextNodeIndex.size() > 0){ // 说明当前节点有连线
|
||||||
|
for (Integer nodeIndex : nextNodeIndex) {
|
||||||
|
double[] toPoi = vertexPosition[nodeIndex];
|
||||||
|
double[][] turnPoi = "horizontal".equals(direction)
|
||||||
|
? calculationLinkerPointInHorizLayOut(fromPoi, toPoi)
|
||||||
|
: calculationLinkerPointInVertLayOut(fromPoi, toPoi);
|
||||||
|
double[] angleArr = calculationLinkerAngle(fromPoi, toPoi, turnPoi[1], turnPoi[turnPoi.length - 2]);
|
||||||
|
// 构建连线
|
||||||
|
JSONObject linkerObj = JSONObject.parseObject(LinkerDefConstant.linker);
|
||||||
|
linkerObj.put("id", UUIDGener.getObjectId());
|
||||||
|
// 折点
|
||||||
|
JSONArray points = new JSONArray();
|
||||||
|
for (int j = 0; j < turnPoi.length; j++) {
|
||||||
|
if (j > 0 && j < turnPoi.length - 1){
|
||||||
|
JSONObject pointObj = new JSONObject();
|
||||||
|
pointObj.put("x", turnPoi[j][0]);
|
||||||
|
pointObj.put("y", turnPoi[j][1]);
|
||||||
|
points.add(pointObj);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
linkerObj.put("points", points);
|
||||||
|
// 起点与终点
|
||||||
|
JSONObject fromObj = new JSONObject();
|
||||||
|
fromObj.put("x", turnPoi[0][0]);
|
||||||
|
fromObj.put("y", turnPoi[0][1]);
|
||||||
|
fromObj.put("angle", angleArr[0]);
|
||||||
|
fromObj.put("id", nodeIds.get(i));
|
||||||
|
linkerObj.put("from", fromObj);
|
||||||
|
JSONObject toObj = new JSONObject();
|
||||||
|
toObj.put("x", turnPoi[turnPoi.length - 1][0]);
|
||||||
|
toObj.put("y", turnPoi[turnPoi.length - 1][1]);
|
||||||
|
toObj.put("angle", angleArr[1]);
|
||||||
|
toObj.put("id", nodeIds.get(nodeIndex.intValue()));
|
||||||
|
linkerObj.put("to", toObj);
|
||||||
|
|
||||||
|
linkers.add(linkerObj);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
return linkers;
|
return linkers;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private double[][] calculationLinkerPointInVertLayOut(double[] fromPoi, double[] toPoi) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private double[][] calculationLinkerPointInHorizLayOut(double[] fromPoi, double[] toPoi) {
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 计算angle值
|
||||||
|
* @param fromPoi 起始节点坐标
|
||||||
|
* @param toPoi 结束节点坐标
|
||||||
|
* @param firstTurnPoi 连线第一个折点坐标
|
||||||
|
* @param lastTurnPoi 连线最后一个折点坐标
|
||||||
|
* @return [0]: from的angle [1]: to的angle
|
||||||
|
*/
|
||||||
|
private double[] calculationLinkerAngle(double[] fromPoi, double[] toPoi, double[] firstTurnPoi, double[] lastTurnPoi){
|
||||||
|
double fromX = fromPoi[0], fromY = fromPoi[1];
|
||||||
|
double toX = toPoi[0], toY = toPoi[1];
|
||||||
|
double firstTurnX = firstTurnPoi[0], firstTurnY = firstTurnPoi[1];
|
||||||
|
double lastTurnX = lastTurnPoi[0], lastTurnY = lastTurnPoi[1];
|
||||||
|
|
||||||
|
if (fromY == toY){ // 水平
|
||||||
|
return fromX < toX ? new double[]{LinkerDefConstant.ANGLE_LEFT, LinkerDefConstant.ANGLE_RIGHT} : new double[]{LinkerDefConstant.ANGLE_RIGHT, LinkerDefConstant.ANGLE_LEFT};
|
||||||
|
}else if (fromX == toX){ // 垂直
|
||||||
|
return fromY < toY ? new double[]{LinkerDefConstant.ANGLE_UP, LinkerDefConstant.ANGLE_DOWN} : new double[]{LinkerDefConstant.ANGLE_DOWN, LinkerDefConstant.ANGLE_UP};
|
||||||
|
}else {
|
||||||
|
double fromAngle = 0.0;
|
||||||
|
if (fromY == firstTurnY){ // 水平
|
||||||
|
fromAngle = fromX < firstTurnX ? LinkerDefConstant.ANGLE_LEFT : LinkerDefConstant.ANGLE_RIGHT;
|
||||||
|
}else if (fromX == firstTurnX){ // 垂直
|
||||||
|
fromAngle = fromY < firstTurnY ? LinkerDefConstant.ANGLE_UP : LinkerDefConstant.ANGLE_DOWN;
|
||||||
|
}
|
||||||
|
double toAngle = 0.0;
|
||||||
|
if (toY == lastTurnY){ // 水平
|
||||||
|
toAngle = toX < lastTurnX ? LinkerDefConstant.ANGLE_LEFT : LinkerDefConstant.ANGLE_RIGHT;
|
||||||
|
}else if (toX == lastTurnX){ // 垂直
|
||||||
|
toAngle = toY < lastTurnY ? LinkerDefConstant.ANGLE_UP : LinkerDefConstant.ANGLE_DOWN;
|
||||||
|
}
|
||||||
|
return new double[]{fromAngle, toAngle};
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user