Excel导入流程图review,处理层级跳级以及递归跳级问题处理
This commit is contained in:
parent
c6179a3d90
commit
a742c34d5a
Binary file not shown.
@ -628,7 +628,7 @@ public class ImportShapeExcel1 {
|
||||
|
||||
double leftLine = leftMinLine;
|
||||
//递归处理父级所有图形+连线的x的偏移量
|
||||
double upLeftLine = this.changeUpLeftOffset(nodes.get(0), levelMap, nodeMap, offset, leftLine);
|
||||
double upLeftLine = this.changeUpLeftOffset(nodes.get(0).getShapeNum(), levelMap, nodeMap, offset, leftLine);
|
||||
|
||||
leftLine = Math.min(leftLine,upLeftLine);
|
||||
|
||||
@ -637,17 +637,16 @@ public class ImportShapeExcel1 {
|
||||
leftLine = Math.min(leftLine,moveLeftLine);
|
||||
|
||||
//递归处理子级所有图形+连线x的偏移量
|
||||
double subLeftLine = this.changeSubLeftOffset(nodes.get(0), levelMap, nodeMap, offset, leftLine);
|
||||
double subLeftLine = this.changeSubLeftOffset(nodes.get(0).getShapeNum(), levelMap, nodeMap, offset, leftLine);
|
||||
leftLine = Math.min(leftLine,subLeftLine);
|
||||
|
||||
return Math.min(leftLine,leftMinLine);
|
||||
|
||||
}
|
||||
|
||||
private double changeUpLeftOffset(CellObject node,Map<String, Map<String, List<CellObject>>> levelMap,Map<String,List<JSONObject>> nodeMap,double offset,double leftMinLine){
|
||||
private double changeUpLeftOffset(String shapeNum,Map<String, Map<String, List<CellObject>>> levelMap,Map<String,List<JSONObject>> nodeMap,double offset,double leftMinLine){
|
||||
|
||||
double leftLine = leftMinLine;
|
||||
String shapeNum = node.getShapeNum();
|
||||
if (!shapeNum.contains(".")){
|
||||
return leftLine;
|
||||
}
|
||||
@ -655,21 +654,31 @@ public class ImportShapeExcel1 {
|
||||
String[] split = shapeNum.split("\\.");
|
||||
String level = ""+ (Integer.parseInt(split[0])-1);
|
||||
String branch = split[1];
|
||||
if (Integer.parseInt(level)<0){
|
||||
return leftLine;
|
||||
}
|
||||
|
||||
Map<String, List<CellObject>> numList = levelMap.get(level);
|
||||
|
||||
if (null == numList){
|
||||
//层级跳级处理
|
||||
double upLeftLine = this.changeUpLeftOffset(level+"."+branch, levelMap, nodeMap, offset, leftLine);
|
||||
leftLine = Math.min(leftLine,upLeftLine);
|
||||
return Math.min(leftLine,leftMinLine);
|
||||
}
|
||||
|
||||
List<CellObject> upList = numList.get(level + "." + branch);
|
||||
if (upList == null || upList.isEmpty()){
|
||||
return leftLine;
|
||||
//分支父级跳级处理
|
||||
double upLeftLine = this.changeUpLeftOffset(level+"."+branch, levelMap, nodeMap, offset, leftLine);
|
||||
leftLine = Math.min(leftLine,upLeftLine);
|
||||
return Math.min(leftLine,leftMinLine);
|
||||
}
|
||||
double upLeftLine = this.changeUpLeftOffset(upList.get(0), levelMap, nodeMap, offset, leftLine);
|
||||
|
||||
double upLeftLine = this.changeUpLeftOffset(upList.get(0).getShapeNum(), levelMap, nodeMap, offset, leftLine);
|
||||
leftLine = Math.min(leftLine,upLeftLine);
|
||||
|
||||
//移动父级节点
|
||||
double moveLeftLine = this.moveLeftNode(upList, nodeMap, offset, leftLine,true,false);
|
||||
|
||||
leftLine = Math.min(leftLine,moveLeftLine);
|
||||
|
||||
return Math.min(leftLine,leftMinLine);
|
||||
@ -723,9 +732,8 @@ public class ImportShapeExcel1 {
|
||||
return leftLine;
|
||||
}
|
||||
|
||||
private double changeSubLeftOffset(CellObject node,Map<String, Map<String, List<CellObject>>> levelMap,Map<String,List<JSONObject>> nodeMap,double offset,double leftMinLine){
|
||||
private double changeSubLeftOffset(String shapeNum,Map<String, Map<String, List<CellObject>>> levelMap,Map<String,List<JSONObject>> nodeMap,double offset,double leftMinLine){
|
||||
double leftLine = leftMinLine;
|
||||
String shapeNum = node.getShapeNum();
|
||||
|
||||
if (!shapeNum.contains(".")){
|
||||
return leftLine;
|
||||
@ -735,8 +743,18 @@ public class ImportShapeExcel1 {
|
||||
String[] split = shapeNum.split("\\.");
|
||||
String level = ""+ (Integer.parseInt(split[0])+1);
|
||||
String branch = split[1];
|
||||
if (Integer.parseInt(level)<0){
|
||||
return leftLine;
|
||||
}
|
||||
|
||||
Map<String, List<CellObject>> numList = levelMap.get(level);
|
||||
if(null == numList){
|
||||
//层级跳级处理
|
||||
double subLeftOffset = this.changeSubLeftOffset(level+"."+branch, levelMap, nodeMap, offset, leftLine);
|
||||
leftLine = Math.min(leftLine,subLeftOffset);
|
||||
return Math.min(leftLine,leftMinLine);
|
||||
}
|
||||
|
||||
List<CellObject> subList = numList.get(level + "." + branch);
|
||||
if (subList == null || subList.isEmpty()){
|
||||
subList = numList.get(level);
|
||||
@ -766,17 +784,19 @@ public class ImportShapeExcel1 {
|
||||
}
|
||||
|
||||
}
|
||||
}else {
|
||||
//下级分支跳级直连
|
||||
double subLeftOffset = this.changeSubLeftOffset(level+"."+branch, levelMap, nodeMap, offset, leftLine);
|
||||
leftLine = Math.min(leftLine,subLeftOffset);
|
||||
}
|
||||
return leftLine;
|
||||
return Math.min(leftLine,leftMinLine);
|
||||
}
|
||||
|
||||
double subLeftOffset = this.changeSubLeftOffset(subList.get(0), levelMap, nodeMap, offset, leftLine);
|
||||
|
||||
double subLeftOffset = this.changeSubLeftOffset(subList.get(0).getShapeNum(), levelMap, nodeMap, offset, leftLine);
|
||||
leftLine = Math.min(leftLine,subLeftOffset);
|
||||
|
||||
//移动子级节点
|
||||
double moveLeftLine = this.moveLeftNode(subList, nodeMap, offset, leftLine,true,true);
|
||||
|
||||
leftLine = Math.min(leftLine,moveLeftLine);
|
||||
|
||||
return Math.min(leftLine,leftMinLine);
|
||||
@ -786,7 +806,7 @@ public class ImportShapeExcel1 {
|
||||
|
||||
double rightLine = rightMaxLine;
|
||||
//递归处理父级所有图形+连线的x的偏移量
|
||||
double upRightOffset = this.changeUpRightOffset(nodes.get(0), levelMap, nodeMap, offset, rightLine);
|
||||
double upRightOffset = this.changeUpRightOffset(nodes.get(0).getShapeNum(), levelMap, nodeMap, offset, rightLine);
|
||||
|
||||
rightLine = Math.max(rightLine,upRightOffset);
|
||||
|
||||
@ -795,15 +815,14 @@ public class ImportShapeExcel1 {
|
||||
rightLine = Math.max(rightLine,moveRightOffset);
|
||||
|
||||
//递归处理子级所有图形+连线x的偏移量
|
||||
double subRightOffset = this.changeSubRightOffset(nodes.get(0), levelMap, nodeMap, offset, rightLine);
|
||||
double subRightOffset = this.changeSubRightOffset(nodes.get(0).getShapeNum(), levelMap, nodeMap, offset, rightLine);
|
||||
rightLine = Math.max(subRightOffset,rightLine);
|
||||
|
||||
return Math.max(rightLine,rightMaxLine);
|
||||
}
|
||||
|
||||
private double changeUpRightOffset(CellObject node,Map<String, Map<String, List<CellObject>>> levelMap,Map<String,List<JSONObject>> nodeMap,double offset,double rightMaxLine){
|
||||
private double changeUpRightOffset(String shapeNum,Map<String, Map<String, List<CellObject>>> levelMap,Map<String,List<JSONObject>> nodeMap,double offset,double rightMaxLine){
|
||||
double rightLine = rightMaxLine;
|
||||
String shapeNum = node.getShapeNum();
|
||||
if (!shapeNum.contains(".")){
|
||||
return rightLine;
|
||||
}
|
||||
@ -812,14 +831,28 @@ public class ImportShapeExcel1 {
|
||||
String[] split = shapeNum.split("\\.");
|
||||
String level = ""+ (Integer.parseInt(split[0])-1);
|
||||
String branch = split[1];
|
||||
Map<String, List<CellObject>> numList = levelMap.get(level);
|
||||
List<CellObject> upList = numList.get(level + "." + branch);
|
||||
if (upList == null || upList.isEmpty()){
|
||||
if (Integer.parseInt(level)<0){
|
||||
return rightLine;
|
||||
}
|
||||
|
||||
double upRightOffset = this.changeUpRightOffset(upList.get(0), levelMap, nodeMap, offset, rightLine);
|
||||
|
||||
Map<String, List<CellObject>> numList = levelMap.get(level);
|
||||
if (null == numList){
|
||||
//层级跳级 处理
|
||||
double upRightOffset = this.changeUpRightOffset(level+"."+branch, levelMap, nodeMap, offset, rightLine);
|
||||
rightLine = Math.max(rightLine,upRightOffset);
|
||||
return Math.max(rightLine,rightMaxLine);
|
||||
}
|
||||
|
||||
List<CellObject> upList = numList.get(level + "." + branch);
|
||||
if (upList == null || upList.isEmpty()){
|
||||
//分支父级跳级处理
|
||||
double upRightOffset = this.changeUpRightOffset(level+"."+branch, levelMap, nodeMap, offset, rightLine);
|
||||
rightLine = Math.max(rightLine,upRightOffset);
|
||||
return Math.max(rightLine,rightMaxLine);
|
||||
}
|
||||
|
||||
double upRightOffset = this.changeUpRightOffset(upList.get(0).getShapeNum(), levelMap, nodeMap, offset, rightLine);
|
||||
rightLine = Math.max(rightLine,upRightOffset);
|
||||
|
||||
//移动父节点x的偏移量
|
||||
@ -878,10 +911,8 @@ public class ImportShapeExcel1 {
|
||||
return rightLine;
|
||||
}
|
||||
|
||||
private double changeSubRightOffset(CellObject node,Map<String, Map<String, List<CellObject>>> levelMap,Map<String,List<JSONObject>> nodeMap,double offset,double rightMaxLine){
|
||||
private double changeSubRightOffset(String shapeNum,Map<String, Map<String, List<CellObject>>> levelMap,Map<String,List<JSONObject>> nodeMap,double offset,double rightMaxLine){
|
||||
double rightLine = rightMaxLine;
|
||||
String shapeNum = node.getShapeNum();
|
||||
|
||||
if (!shapeNum.contains(".")){
|
||||
return rightLine;
|
||||
}
|
||||
@ -890,10 +921,18 @@ public class ImportShapeExcel1 {
|
||||
String[] split = shapeNum.split("\\.");
|
||||
String level = ""+ (Integer.parseInt(split[0])+1);
|
||||
String branch = split[1];
|
||||
if (Integer.parseInt(level)<0){
|
||||
return rightLine;
|
||||
}
|
||||
|
||||
Map<String, List<CellObject>> numList = levelMap.get(level);
|
||||
if(null == numList){
|
||||
//层级跳级处理
|
||||
double subRightOffset = this.changeSubRightOffset(level + "." + branch, levelMap, nodeMap, offset, rightLine);
|
||||
rightLine = Math.max(rightLine,subRightOffset);
|
||||
return Math.max(rightLine,rightMaxLine);
|
||||
}
|
||||
List<CellObject> subList = numList.get(level + "." + branch);
|
||||
|
||||
if (subList == null || subList.isEmpty()){
|
||||
subList = numList.get(level);
|
||||
if (subList != null){
|
||||
@ -919,17 +958,19 @@ public class ImportShapeExcel1 {
|
||||
}
|
||||
}
|
||||
}
|
||||
}else{
|
||||
//分支下级跳级处理
|
||||
double subRightOffset = this.changeSubRightOffset(level + "." + branch, levelMap, nodeMap, offset, rightLine);
|
||||
rightLine = Math.max(rightLine,subRightOffset);
|
||||
}
|
||||
return rightLine;
|
||||
return Math.max(rightLine,rightMaxLine);
|
||||
}
|
||||
|
||||
double subRightOffset = this.changeSubRightOffset(subList.get(0), levelMap, nodeMap, offset, rightLine);
|
||||
|
||||
double subRightOffset = this.changeSubRightOffset(subList.get(0).getShapeNum(), levelMap, nodeMap, offset, rightLine);
|
||||
rightLine = Math.max(rightLine,subRightOffset);
|
||||
|
||||
//移动子级节点
|
||||
double moveRightOffset = this.moveRightNode(subList, nodeMap, offset, rightLine, true, true);
|
||||
|
||||
rightLine = Math.max(rightLine,moveRightOffset);
|
||||
|
||||
return Math.max(rightLine,rightMaxLine);
|
||||
@ -1498,6 +1539,12 @@ public class ImportShapeExcel1 {
|
||||
}
|
||||
|
||||
Map<String, List<CellObject>> numList = levelMap.get(level);
|
||||
if (null == numList){
|
||||
//跳级 直接递归找上级
|
||||
List<CellObject> upBranchNode = this.findUpBranchNode(levelMap, level + "." + branch);
|
||||
list.addAll(upBranchNode);
|
||||
return list;
|
||||
}
|
||||
|
||||
List<CellObject> cellObjects = numList.get(level + "." + branch);
|
||||
if (cellObjects==null){
|
||||
|
||||
Loading…
Reference in New Issue
Block a user