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 67234a7d..bc6af5a7 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/GraphNodeCloseHandle.java b/com.actionsoft.apps.coe.method.process.subprocess/src/com/actionsoft/apps/coe/method/process/subprocess/graph/GraphNodeCloseHandle.java index b65a301c..c7b6acce 100644 --- a/com.actionsoft.apps.coe.method.process.subprocess/src/com/actionsoft/apps/coe/method/process/subprocess/graph/GraphNodeCloseHandle.java +++ b/com.actionsoft.apps.coe.method.process.subprocess/src/com/actionsoft/apps/coe/method/process/subprocess/graph/GraphNodeCloseHandle.java @@ -6,6 +6,7 @@ import com.actionsoft.apps.coe.method.process.subprocess.graph.component.Abstrac import com.actionsoft.apps.coe.method.process.subprocess.graph.component.AbstractDefinitionHandle; import com.actionsoft.apps.coe.method.process.subprocess.graph.util.DefinitionThreadUnSafe; import com.actionsoft.apps.coe.method.process.subprocess.graph.util.SubProcessNodeDefineUtil; +import com.actionsoft.apps.coe.method.process.subprocess.mode.ScopeShapeMonitor; import com.actionsoft.apps.coe.pal.pal.repository.cache.PALRepositoryCache; import com.actionsoft.apps.coe.pal.pal.repository.designer.manage.CoeDesignerAPIManager; import com.actionsoft.apps.coe.pal.pal.repository.designer.model.BaseModel; @@ -34,6 +35,7 @@ public class GraphNodeCloseHandle { private JSONObject scopeLimitationShape; // 范围标注框 private AbstractDefinitionHandle definitionHandle; // 当前总图 define 处理器 private AbstractDefinitionHandle subProcessNodeDefineHandle; // 子流程节点 define 处理器 + private ScopeShapeMonitor scopeShapeMonitor; // 范围选择框及其内部元素监视器 public GraphNodeCloseHandle(String repositoryId, String shapeId, String endToEndProcessDefineStr) throws AWSException{ this.repositoryId = repositoryId; @@ -51,6 +53,8 @@ public class GraphNodeCloseHandle { scopeLimitationShape = definitionHandle.getShapeByKey(shapeId); + scopeShapeMonitor = new ScopeShapeMonitor(definitionHandle, subProcessNodeDefineHandle); + } catch (AWSException e) { throw new AWSException(e); } @@ -67,6 +71,8 @@ public class GraphNodeCloseHandle { // 1、处理范围选择框及其内部节点 removeScopeShapeAndInRangeEle(); + scopeShapeMonitor.buildScopeShapeMonitors(); + // 2、处理总图中的节点与连线 handleEndToEndGraphNodeAndLinker(); @@ -91,12 +97,14 @@ public class GraphNodeCloseHandle { removeEndToEndGraphOldLinker(); // 5、构建新的连线 NodeCloseLinkerRender linkerRender = new NodeCloseLinkerRender(vertexBounding, closeAdjMatrix); - JSONArray linkers = linkerRender.toAssembleLinker(direction, shapeId); + JSONArray linkers = linkerRender.toAssembleLinker(direction); for (Object o : linkers) { JSONObject linker = (JSONObject) o; definitionHandle.addEle(linker.getString("id"), linker); } + scopeShapeMonitor.updateScopeShapeInnerEle(); + // 6、更新画布的大小 // 确定画布的宽度与高度 double w = Arrays.stream(vertexBounding).mapToDouble(position -> position[0]).max().orElse(0.0); @@ -123,26 +131,51 @@ public class GraphNodeCloseHandle { JSONObject ele = elements.getJSONObject(key); if ("linker".equals(ele.getString("name"))) continue; if (ele.getString("id").equals(subProcessNode.getString("id"))) continue; + if (scopeShapeMonitor.checkShapeIsScopeInRange(key)) continue; JSONObject eleProps = ele.getJSONObject("props"); if ("vertically".equals(direction)){ // 垂直布局 if (x + scope[2] < eleProps.getDoubleValue("x")) { + double xMoveDistance = -scope[2] + SubProcessConst.SUB_PROCESS_SHAPE_W; eleProps.put("x", eleProps.getDoubleValue("x") - scope[2] + SubProcessConst.SUB_PROCESS_SHAPE_W); + if (scopeShapeMonitor.checkShapeIsScopeShape(key)){ + scopeShapeMonitor.updateMonitorXInfo(key, true, xMoveDistance); + } } if (y +scope[3] < eleProps.getDoubleValue("y")){ + double yMoveDistance = -scope[3] + SubProcessConst.SUB_PROCESS_SHAPE_H; eleProps.put("y", eleProps.getDoubleValue("y") - scope[3] + SubProcessConst.SUB_PROCESS_SHAPE_H); + if (scopeShapeMonitor.checkShapeIsScopeShape(key)){ + scopeShapeMonitor.updateMonitorYInfo(key, true, yMoveDistance); + } }else if (y < eleProps.getDoubleValue("y") && eleProps.getDoubleValue("y") < y + scope[3]){ eleProps.put("y", y); + double yMoveDistance = y - eleProps.getDoubleValue("y"); + if (scopeShapeMonitor.checkShapeIsScopeShape(key)){ + scopeShapeMonitor.updateMonitorYInfo(key, true, yMoveDistance); + } } }else { // 横向布局 if (x + scope[2] < eleProps.getDoubleValue("x")){ // 节点在范围框右侧的节点 + double xMoveDistance = -scope[2] + SubProcessConst.SUB_PROCESS_SHAPE_W; eleProps.put("x", eleProps.getDoubleValue("x") - scope[2] + SubProcessConst.SUB_PROCESS_SHAPE_W); + if (scopeShapeMonitor.checkShapeIsScopeShape(key)){ + scopeShapeMonitor.updateMonitorXInfo(key, true, xMoveDistance); + } }else if (x < eleProps.getDoubleValue("x") && eleProps.getDoubleValue("x") < x + scope[2] && y + scope[3] < eleProps.getDoubleValue("y")){ eleProps.put("x", x); + double xMoveDistance = x - eleProps.getDoubleValue("x"); + if (scopeShapeMonitor.checkShapeIsScopeShape(key)){ + scopeShapeMonitor.updateMonitorXInfo(key, true, xMoveDistance); + } } if (y + scope[3] < eleProps.getDoubleValue("y")){ // 节点在范围框下方的节点 + double yMoveDistance = -scope[3] + SubProcessConst.SUB_PROCESS_SHAPE_H; eleProps.put("y", eleProps.getDoubleValue("y") - scope[3] + SubProcessConst.SUB_PROCESS_SHAPE_H); + if (scopeShapeMonitor.checkShapeIsScopeShape(key)){ + scopeShapeMonitor.updateMonitorYInfo(key, true, yMoveDistance); + } } } } @@ -157,7 +190,7 @@ public class GraphNodeCloseHandle { Set eleKeys = new HashSet<>(); for (String key : elements.keySet()) { JSONObject ele = elements.getJSONObject(key); - if ("linker".equals(ele.getString("name"))){ + if ("linker".equals(ele.getString("name")) && !scopeShapeMonitor.checkShapeIsScopeInRange(key)){ eleKeys.add(key); } } @@ -177,6 +210,7 @@ public class GraphNodeCloseHandle { List linkerList = new ArrayList<>(); JSONObject endToEndProcessElements = definitionHandle.getElements(); for (String key : endToEndProcessElements.keySet()) { + if (scopeShapeMonitor.checkShapeIsScopeInRange(key)) continue; JSONObject ele = endToEndProcessElements.getJSONObject(key); if ("linker".equals(ele.getString("name"))) { linkerList.add(ele); @@ -287,13 +321,11 @@ class NodeCloseLinkerRender{ private List nodeIds; // 图形节点ID集合 private double[][] vertexPosition; // 所有节点的坐标 private NodeCloseAdjMatrix closeAdjMatrix; // 节点矩阵 - // private JSONObject scopeLimitationShape; // 范围标注框 public NodeCloseLinkerRender(double[][] vertexPosition, NodeCloseAdjMatrix closeAdjMatrix) { this.nodeIds = closeAdjMatrix.getNodeIds(); this.vertexPosition = vertexPosition; this.closeAdjMatrix = closeAdjMatrix; - // this.scopeLimitationShape = scopeLimitationShape; } /** @@ -302,9 +334,8 @@ class NodeCloseLinkerRender{ * @param shapeId 当前待展开节点ID * @return */ - public JSONArray toAssembleLinker(String direction, String shapeId){ + public JSONArray toAssembleLinker(String direction){ JSONArray linkers = new JSONArray(); - int index = nodeIds.indexOf(shapeId); for (int i = 0; i < vertexPosition.length; i++) { double[] fromBounding = vertexPosition[i]; List nextNodeIndex = closeAdjMatrix.getNeighbors(i); 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 b1313059..326fb196 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 @@ -36,7 +36,7 @@ public class GraphNodeExpandHandle { private JSONObject scopeLimitationShape; // 范围标注框 private AbstractDefinitionHandle definitionHandle; // 当前总图 define 处理器 private AbstractDefinitionHandle subProcessNodeDefineHandle; // 子流程节点 define 处理器 - private ScopeShapeMonitor scopeShapeMonitor; + private ScopeShapeMonitor scopeShapeMonitor; // 范围选择框及其内部元素监视器 private double[] scopeLimitationShapeBeforePoi; // 范围选择框在子流程文件中的坐标 @@ -229,40 +229,41 @@ public class GraphNodeExpandHandle { if ("linker".equals(ele.getString("name"))) continue; // 连线先不处理 JSONObject props = ele.getJSONObject("props"); if (ele.getString("id").equals(scopeLimitationShape.getString("id"))) continue; + if (scopeShapeMonitor.checkShapeIsScopeInRange(key)) continue; if ("vertically".equals(direction)){ - if (props.getDoubleValue("x") > scopeShapeX && !scopeShapeMonitor.checkShapeIsScopeInRange(key)) { // 当前元素在待展开节点的右侧 + if (props.getDoubleValue("x") > scopeShapeX) { // 当前元素在待展开节点的右侧 double rightMoveDistance = scopeShapeW - SubProcessConst.SUB_PROCESS_SHAPE_W; props.put("x", props.getDoubleValue("x") + rightMoveDistance); if (scopeShapeMonitor.checkShapeIsScopeShape(key)){ - scopeShapeMonitor.updateMonitorRightInfo(key, true, rightMoveDistance); + scopeShapeMonitor.updateMonitorXInfo(key, true, rightMoveDistance); } } - if (props.getDoubleValue("y") >= scopeShapeY && !scopeShapeMonitor.checkShapeIsScopeInRange(key)) { // 当前元素在待展开节点的下侧 + if (props.getDoubleValue("y") >= scopeShapeY) { // 当前元素在待展开节点的下侧 double bottomMoveDistance = scopeShapeH - SubProcessConst.SUB_PROCESS_SHAPE_H; props.put("y", props.getDoubleValue("y") + bottomMoveDistance); if (scopeShapeMonitor.checkShapeIsScopeShape(key)){ - scopeShapeMonitor.updateMonitorBottomInfo(key, true, bottomMoveDistance); + scopeShapeMonitor.updateMonitorYInfo(key, true, bottomMoveDistance); } } }else { - if (props.getDoubleValue("x") > scopeShapeX && !scopeShapeMonitor.checkShapeIsScopeInRange(key)) { // 当前元素在待展开节点的右侧 + if (props.getDoubleValue("x") > scopeShapeX) { // 当前元素在待展开节点的右侧 double rightMoveDistance = scopeShapeW - SubProcessConst.SUB_PROCESS_SHAPE_W; props.put("x", props.getDoubleValue("x") + rightMoveDistance); if (scopeShapeMonitor.checkShapeIsScopeShape(key)){ - scopeShapeMonitor.updateMonitorRightInfo(key, true, rightMoveDistance); + scopeShapeMonitor.updateMonitorXInfo(key, true, rightMoveDistance); } - }else if (props.getDoubleValue("x") == scopeShapeX && props.getDoubleValue("y") > scopeShapeY && !scopeShapeMonitor.checkShapeIsScopeInRange(key)) { // 当前元素与待展开节点在一列上 且在下侧 + }else if (props.getDoubleValue("x") == scopeShapeX && props.getDoubleValue("y") > scopeShapeY) { // 当前元素与待展开节点在一列上 且在下侧 double rightMoveDistance = scopeShapeW - SubProcessConst.SUB_PROCESS_SHAPE_W; props.put("x", props.getDoubleValue("x") + rightMoveDistance); if (scopeShapeMonitor.checkShapeIsScopeShape(key)){ - scopeShapeMonitor.updateMonitorRightInfo(key, true, rightMoveDistance); + scopeShapeMonitor.updateMonitorXInfo(key, true, rightMoveDistance); } } - if (props.getDoubleValue("y") > scopeShapeY && !scopeShapeMonitor.checkShapeIsScopeInRange(key)) { // 当前元素在待展开节点的下侧 + if (props.getDoubleValue("y") > scopeShapeY) { // 当前元素在待展开节点的下侧 double bottomMoveDistance = scopeShapeH - SubProcessConst.SUB_PROCESS_SHAPE_H; props.put("y", props.getDoubleValue("y") + bottomMoveDistance); if (scopeShapeMonitor.checkShapeIsScopeShape(key)){ - scopeShapeMonitor.updateMonitorBottomInfo(key, true, bottomMoveDistance); + scopeShapeMonitor.updateMonitorYInfo(key, true, bottomMoveDistance); } } } diff --git a/com.actionsoft.apps.coe.method.process.subprocess/src/com/actionsoft/apps/coe/method/process/subprocess/mode/ScopeShapeMonitor.java b/com.actionsoft.apps.coe.method.process.subprocess/src/com/actionsoft/apps/coe/method/process/subprocess/mode/ScopeShapeMonitor.java index a0e052dd..f0bfe24c 100644 --- a/com.actionsoft.apps.coe.method.process.subprocess/src/com/actionsoft/apps/coe/method/process/subprocess/mode/ScopeShapeMonitor.java +++ b/com.actionsoft.apps.coe.method.process.subprocess/src/com/actionsoft/apps/coe/method/process/subprocess/mode/ScopeShapeMonitor.java @@ -58,13 +58,13 @@ public class ScopeShapeMonitor { * @param rightMoveDistance 右移动距离 * @throws AWSException */ - public void updateMonitorRightInfo(String scopeShapeId, boolean isRightMove, double rightMoveDistance) throws AWSException{ + public void updateMonitorXInfo(String scopeShapeId, boolean isXMove, double xMoveDistance) throws AWSException{ if (scopeShapeMonitorMap == null) return; if (!scopeShapeMonitorMap.containsKey(scopeShapeId)) throw new AWSException("【参数异常】当前范围框监视器不包含图形ID【" + scopeShapeId + "】"); MonitorInfo monitorInfo = scopeShapeMonitorMap.get(scopeShapeId); - monitorInfo.setRightMove(isRightMove); - monitorInfo.setRightMoveDistance(rightMoveDistance); + monitorInfo.setxMove(isXMove); + monitorInfo.setxMoveDistance(xMoveDistance); } /** @@ -74,13 +74,13 @@ public class ScopeShapeMonitor { * @param bottomMoveDistance 下移距离 * @throws AWSException */ - public void updateMonitorBottomInfo(String scopeShapeId, boolean isBottomMove, double bottomMoveDistance) throws AWSException{ + public void updateMonitorYInfo(String scopeShapeId, boolean isYMove, double yMoveDistance) throws AWSException{ if (scopeShapeMonitorMap == null) return; if (!scopeShapeMonitorMap.containsKey(scopeShapeId)) throw new AWSException("【参数异常】当前范围框监视器不包含图形ID【" + scopeShapeId + "】"); MonitorInfo monitorInfo = scopeShapeMonitorMap.get(scopeShapeId); - monitorInfo.setBottomMove(isBottomMove); - monitorInfo.setBottomMoveDistance(bottomMoveDistance); + monitorInfo.setyMove(isYMove); + monitorInfo.setyMoveDistance(yMoveDistance); } /** @@ -124,46 +124,43 @@ public class ScopeShapeMonitor { for (String scopeShapeKey : scopeShapeMonitorMap.keySet()) { MonitorInfo monitorInfo = scopeShapeMonitorMap.get(scopeShapeKey); Set inRangeShapeIdSet = monitorInfo.getInRangeShapeIdSet(); - if (monitorInfo.isRightMove()){ - double rightMoveDistance = monitorInfo.getRightMoveDistance(); - for (String key : inRangeShapeIdSet) { - JSONObject shape = definitionHandle.getShapeByKey(key); + for (String key : inRangeShapeIdSet) { + JSONObject shape = definitionHandle.getShapeByKey(key); + if (monitorInfo.isxMove()){ // x轴上发生移动 + double xMoveDIstance = monitorInfo.getxMoveDistance(); if ("linker".equals(shape.getString("name"))){ JSONObject from = shape.getJSONObject("from"); - from.put("x", from.getDoubleValue("x") + rightMoveDistance); + from.put("x", from.getDoubleValue("x") + xMoveDIstance); JSONObject to = shape.getJSONObject("to"); - to.put("x", to.getDoubleValue("x") + rightMoveDistance); + to.put("x", to.getDoubleValue("x") + xMoveDIstance); JSONArray points = shape.getJSONArray("points"); for (Object o : points) { JSONObject point = (JSONObject) o; - point.put("x", point.getDoubleValue("x") + rightMoveDistance); + point.put("x", point.getDoubleValue("x") + xMoveDIstance); } }else { JSONObject props = definitionHandle.getShapeByProps(key); - props.put("x", props.getDoubleValue("x") + rightMoveDistance); + props.put("x", props.getDoubleValue("x") + xMoveDIstance); } } - } - if (monitorInfo.isBottomMove()){ - double bottomMoveDistance = monitorInfo.getBottomMoveDistance(); - for (String key : inRangeShapeIdSet) { - JSONObject shape = definitionHandle.getShapeByKey(key); + if (monitorInfo.isyMove()){ // y轴上发生移动 + double yMoveDistance = monitorInfo.getyMoveDistance(); if ("linker".equals(shape.getString("name"))){ JSONObject from = shape.getJSONObject("from"); - from.put("y", from.getDoubleValue("y") + bottomMoveDistance); + from.put("y", from.getDoubleValue("y") + yMoveDistance); JSONObject to = shape.getJSONObject("to"); - to.put("y", to.getDoubleValue("y") + bottomMoveDistance); + to.put("y", to.getDoubleValue("y") + yMoveDistance); JSONArray points = shape.getJSONArray("points"); for (Object o : points) { JSONObject point = (JSONObject) o; - point.put("y", point.getDoubleValue("y") + bottomMoveDistance); + point.put("y", point.getDoubleValue("y") + yMoveDistance); } }else { JSONObject props = definitionHandle.getShapeByProps(key); - props.put("y", props.getDoubleValue("y") + bottomMoveDistance); + props.put("y", props.getDoubleValue("y") + yMoveDistance); } } } @@ -175,52 +172,52 @@ public class ScopeShapeMonitor { class MonitorInfo { private String scopeShapeId; // 当前虚线范围框的图形ID - private boolean isRightMove; // 范围框是否右移 - private double rightMoveDistance; // 右移动距离 - private boolean isBottomMove; // 范围框是否下移 - private double bottomMoveDistance; // 下移距离 + private boolean xMove; // 范围框发生左移或者右移 + private double xMoveDistance; // 左移或者右移动距离 + private boolean yMove; // 范围框发生上移或者下移 + private double yMoveDistance; // 上移或者下移距离 private Set inRangeShapeIdSet; // 范围内的图形与连线的ID集合 - public MonitorInfo(String scopeShapeId, boolean isRightMove, double rightMoveDistance, boolean isBottomMove, double bottomMoveDistance, Set inRangeShapeIdSet) { + public MonitorInfo(String scopeShapeId, boolean xMove, double xMoveDistance, boolean yMove, double yMoveDistance, Set inRangeShapeIdSet) { this.scopeShapeId = scopeShapeId; - this.isRightMove = isRightMove; - this.rightMoveDistance = rightMoveDistance; - this.isBottomMove = isBottomMove; - this.bottomMoveDistance = bottomMoveDistance; + this.xMove = xMove; + this.xMoveDistance = xMoveDistance; + this.yMove = yMove; + this.yMoveDistance = yMoveDistance; this.inRangeShapeIdSet = inRangeShapeIdSet; } - public boolean isRightMove() { - return isRightMove; + public boolean isxMove() { + return xMove; } - public double getRightMoveDistance() { - return rightMoveDistance; + public void setxMove(boolean xMove) { + this.xMove = xMove; } - public boolean isBottomMove() { - return isBottomMove; + public double getxMoveDistance() { + return xMoveDistance; } - public double getBottomMoveDistance() { - return bottomMoveDistance; + public void setxMoveDistance(double xMoveDistance) { + this.xMoveDistance = xMoveDistance; } - public void setRightMove(boolean rightMove) { - isRightMove = rightMove; + public boolean isyMove() { + return yMove; } - public void setRightMoveDistance(double rightMoveDistance) { - this.rightMoveDistance = rightMoveDistance; + public void setyMove(boolean yMove) { + this.yMove = yMove; } - public void setBottomMove(boolean bottomMove) { - isBottomMove = bottomMove; + public double getyMoveDistance() { + return yMoveDistance; } - public void setBottomMoveDistance(double bottomMoveDistance) { - this.bottomMoveDistance = bottomMoveDistance; + public void setyMoveDistance(double yMoveDistance) { + this.yMoveDistance = yMoveDistance; } public Set getInRangeShapeIdSet() {