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;
|
double leftLine = leftMinLine;
|
||||||
//递归处理父级所有图形+连线的x的偏移量
|
//递归处理父级所有图形+连线的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);
|
leftLine = Math.min(leftLine,upLeftLine);
|
||||||
|
|
||||||
@ -637,17 +637,16 @@ public class ImportShapeExcel1 {
|
|||||||
leftLine = Math.min(leftLine,moveLeftLine);
|
leftLine = Math.min(leftLine,moveLeftLine);
|
||||||
|
|
||||||
//递归处理子级所有图形+连线x的偏移量
|
//递归处理子级所有图形+连线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);
|
leftLine = Math.min(leftLine,subLeftLine);
|
||||||
|
|
||||||
return Math.min(leftLine,leftMinLine);
|
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;
|
double leftLine = leftMinLine;
|
||||||
String shapeNum = node.getShapeNum();
|
|
||||||
if (!shapeNum.contains(".")){
|
if (!shapeNum.contains(".")){
|
||||||
return leftLine;
|
return leftLine;
|
||||||
}
|
}
|
||||||
@ -655,21 +654,31 @@ public class ImportShapeExcel1 {
|
|||||||
String[] split = shapeNum.split("\\.");
|
String[] split = shapeNum.split("\\.");
|
||||||
String level = ""+ (Integer.parseInt(split[0])-1);
|
String level = ""+ (Integer.parseInt(split[0])-1);
|
||||||
String branch = split[1];
|
String branch = split[1];
|
||||||
|
if (Integer.parseInt(level)<0){
|
||||||
|
return leftLine;
|
||||||
|
}
|
||||||
|
|
||||||
Map<String, List<CellObject>> numList = levelMap.get(level);
|
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);
|
List<CellObject> upList = numList.get(level + "." + branch);
|
||||||
if (upList == null || upList.isEmpty()){
|
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);
|
leftLine = Math.min(leftLine,upLeftLine);
|
||||||
|
|
||||||
//移动父级节点
|
//移动父级节点
|
||||||
double moveLeftLine = this.moveLeftNode(upList, nodeMap, offset, leftLine,true,false);
|
double moveLeftLine = this.moveLeftNode(upList, nodeMap, offset, leftLine,true,false);
|
||||||
|
|
||||||
leftLine = Math.min(leftLine,moveLeftLine);
|
leftLine = Math.min(leftLine,moveLeftLine);
|
||||||
|
|
||||||
return Math.min(leftLine,leftMinLine);
|
return Math.min(leftLine,leftMinLine);
|
||||||
@ -723,9 +732,8 @@ public class ImportShapeExcel1 {
|
|||||||
return leftLine;
|
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;
|
double leftLine = leftMinLine;
|
||||||
String shapeNum = node.getShapeNum();
|
|
||||||
|
|
||||||
if (!shapeNum.contains(".")){
|
if (!shapeNum.contains(".")){
|
||||||
return leftLine;
|
return leftLine;
|
||||||
@ -735,8 +743,18 @@ public class ImportShapeExcel1 {
|
|||||||
String[] split = shapeNum.split("\\.");
|
String[] split = shapeNum.split("\\.");
|
||||||
String level = ""+ (Integer.parseInt(split[0])+1);
|
String level = ""+ (Integer.parseInt(split[0])+1);
|
||||||
String branch = split[1];
|
String branch = split[1];
|
||||||
|
if (Integer.parseInt(level)<0){
|
||||||
|
return leftLine;
|
||||||
|
}
|
||||||
|
|
||||||
Map<String, List<CellObject>> numList = levelMap.get(level);
|
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);
|
List<CellObject> subList = numList.get(level + "." + branch);
|
||||||
if (subList == null || subList.isEmpty()){
|
if (subList == null || subList.isEmpty()){
|
||||||
subList = numList.get(level);
|
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);
|
leftLine = Math.min(leftLine,subLeftOffset);
|
||||||
|
|
||||||
//移动子级节点
|
//移动子级节点
|
||||||
double moveLeftLine = this.moveLeftNode(subList, nodeMap, offset, leftLine,true,true);
|
double moveLeftLine = this.moveLeftNode(subList, nodeMap, offset, leftLine,true,true);
|
||||||
|
|
||||||
leftLine = Math.min(leftLine,moveLeftLine);
|
leftLine = Math.min(leftLine,moveLeftLine);
|
||||||
|
|
||||||
return Math.min(leftLine,leftMinLine);
|
return Math.min(leftLine,leftMinLine);
|
||||||
@ -786,7 +806,7 @@ public class ImportShapeExcel1 {
|
|||||||
|
|
||||||
double rightLine = rightMaxLine;
|
double rightLine = rightMaxLine;
|
||||||
//递归处理父级所有图形+连线的x的偏移量
|
//递归处理父级所有图形+连线的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);
|
rightLine = Math.max(rightLine,upRightOffset);
|
||||||
|
|
||||||
@ -795,15 +815,14 @@ public class ImportShapeExcel1 {
|
|||||||
rightLine = Math.max(rightLine,moveRightOffset);
|
rightLine = Math.max(rightLine,moveRightOffset);
|
||||||
|
|
||||||
//递归处理子级所有图形+连线x的偏移量
|
//递归处理子级所有图形+连线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);
|
rightLine = Math.max(subRightOffset,rightLine);
|
||||||
|
|
||||||
return Math.max(rightLine,rightMaxLine);
|
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;
|
double rightLine = rightMaxLine;
|
||||||
String shapeNum = node.getShapeNum();
|
|
||||||
if (!shapeNum.contains(".")){
|
if (!shapeNum.contains(".")){
|
||||||
return rightLine;
|
return rightLine;
|
||||||
}
|
}
|
||||||
@ -812,14 +831,28 @@ public class ImportShapeExcel1 {
|
|||||||
String[] split = shapeNum.split("\\.");
|
String[] split = shapeNum.split("\\.");
|
||||||
String level = ""+ (Integer.parseInt(split[0])-1);
|
String level = ""+ (Integer.parseInt(split[0])-1);
|
||||||
String branch = split[1];
|
String branch = split[1];
|
||||||
Map<String, List<CellObject>> numList = levelMap.get(level);
|
if (Integer.parseInt(level)<0){
|
||||||
List<CellObject> upList = numList.get(level + "." + branch);
|
|
||||||
if (upList == null || upList.isEmpty()){
|
|
||||||
return rightLine;
|
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);
|
rightLine = Math.max(rightLine,upRightOffset);
|
||||||
|
|
||||||
//移动父节点x的偏移量
|
//移动父节点x的偏移量
|
||||||
@ -878,10 +911,8 @@ public class ImportShapeExcel1 {
|
|||||||
return rightLine;
|
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;
|
double rightLine = rightMaxLine;
|
||||||
String shapeNum = node.getShapeNum();
|
|
||||||
|
|
||||||
if (!shapeNum.contains(".")){
|
if (!shapeNum.contains(".")){
|
||||||
return rightLine;
|
return rightLine;
|
||||||
}
|
}
|
||||||
@ -890,10 +921,18 @@ public class ImportShapeExcel1 {
|
|||||||
String[] split = shapeNum.split("\\.");
|
String[] split = shapeNum.split("\\.");
|
||||||
String level = ""+ (Integer.parseInt(split[0])+1);
|
String level = ""+ (Integer.parseInt(split[0])+1);
|
||||||
String branch = split[1];
|
String branch = split[1];
|
||||||
|
if (Integer.parseInt(level)<0){
|
||||||
|
return rightLine;
|
||||||
|
}
|
||||||
|
|
||||||
Map<String, List<CellObject>> numList = levelMap.get(level);
|
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);
|
List<CellObject> subList = numList.get(level + "." + branch);
|
||||||
|
|
||||||
if (subList == null || subList.isEmpty()){
|
if (subList == null || subList.isEmpty()){
|
||||||
subList = numList.get(level);
|
subList = numList.get(level);
|
||||||
if (subList != null){
|
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);
|
rightLine = Math.max(rightLine,subRightOffset);
|
||||||
|
|
||||||
//移动子级节点
|
//移动子级节点
|
||||||
double moveRightOffset = this.moveRightNode(subList, nodeMap, offset, rightLine, true, true);
|
double moveRightOffset = this.moveRightNode(subList, nodeMap, offset, rightLine, true, true);
|
||||||
|
|
||||||
rightLine = Math.max(rightLine,moveRightOffset);
|
rightLine = Math.max(rightLine,moveRightOffset);
|
||||||
|
|
||||||
return Math.max(rightLine,rightMaxLine);
|
return Math.max(rightLine,rightMaxLine);
|
||||||
@ -1498,6 +1539,12 @@ public class ImportShapeExcel1 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Map<String, List<CellObject>> numList = levelMap.get(level);
|
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);
|
List<CellObject> cellObjects = numList.get(level + "." + branch);
|
||||||
if (cellObjects==null){
|
if (cellObjects==null){
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user