端到端功能 节点展开与闭合功能优化
This commit is contained in:
parent
1e600221fd
commit
99c43f7571
Binary file not shown.
@ -53,7 +53,7 @@ public class GraphNodeCloseHandle {
|
||||
|
||||
scopeLimitationShape = definitionHandle.getShapeByKey(shapeId);
|
||||
|
||||
scopeShapeMonitor = new ScopeShapeMonitor(definitionHandle, subProcessNodeDefineHandle);
|
||||
scopeShapeMonitor = new ScopeShapeMonitor(definitionHandle);
|
||||
|
||||
} catch (AWSException e) {
|
||||
throw new AWSException(e);
|
||||
@ -76,6 +76,8 @@ public class GraphNodeCloseHandle {
|
||||
// 2、处理总图中的节点与连线
|
||||
handleEndToEndGraphNodeAndLinker();
|
||||
|
||||
scopeShapeMonitor.updateScopeShapeInnerEle();
|
||||
|
||||
return definitionHandle.getDefine().toJSONString();
|
||||
}
|
||||
|
||||
@ -103,12 +105,10 @@ public class GraphNodeCloseHandle {
|
||||
definitionHandle.addEle(linker.getString("id"), linker);
|
||||
}
|
||||
|
||||
scopeShapeMonitor.updateScopeShapeInnerEle();
|
||||
|
||||
// 6、更新画布的大小
|
||||
// 确定画布的宽度与高度
|
||||
double w = Arrays.stream(vertexBounding).mapToDouble(position -> position[0]).max().orElse(0.0);
|
||||
double h = Arrays.stream(vertexBounding).mapToDouble(position -> position[1]).max().orElse(0.0);
|
||||
double w = Arrays.stream(vertexBounding).mapToDouble(position -> position[0] + position[2]).max().orElse(0.0);
|
||||
double h = Arrays.stream(vertexBounding).mapToDouble(position -> position[1] + position[3]).max().orElse(0.0);
|
||||
|
||||
JSONObject page = definitionHandle.getPage();
|
||||
page.put("width", w + 300);
|
||||
|
||||
@ -53,7 +53,7 @@ public class GraphNodeExpandHandle {
|
||||
definitionHandle = new DefinitionThreadUnSafe(endToEndProcessDefineStr);
|
||||
subProcessNodeDefineHandle = new DefinitionThreadUnSafe(SubProcessNodeDefineUtil.readSubProcessNodeDefine(repositoryId, shapeId));
|
||||
|
||||
scopeShapeMonitor = new ScopeShapeMonitor(definitionHandle, subProcessNodeDefineHandle);
|
||||
scopeShapeMonitor = new ScopeShapeMonitor(definitionHandle);
|
||||
|
||||
toAssembleScopeLimitationShape();
|
||||
} catch (Exception e) {
|
||||
@ -103,15 +103,18 @@ public class GraphNodeExpandHandle {
|
||||
*/
|
||||
public String handleNodeExpand() throws AWSException{
|
||||
|
||||
// 1、甄别总图中的范围标识框以及其内的节点
|
||||
// 1、构建范围框监视器模型 并关联内部元素
|
||||
scopeShapeMonitor.buildScopeShapeMonitors();
|
||||
|
||||
// 2、总图节点以及连线处理
|
||||
handleEndToEndGraphNodeAndLinker();
|
||||
|
||||
// 3、子流程节点内部元素处理
|
||||
// 3、当前展开的子流程节点内部元素 以及 范围框处理
|
||||
handleRelationModelNodePosition();
|
||||
|
||||
// 4、范围框内的元素 坐标更新
|
||||
scopeShapeMonitor.updateScopeShapeInnerEle();
|
||||
|
||||
return definitionHandle.getDefine().toJSONString();
|
||||
}
|
||||
|
||||
@ -154,13 +157,10 @@ public class GraphNodeExpandHandle {
|
||||
definitionHandle.addEle(linker.getString("id"), linker);
|
||||
}
|
||||
|
||||
// 范围框内的元素 坐标更新
|
||||
scopeShapeMonitor.updateScopeShapeInnerEle();
|
||||
|
||||
// 8、更新画布的大小
|
||||
// 确定画布的宽度与高度
|
||||
double w = Arrays.stream(vertexBounding).mapToDouble(position -> position[0]).max().orElse(0.0);
|
||||
double h = Arrays.stream(vertexBounding).mapToDouble(position -> position[1]).max().orElse(0.0);
|
||||
double w = Arrays.stream(vertexBounding).mapToDouble(position -> position[0] + position[2]).max().orElse(0.0);
|
||||
double h = Arrays.stream(vertexBounding).mapToDouble(position -> position[1] + position[3]).max().orElse(0.0);
|
||||
|
||||
JSONObject page = definitionHandle.getPage();
|
||||
page.put("width", w + 300);
|
||||
@ -227,9 +227,9 @@ 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 (ele.getString("id").equals(scopeLimitationShape.getString("id"))) continue;
|
||||
if (scopeShapeMonitor.checkShapeIsScopeInRange(key)) continue;
|
||||
JSONObject props = ele.getJSONObject("props");
|
||||
if ("vertically".equals(direction)){
|
||||
if (props.getDoubleValue("x") > scopeShapeX) { // 当前元素在待展开节点的右侧
|
||||
double rightMoveDistance = scopeShapeW - SubProcessConst.SUB_PROCESS_SHAPE_W;
|
||||
|
||||
@ -58,7 +58,7 @@ public class SubProcessNodeDefineUtil {
|
||||
}
|
||||
|
||||
/**
|
||||
* 计算子流程节点 展开后的宽度与高度
|
||||
* 计算当前子流程节点 展开后的宽度与高度以及在子流程文件中的坐标
|
||||
* @param definitionHandle
|
||||
* @return double[]{x, y, w, h}
|
||||
*/
|
||||
|
||||
@ -7,24 +7,23 @@ import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author oYang
|
||||
* @Description 虚线范围框及其内部元素的监视器模型
|
||||
* @Description 构建虚线范围框监视器模型且关联其内部元素 方便最后调整范围框内的元素
|
||||
* @createTime 2023年06月13日 14:46:00
|
||||
*/
|
||||
public class ScopeShapeMonitor {
|
||||
|
||||
private AbstractDefinitionHandle definitionHandle; // 总图 define 处理器
|
||||
private AbstractDefinitionHandle subProcessDefineHandle; // 子流程节点 define 处理器
|
||||
private Map<String, MonitorInfo> scopeShapeMonitorMap; // 范围框及内部元素集合
|
||||
|
||||
public ScopeShapeMonitor(AbstractDefinitionHandle definitionHandle, AbstractDefinitionHandle subProcessDefineHandle) {
|
||||
public ScopeShapeMonitor(AbstractDefinitionHandle definitionHandle) {
|
||||
this.definitionHandle = definitionHandle;
|
||||
this.subProcessDefineHandle = subProcessDefineHandle;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -40,8 +39,29 @@ public class ScopeShapeMonitor {
|
||||
|
||||
Map<String, MonitorInfo> scopeShapeMonitorMap = new HashMap<>();
|
||||
for (String scopeShapeKey : scopeShapeKeySet) {
|
||||
Set<String> inScopeLimitationRangeEles = SubProcessNodeDefineUtil.getInScopeLimitationRangeEles(scopeShapeKey, definitionHandle, subProcessDefineHandle);
|
||||
MonitorInfo monitorInfo = new MonitorInfo(scopeShapeKey, false, 0.0, false, 0.0, inScopeLimitationRangeEles);
|
||||
JSONObject props = definitionHandle.getShapeByProps(scopeShapeKey);
|
||||
double scopeX = props.getDoubleValue("x"), scopeY = props.getDoubleValue("y"), scopeW = props.getDoubleValue("w"), scopeH = props.getDoubleValue("h");
|
||||
// 判断当前元素是否在范围选择框的范围内
|
||||
Set<String> inRangeEleKeySet = new HashSet<>();
|
||||
for (String key : elements.keySet()) {
|
||||
if (scopeShapeKey.equals(key)) continue; // 范围框本身不算作其内部元素
|
||||
JSONObject shape = definitionHandle.getShapeByKey(key);
|
||||
if ("linker".equals(shape.getString("name"))){ // 连线
|
||||
JSONObject from = shape.getJSONObject("from");
|
||||
JSONObject to = shape.getJSONObject("to");
|
||||
double fromX = from.getDoubleValue("x"), fromY = from.getDoubleValue("y"), toX = to.getDoubleValue("x"), toY = to.getDoubleValue("y");
|
||||
if ((scopeX < fromX && fromX < scopeX + scopeW && scopeY < fromY && fromY < scopeY + scopeH) || (scopeX < toX && toX < scopeX + scopeW && scopeY < toY && toY < scopeY + scopeH)){
|
||||
inRangeEleKeySet.add(key);
|
||||
}
|
||||
}else {
|
||||
double x = definitionHandle.getShapeByProps(key).getDoubleValue("x");
|
||||
double y = definitionHandle.getShapeByProps(key).getDoubleValue("y");
|
||||
if (scopeX <= x && x < scopeX + scopeW && scopeY <= y && y < scopeY + scopeH){
|
||||
inRangeEleKeySet.add(key);
|
||||
}
|
||||
}
|
||||
}
|
||||
MonitorInfo monitorInfo = new MonitorInfo(scopeShapeKey, false, 0.0, false, 0.0, inRangeEleKeySet);
|
||||
scopeShapeMonitorMap.put(scopeShapeKey, monitorInfo);
|
||||
}
|
||||
this.scopeShapeMonitorMap = scopeShapeMonitorMap;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user