端到端功能 图生成前置处理 节点根据被指向的连线数量进行排序

This commit is contained in:
qinoy 2023-05-29 17:03:16 +08:00
parent a9ea67c8da
commit 1a0a4cd15f
4 changed files with 50 additions and 6 deletions

View File

@ -225,7 +225,7 @@ public class GraphLayout {
if (unIsPosition.size() == 1){ if (unIsPosition.size() == 1){
position[rearNodeIndex][0] = position[nodeIndex][0]; // 当前节点的如果为第一个后置节点 坐标x的值一致 position[rearNodeIndex][0] = position[nodeIndex][0]; // 当前节点的如果为第一个后置节点 坐标x的值一致
}else { }else {
position[rearNodeIndex][0] = position[nodeIndex][0] + shapeW + (unIsPosition.size() - 1) * horizInterval; // 非第一个后置节点的坐标x = 上一个节点的坐标x + 图形宽度 + 第几个后置节点 * 横向间隔 position[rearNodeIndex][0] = realTimeX + shapeW + (unIsPosition.size() - 1) * horizInterval; // 非第一个后置节点的坐标x = 上一个节点的坐标x + 图形宽度 + 第几个后置节点 * 横向间隔
realTimeX = position[rearNodeIndex][0]; realTimeX = position[rearNodeIndex][0];
} }
isPosition[rearNodeIndex] = true; isPosition[rearNodeIndex] = true;

View File

@ -113,6 +113,8 @@ public class VertexPreHandle {
* 如果未在选择的范围内 则忽略 * 如果未在选择的范围内 则忽略
* *
* 同时处理节点的前后置关系 * 同时处理节点的前后置关系
*
* 同时根据当前节点被指向的线条数量排序 由低到高
* @param processIdList * @param processIdList
* @param nodeIndexMap * @param nodeIndexMap
* @return 按照节点前置流程数量 从小到大排序 * @return 按照节点前置流程数量 从小到大排序
@ -120,15 +122,23 @@ public class VertexPreHandle {
*/ */
public List<Node> excludeLearAndRearNode(List<String> processIdList, Map<String, Integer> nodeIndexMap) throws AWSException { public List<Node> excludeLearAndRearNode(List<String> processIdList, Map<String, Integer> nodeIndexMap) throws AWSException {
List<Node> nodeList = new ArrayList<>(); List<Node> nodeList = new ArrayList<>();
Map<String, Integer> pointsMap = new HashMap<>();
for (int i = 0; i < processIdList.size(); i++) { for (int i = 0; i < processIdList.size(); i++) {
Node node = new Node(processIdList.get(i)); Node node = new Node(processIdList.get(i), PALRepositoryCache.getCache().get(processIdList.get(i)).getName());
// 前置流程 // 前置流程
List<DesignerShapeRelationModel> leadProcessList = DesignerShapeRelationCache.getByFileId(processIdList.get(i), SubProcessConst.LEAD_PROCESS_ATTR_ID); List<DesignerShapeRelationModel> leadProcessList = DesignerShapeRelationCache.getByFileId(processIdList.get(i), SubProcessConst.LEAD_PROCESS_ATTR_ID);
List<Node> leadNodeList = new ArrayList<>(); List<Node> leadNodeList = new ArrayList<>();
leadProcessList.stream().forEach(model -> { leadProcessList.stream().forEach(model -> {
if (processIdList.contains(model.getRelationFileId())){ if (processIdList.contains(model.getRelationFileId())){
Node leadNode = new Node(model.getRelationFileId()); Node leadNode = new Node(model.getRelationFileId(), PALRepositoryCache.getCache().get(model.getRelationFileId()).getName());
leadNodeList.add(leadNode); leadNodeList.add(leadNode);
// 当前节点被指向的线条数+1
if (pointsMap.containsKey(node.getId())) {
pointsMap.put(node.getId(), pointsMap.get(node.getId()).intValue() + 1);
} else {
pointsMap.put(node.getId(), 1);
}
} }
}); });
node.setLeadNodeList(leadNodeList); node.setLeadNodeList(leadNodeList);
@ -137,8 +147,14 @@ public class VertexPreHandle {
List<Node> rearNodeList = new ArrayList<>(); List<Node> rearNodeList = new ArrayList<>();
rearProcessList.stream().forEach(model -> { rearProcessList.stream().forEach(model -> {
if (processIdList.contains(model.getRelationFileId())){ if (processIdList.contains(model.getRelationFileId())){
Node rearNode = new Node(model.getRelationFileId()); Node rearNode = new Node(model.getRelationFileId(), PALRepositoryCache.getCache().get(model.getRelationFileId()).getName());
rearNodeList.add(rearNode); rearNodeList.add(rearNode);
if (pointsMap.containsKey(model.getRelationFileId())) {
pointsMap.put(model.getRelationFileId(), pointsMap.get(model.getRelationFileId()).intValue() + 1);
} else {
pointsMap.put(model.getRelationFileId(), 1);
}
} }
}); });
node.setRearNodeList(rearNodeList); node.setRearNodeList(rearNodeList);
@ -147,6 +163,12 @@ public class VertexPreHandle {
nodeIndexMap.put(node.getId(), nodeList.size() - 1); nodeIndexMap.put(node.getId(), nodeList.size() - 1);
} }
for (Node node : nodeList) {
if (pointsMap.containsKey(node.getId())){
node.setPoints(pointsMap.get(node.getId()));
}
}
Collections.sort(nodeList); Collections.sort(nodeList);
return nodeList; return nodeList;
} }

View File

@ -10,14 +10,20 @@ import java.util.Objects;
public class Node implements Comparable<Node> { public class Node implements Comparable<Node> {
private String id; private String id;
private String name;
private List<Node> leadNodeList; private List<Node> leadNodeList;
private List<Node> rearNodeList; private List<Node> rearNodeList;
private int points; // 被指向的线条数
public Node(String id) { public Node(String id) {
this.id = id; this.id = id;
} }
public Node(String id, String name) {
this.id = id;
this.name = name;
}
public String getId() { public String getId() {
return id; return id;
} }
@ -26,6 +32,14 @@ public class Node implements Comparable<Node> {
this.id = id; this.id = id;
} }
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public List<Node> getLeadNodeList() { public List<Node> getLeadNodeList() {
return leadNodeList; return leadNodeList;
} }
@ -42,6 +56,14 @@ public class Node implements Comparable<Node> {
this.rearNodeList = rearNodeList; this.rearNodeList = rearNodeList;
} }
public int getPoints() {
return points;
}
public void setPoints(int points) {
this.points = points;
}
@Override @Override
public boolean equals(Object o) { public boolean equals(Object o) {
if (this == o) return true; if (this == o) return true;
@ -57,6 +79,6 @@ public class Node implements Comparable<Node> {
@Override @Override
public int compareTo(Node node) { public int compareTo(Node node) {
return Integer.compare(this.leadNodeList.size(), node.getLeadNodeList().size()); return Integer.compare(this.points, node.points);
} }
} }