pal 流程手册流程图文字被裁剪问题特殊处理

This commit is contained in:
anhc 2022-07-21 17:21:14 +08:00
parent ac36722437
commit 8482a4f8e8
2 changed files with 72 additions and 1 deletions

View File

@ -2742,7 +2742,78 @@ public class PALRepositoryQueryAPIManager {
if (model != null) {
// 形状锚点更新
String define = CoeDesignerShapeAPIManager.getInstance().updateShapeConfig(uuid, model.getDefinition());
model.setDefinition(define);
//特殊处理shape外属性显示内容被切割问题
boolean addEmptyFlag = false;
String str = "";
int maxX = 0;
int maxY = 0;
int maxW = 0;
boolean isRight = false;
JSONObject defineObj = JSON.parseObject(define);
if (defineObj.containsKey("elements")){
JSONObject elements = defineObj.getJSONObject("elements");
for (String key : elements.keySet()) {
JSONObject shapeObj = elements.getJSONObject(key);
if (null !=shapeObj && shapeObj.containsKey("dataAttributes")){
JSONArray dataAttributes = shapeObj.getJSONArray("dataAttributes");
for (int i = 0; i < dataAttributes.size(); i++) {
JSONObject dataAttribute = dataAttributes.getJSONObject(i);
if (null != dataAttribute && null != dataAttribute.getJSONObject("dataShowConfig")
&& null != dataAttribute.getJSONObject("dataShowConfig").getJSONArray("value")
&& dataAttribute.getJSONObject("dataShowConfig").getJSONArray("value").size()>0){
addEmptyFlag = true;
JSONArray configs = dataAttribute.getJSONObject("dataShowConfig").getJSONArray("value");
for (int i1 = 0; i1 < configs.size(); i1++) {
JSONObject config = configs.getJSONObject(i1);
if (null == config ){
continue;
}
String value = config.getString("value");
if (value.length()>str.length()){
str = value;
String horizontal = config.getString("horizontal");
isRight = horizontal.contains("right");
}
}
}
}
}
if (null != shapeObj && shapeObj.containsKey("props")){
JSONObject props = shapeObj.getJSONObject("props");
if ( null == props ){
continue;
}
Integer x = props.getInteger("x");
if(null != x && x > maxX){
maxX = x;
maxW = props.getInteger("w");
maxY = props.getInteger("y");
}
}
}
if (addEmptyFlag){
JSONObject textShape = JSON.parseObject("{\"parent\":\"\",\"textBlockFinal\":{\"w\":91,\"x\":0,\"h\":50,\"y\":0},\"link\":\"\",\"shapeStyle\":{\"alpha\":1},\"anchors\":[],\"textBlock\":{\"w\":\"w\",\"x\":0,\"h\":\"h\",\"y\":0},\"title\":\"\",\"fontStyle\":{\"orientation\":\"vertical\",\"fontFamily\":\"Arial\",\"size\":14,\"color\":\"50,50,50\",\"underline\":false,\"textAlign\":\"center\",\"bold\":false,\"italic\":false,\"vAlign\":\"middle\"},\"dataAttributes\":[{\"relevanceShapes\":[],\"attributesContent\":\"\",\"type\":\"string\",\"attributesJsonArray\":[],\"linksArray\":[],\"shapeDesc\":\"\",\"privateAttributeContent\":[],\"name\":\"AWSProperties\",\"privateShapesName\":[],\"id\":\"obj_c9e885014030000150f7ed506b48d010\",\"category\":\"default\",\"value\":\"\",\"upFilesArray\":[],\"privateAttribute\":[],\"isCopy\":\"\",\"shapeGroupId\":\"\"}],\"props\":{\"zindex\":51,\"w\":91,\"x\":629,\"h\":50,\"y\":250,\"angle\":0},\"path\":[{\"lineStyle\":{\"lineWidth\":0},\"fillStyle\":{\"type\":\"none\"},\"actions\":[{\"x\":\"0\",\"action\":\"move\",\"y\":\"0\"},{\"x\":\"w\",\"action\":\"line\",\"y\":\"0\"},{\"x\":\"w\",\"action\":\"line\",\"y\":\"h\"},{\"x\":\"0\",\"action\":\"line\",\"y\":\"h\"},{\"action\":\"close\"}]}],\"lineStyle\":{\"lineStyle\":\"solid\",\"lineColor\":\"50,50,50\",\"lineWidth\":1},\"children\":[],\"resizeDir\":[\"tl\",\"tr\",\"br\",\"bl\"],\"name\":\"standardText\",\"orderIndex\":0,\"fillStyle\":{\"color\":\"255,255,255\",\"type\":\"solid\"},\"id\":\"obj_c9e885014020000183f8bc75be204580\",\"text\":\"\",\"attribute\":{\"container\":false,\"rotatable\":false,\"visible\":true,\"editable\":true,\"linkable\":false,\"markerOffset\":5},\"resizeable\":\"1\",\"locked\":false,\"category\":\"standard\",\"group\":\"\"}");
if (textShape != null && textShape.containsKey("props")){
JSONObject props = textShape.getJSONObject("props");
props.put("w",100);
props.put("y",maxY);
props.put("h",50);
if (isRight){
props.put("x",maxX + maxW + (str.length()* 2));
}else {
props.put("x",maxX - (str.length()* 2));
}
elements.put(textShape.getString("id"),textShape);
}
}
}
model.setDefinition(defineObj.toString());
// 生成图片
CoeDesignerImage.saveImage(model, bigImage, smallImage);
}