diff --git a/com.actionsoft.apps.coe.method.process.subprocess/lib/com.actionsoft.apps.coe.method.process.subprocess.jar b/com.actionsoft.apps.coe.method.process.subprocess/lib/com.actionsoft.apps.coe.method.process.subprocess.jar index 4de670e9..1995ed13 100644 Binary files a/com.actionsoft.apps.coe.method.process.subprocess/lib/com.actionsoft.apps.coe.method.process.subprocess.jar and b/com.actionsoft.apps.coe.method.process.subprocess/lib/com.actionsoft.apps.coe.method.process.subprocess.jar differ diff --git a/com.actionsoft.apps.coe.method.process.subprocess/src/com/actionsoft/apps/coe/method/process/subprocess/graph/GraphNodeExpandHandle.java b/com.actionsoft.apps.coe.method.process.subprocess/src/com/actionsoft/apps/coe/method/process/subprocess/graph/GraphNodeExpandHandle.java index 86559367..e4a13a86 100644 --- a/com.actionsoft.apps.coe.method.process.subprocess/src/com/actionsoft/apps/coe/method/process/subprocess/graph/GraphNodeExpandHandle.java +++ b/com.actionsoft.apps.coe.method.process.subprocess/src/com/actionsoft/apps/coe/method/process/subprocess/graph/GraphNodeExpandHandle.java @@ -105,44 +105,71 @@ public class GraphNodeExpandHandle { /** * 节点展开 + * @param direction 排布方向 + * @throws Exception */ - public void handleNodeExpand() throws Exception{ + public void handleNodeExpand(String direction) throws Exception{ Thread t1 = new Thread(() -> { - // 1、子流程节点内部元素处理 包括范围标注框处理 - handleRelationModelNodePosition(); + // 1、总图节点以及连线处理 + handleEndToEndGraphNodeAndLinker(direction); }); t1.start(); Thread t2 = new Thread(() -> { - // 2、子流程节点外部其它节点的位置处理 - handleEndToEndGraphNodeExcluedExpandNode(); + // 2、子流程节点内部元素处理 + handleRelationModelNodePosition(); }); t2.start(); t1.join(); t2.join(); - // 3、构建邻接矩阵 - NodeExpandAdjMatrix expandAdjMatrix = buildEndToEndGraphAdjMatrix(); - expandAdjMatrix.buildAdjMatrix(); - // 5、根据邻接矩阵重新连线 - // 6、保存总图模型信息 以及 子流程模型信息备份 + BaseModel baseModel = apiManager.getDefinition(repositoryId, 0); + baseModel.setDefinition(endToEndProcessDefine.toJSONString()); + apiManager.storeDefinition(baseModel); + apiManager.storeChildProcessDefine(baseModel, relationFileId, childProcessDefine.toJSONString()); } /** - * 处理子流程中所有节点的坐标 + * 处理总图中的节点与连线 + * 1、删除待展开的节点 + * 2、替换为范围选择框 + * 3、节点x > 范围标注框x || 节点y < 范围标注框y 针对符合条件的节点 进行坐标调整 + * 4、根据旧有连线关系构建邻接矩阵 + * 5、获取当前总图中的所有节点的坐标 + * 6、删除旧有连线关系 + * 7、构建新的连线关系 */ - private void handleRelationModelNodePosition(){ - - // 删除当前要展开的节点 + private void handleEndToEndGraphNodeAndLinker(String direction){ + // 1、删除当前要展开的节点 removeEndToEndGraphElements(shapeId); - // 添加到总图中 + // 2、添加到总图中 addEndToEndGraphElements(scopeLimitationShape); + // 3、总图中符合范围选择框条件的节点 坐标更新 + handleEndToEndGraphNodeExcluedExpandNode(); + + // 4、构建邻接矩阵 + NodeExpandAdjMatrix expandAdjMatrix = buildEndToEndGraphAdjMatrix(); + expandAdjMatrix.buildAdjMatrix(); + // 5、删除节点展开前的连线 + removeEndToEndGraphOldLinker(); + // 6、获取所有节点坐标 + JSONObject elements = endToEndProcessDefine.getJSONObject("elements"); + double[][] vertexPosition = expandAdjMatrix.getVertexPosition(elements); + // 7、构建新的连线 + NodeExpandLinkerRender linkerRender = new NodeExpandLinkerRender(vertexPosition, expandAdjMatrix); + linkerRender.toAssembleLinker(direction); + } + + /** + * 处理待展开节点所代表的流程文件中的节点的坐标 + */ + private void handleRelationModelNodePosition(){ // 范围标注框 坐标 JSONObject scopeShapeProps = scopeLimitationShape.getJSONObject("props"); double scopeShapeX = scopeShapeProps.getDoubleValue("x"); @@ -185,6 +212,7 @@ public class GraphNodeExpandHandle { for (String key : elements.keySet()) { JSONObject ele = elements.getJSONObject(key); + if ("linker".equals(ele.getString("name"))) continue; // 连线先不处理 JSONObject props = ele.getJSONObject("props"); if (props.getDoubleValue("x") > scopeShapeX) { // 当前元素在待展开节点的右侧 props.put("x", props.getDoubleValue("x") + scopeShapeW); @@ -197,7 +225,6 @@ public class GraphNodeExpandHandle { } } - /** * 构建节点展开前 端到端总图的邻接矩阵 * 方便后续节点展开或者闭合进行重新连线 @@ -208,11 +235,9 @@ public class GraphNodeExpandHandle { List linkerList = new ArrayList<>(); JSONObject endToEndProcessElements = endToEndProcessDefine.getJSONObject("elements"); for (String key : endToEndProcessElements.keySet()) { - JSONObject ele = endToEndProcessDefine.getJSONObject(key); + JSONObject ele = endToEndProcessElements.getJSONObject(key); if ("linker".equals(ele.getString("name"))) { linkerList.add(ele); - // 删除旧有的连线 - removeEndToEndGraphElements(key); }else { nodeIdList.add(key); } @@ -221,6 +246,19 @@ public class GraphNodeExpandHandle { return expandAdjMatrix; } + /** + * 删除总图中节点展开前的连线 + */ + private void removeEndToEndGraphOldLinker(){ + JSONObject elements = endToEndProcessDefine.getJSONObject("elements"); + for (String key : elements.keySet()) { + JSONObject ele = elements.getJSONObject(key); + if ("linker".equals(ele.getString("name"))){ + removeEndToEndGraphElements(key); + } + } + } + /** * 存储子流程模型信息 * 在总图存储的同一级目录下 @@ -260,6 +298,9 @@ public class GraphNodeExpandHandle { } } +/** + * 节点展开的邻接矩阵 + */ class NodeExpandAdjMatrix{ private int[][] adjMatrix; @@ -307,6 +348,14 @@ class NodeExpandAdjMatrix{ return adjMatrix; } + public List getNodeIds() { + return nodeIds; + } + + public List getLinkerList() { + return linkerList; + } + /** * 构建邻接矩阵 */ @@ -319,4 +368,56 @@ class NodeExpandAdjMatrix{ addEdge(fromIndex, toIndex); } } + + // 输出邻接矩阵 + public void printAdjMatrix() { + StringBuffer sb = new StringBuffer(); + for (int i = 0; i < nodeIds.size(); i++) { + for (int j = 0; j < nodeIds.size(); j++) { + sb.append(adjMatrix[i][j]).append(" "); + } + sb.append("\n"); + } + System.out.println(sb.toString()); + } + + /** + * 获取总图中节点展开前的所有节点坐标 + * @param elements + * @return + */ + public double[][] getVertexPosition(JSONObject elements){ + double[][] position = new double[nodeIds.size()][2]; + for (int i = 0; i < nodeIds.size(); i++) { + JSONObject shape = elements.getJSONObject(nodeIds.get(i)); + JSONObject props = shape.getJSONObject("props"); + double x = props.getDoubleValue("x"); + double y = props.getDoubleValue("y"); + position[i][0] = x; + position[i][1] = y; + } + return position; + } +} + +/** + * 节点展开后连线重构 + */ +class NodeExpandLinkerRender{ + + private List nodeIds; // 图形节点ID集合 + private double[][] vertexPosition; // 所有节点的坐标 + private NodeExpandAdjMatrix expandAdjMatrix; // 节点矩阵 + + public NodeExpandLinkerRender(double[][] vertexPosition, NodeExpandAdjMatrix expandAdjMatrix) { + this.nodeIds = expandAdjMatrix.getNodeIds(); + this.vertexPosition = vertexPosition; + this.expandAdjMatrix = expandAdjMatrix; + } + + public JSONArray toAssembleLinker(String direction){ + JSONArray linkers = new JSONArray(); + + return linkers; + } } diff --git a/com.actionsoft.apps.coe.method.process.subprocess/src/com/actionsoft/apps/coe/method/process/subprocess/web/SubProcessWeb.java b/com.actionsoft.apps.coe.method.process.subprocess/src/com/actionsoft/apps/coe/method/process/subprocess/web/SubProcessWeb.java index f78d23e1..cbc7dbc2 100644 --- a/com.actionsoft.apps.coe.method.process.subprocess/src/com/actionsoft/apps/coe/method/process/subprocess/web/SubProcessWeb.java +++ b/com.actionsoft.apps.coe.method.process.subprocess/src/com/actionsoft/apps/coe/method/process/subprocess/web/SubProcessWeb.java @@ -303,7 +303,7 @@ public class SubProcessWeb extends ActionWeb { } - public void shapeNodeExpand(String repositoryId, String shapeId){ + public void shapeNodeExpand(String repositoryId, String shapeId, String direction){ /* * 以当前节点展开涉及到动作拆分: @@ -323,7 +323,7 @@ public class SubProcessWeb extends ActionWeb { GraphNodeExpandHandle nodeExpandHandle = new GraphNodeExpandHandle(repositoryId, shapeId); try { - nodeExpandHandle.handleNodeExpand(); + nodeExpandHandle.handleNodeExpand(direction); } catch (Exception e) { throw new RuntimeException(e); }