fix: 流程图生成图片 右侧出现大片空白问题

This commit is contained in:
qinoy 2024-11-08 14:41:39 +08:00
parent a70f725ee4
commit 2c86dd443e
2 changed files with 11 additions and 18 deletions

View File

@ -4332,9 +4332,8 @@ public class PALRepositoryQueryAPIManager {
//特殊处理shape外属性显示内容被切割问题 //特殊处理shape外属性显示内容被切割问题
boolean addEmptyFlag = false; boolean addEmptyFlag = false;
String str = ""; String str = "";
int maxX = 0; int rightBoundary = 0; // 记录图最右侧边界值
int maxY = 0; int bottomBoundary = 0; // 记录图最下侧边界值
int maxW = 0;
boolean isRight = false; boolean isRight = false;
JSONObject defineObj = JSON.parseObject(define); JSONObject defineObj = JSON.parseObject(define);
if (defineObj.containsKey("elements")) { if (defineObj.containsKey("elements")) {
@ -4372,18 +4371,12 @@ public class PALRepositoryQueryAPIManager {
if (null == props) { if (null == props) {
continue; continue;
} }
Integer x = props.getInteger("x"); int x = props.getIntValue("x");
if (null != x && x > maxX) { int y = props.getIntValue("y");
maxX = x; int w = props.getIntValue("w");
} int h = props.getIntValue("h");
Integer y = props.getInteger("y"); rightBoundary = Math.max(x + w, rightBoundary);
if (null != y && y > maxY) { bottomBoundary = Math.max(y + h, bottomBoundary);
maxY = y;
}
Integer w = props.getInteger("w");
if (null != w && w > maxW){
maxW = w;
}
} }
} }
@ -4394,12 +4387,12 @@ public class PALRepositoryQueryAPIManager {
if (textShape != null && textShape.containsKey("props")) { if (textShape != null && textShape.containsKey("props")) {
JSONObject props = textShape.getJSONObject("props"); JSONObject props = textShape.getJSONObject("props");
props.put("w", 100); props.put("w", 100);
props.put("y", maxY); props.put("y", bottomBoundary);
props.put("h", 50); props.put("h", 50);
if (isRight) { if (isRight) {
props.put("x", maxX + maxW + (str.length() * 2)); props.put("x", rightBoundary + (str.length() * 2));
} else { } else {
props.put("x", maxX - (str.length() * 2)); props.put("x", rightBoundary - (str.length() * 2));
} }
elements.put(textShape.getString("id"), textShape); elements.put(textShape.getString("id"), textShape);