伊利项目 模型转换功能 图形间距问题以及连线锚点问题解决
This commit is contained in:
parent
29b29ea7f9
commit
901f047405
Binary file not shown.
@ -6,4 +6,10 @@ public class ShapeConstant {
|
||||
public static final double DECISION_NODE_WIDTH = 90;
|
||||
// 判定图形的初始高
|
||||
public static final double DECISION_NODE_HEIGHT = 46;
|
||||
|
||||
// epc转bpmn的图形间隔
|
||||
public static final int EPC_TO_BPMN_SHAPE_SPACE = 180;
|
||||
|
||||
public static final String LINKER_FROM_DIRECTION_KEY = "fromDirection";
|
||||
public static final String LINKER_TO_DIRECTION_KEY = "toDirection";
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -3,6 +3,7 @@ package com.actionsoft.apps.coe.pal.modelconvert.util;
|
||||
import com.actionsoft.apps.coe.pal.modelconvert.cache.ConvertShapeIdMapping;
|
||||
import com.actionsoft.apps.coe.pal.modelconvert.constant.ConvertType;
|
||||
import com.actionsoft.apps.coe.pal.modelconvert.constant.LinkerDefConstant;
|
||||
import com.actionsoft.apps.coe.pal.modelconvert.constant.ShapeConstant;
|
||||
import com.actionsoft.apps.coe.pal.modelconvert.model.Position;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
@ -213,7 +214,7 @@ public class ConvertUtil {
|
||||
* @param beforeConvertLinker
|
||||
* @return
|
||||
*/
|
||||
public static Map<String,Position> getConvertAnchorPoi(JSONObject beforeConvertElement,JSONObject afterConvertElement,JSONObject beforeConvertLinker){
|
||||
public static Map<String,Position> getConvertAnchorPoi(JSONObject beforeConvertElement,JSONObject afterConvertElement,JSONObject beforeConvertLinker,Map<String,String> convertLinkerTypeMap){
|
||||
|
||||
Map<String,Position> resultMap = new HashMap<>(2);
|
||||
|
||||
@ -236,15 +237,42 @@ public class ConvertUtil {
|
||||
if (beforeConvertFromAnchorPoi.equals(leftFromPoi)){ // 转换前从左侧出 转换后从下侧出
|
||||
Position afterBottomFromPoi = new Position(afterFromShapeProps.getDoubleValue("x") + (afterFromShapeProps.getDoubleValue("w") / 2),afterFromShapeProps.getDoubleValue("y") + afterFromShapeProps.getDoubleValue("h"));
|
||||
resultMap.put("from",afterBottomFromPoi);
|
||||
convertLinkerTypeMap.put(ShapeConstant.LINKER_FROM_DIRECTION_KEY,"bottom");
|
||||
}else if (beforeConvertFromAnchorPoi.equals(topFromPoi)){ // 转换前从上侧出 转换后从左侧出
|
||||
Position afterLeftFromPoi = new Position(afterFromShapeProps.getDoubleValue("x"),afterFromShapeProps.getDoubleValue("y") + (afterFromShapeProps.getDoubleValue("h") / 2));
|
||||
resultMap.put("from",afterLeftFromPoi);
|
||||
convertLinkerTypeMap.put(ShapeConstant.LINKER_FROM_DIRECTION_KEY,"left");
|
||||
}else if (beforeConvertFromAnchorPoi.equals(rightFromPoi)){ // 转换前从右侧出 转换后从上侧出
|
||||
Position afterTopFromPoi = new Position(afterFromShapeProps.getDoubleValue("x") + (afterFromShapeProps.getDoubleValue("w") / 2),afterFromShapeProps.getDoubleValue("y"));
|
||||
resultMap.put("from",afterTopFromPoi);
|
||||
convertLinkerTypeMap.put(ShapeConstant.LINKER_FROM_DIRECTION_KEY,"top");
|
||||
}else if (beforeConvertFromAnchorPoi.equals(bottomFromPoi)){ // 转换前从下侧出 转换后从右侧出
|
||||
Position afterRightFromPoi = new Position(afterFromShapeProps.getDoubleValue("x") + afterFromShapeProps.getDoubleValue("w"),afterFromShapeProps.getDoubleValue("y") + (afterFromShapeProps.getDoubleValue("h") / 2));
|
||||
resultMap.put("from",afterRightFromPoi);
|
||||
convertLinkerTypeMap.put(ShapeConstant.LINKER_FROM_DIRECTION_KEY,"right");
|
||||
}else{
|
||||
// 有坑 正常来讲不会进入这里
|
||||
if (beforeConvertFromAnchorPoi.getX() >= rightFromPoi.getX() && beforeConvertFromAnchorPoi.getY() > topFromPoi.getY() && beforeConvertFromAnchorPoi.getY() < bottomFromPoi.getY()){
|
||||
// 转换前从右侧出 转换后从上侧出
|
||||
Position afterTopFromPoi = new Position(afterFromShapeProps.getDoubleValue("x") + (afterFromShapeProps.getDoubleValue("w") / 2),afterFromShapeProps.getDoubleValue("y"));
|
||||
resultMap.put("from",afterTopFromPoi);
|
||||
convertLinkerTypeMap.put(ShapeConstant.LINKER_FROM_DIRECTION_KEY,"top");
|
||||
}else if (beforeConvertFromAnchorPoi.getX() <= leftFromPoi.getX() && beforeConvertFromAnchorPoi.getY() > topFromPoi.getY() && beforeConvertFromAnchorPoi.getY() < bottomFromPoi.getY()){
|
||||
// 转换前从左侧出 转换后从下侧出
|
||||
Position afterBottomFromPoi = new Position(afterFromShapeProps.getDoubleValue("x") + (afterFromShapeProps.getDoubleValue("w") / 2),afterFromShapeProps.getDoubleValue("y") + afterFromShapeProps.getDoubleValue("h"));
|
||||
resultMap.put("from",afterBottomFromPoi);
|
||||
convertLinkerTypeMap.put(ShapeConstant.LINKER_FROM_DIRECTION_KEY,"bottom");
|
||||
}else if (beforeConvertFromAnchorPoi.getX() > leftFromPoi.getX() && beforeConvertFromAnchorPoi.getX() < rightFromPoi.getX() && beforeConvertFromAnchorPoi.getY() <= topFromPoi.getY()){
|
||||
// 转换前从上侧出 转换后从左侧出
|
||||
Position afterLeftFromPoi = new Position(afterFromShapeProps.getDoubleValue("x"),afterFromShapeProps.getDoubleValue("y") + (afterFromShapeProps.getDoubleValue("h") / 2));
|
||||
resultMap.put("from",afterLeftFromPoi);
|
||||
convertLinkerTypeMap.put(ShapeConstant.LINKER_FROM_DIRECTION_KEY,"left");
|
||||
}else if (beforeConvertFromAnchorPoi.getX() > leftFromPoi.getX() && beforeConvertFromAnchorPoi.getX() < rightFromPoi.getX() && beforeConvertFromAnchorPoi.getY() >= bottomFromPoi.getY()){
|
||||
// 转换前从下侧出 转换后从右侧出
|
||||
Position afterRightFromPoi = new Position(afterFromShapeProps.getDoubleValue("x") + afterFromShapeProps.getDoubleValue("w"),afterFromShapeProps.getDoubleValue("y") + (afterFromShapeProps.getDoubleValue("h") / 2));
|
||||
resultMap.put("from",afterRightFromPoi);
|
||||
convertLinkerTypeMap.put(ShapeConstant.LINKER_FROM_DIRECTION_KEY,"right");
|
||||
}
|
||||
}
|
||||
}else {
|
||||
Position noneShape = new Position(linkerFromObj.getDoubleValue("y"),beforeConvertElement.getJSONObject("page").getDoubleValue("width") - linkerFromObj.getDoubleValue("x"));
|
||||
@ -267,17 +295,44 @@ public class ConvertUtil {
|
||||
if (beforeConvertToAnchorPoi.equals(leftToPoi)){ // 转换前从左侧进入 转换后从下侧进入
|
||||
Position afterBottomToPoi = new Position(afterToShapeProps.getDoubleValue("x") + (afterToShapeProps.getDoubleValue("w") / 2),afterToShapeProps.getDoubleValue("y") + afterToShapeProps.getDoubleValue("h"));
|
||||
resultMap.put("to",afterBottomToPoi);
|
||||
convertLinkerTypeMap.put(ShapeConstant.LINKER_TO_DIRECTION_KEY,"bottom");
|
||||
}else if (beforeConvertToAnchorPoi.equals(topToPoi)){ // 转换前从上侧进入 转换后从左侧进入
|
||||
Position afterLeftToPoi = new Position(afterToShapeProps.getDoubleValue("x"),afterToShapeProps.getDoubleValue("y") + (afterToShapeProps.getDoubleValue("h") / 2));
|
||||
resultMap.put("to",afterLeftToPoi);
|
||||
convertLinkerTypeMap.put(ShapeConstant.LINKER_TO_DIRECTION_KEY,"left");
|
||||
}else if (beforeConvertToAnchorPoi.equals(rightToPoi)){ // 转换前从右侧进入 转换后从上侧进入
|
||||
Position afterTopToPoi = new Position(afterToShapeProps.getDoubleValue("x") + (afterToShapeProps.getDoubleValue("w") / 2),afterToShapeProps.getDoubleValue("y"));
|
||||
resultMap.put("to",afterTopToPoi);
|
||||
convertLinkerTypeMap.put(ShapeConstant.LINKER_TO_DIRECTION_KEY,"top");
|
||||
}else if (beforeConvertToAnchorPoi.equals(bottomToPoi)){ // 转换前从下侧进入 转换后从右侧进入
|
||||
Position afterRightToPoi = new Position(afterToShapeProps.getDoubleValue("x") + afterToShapeProps.getDoubleValue("w"),afterToShapeProps.getDoubleValue("y") + (afterToShapeProps.getDoubleValue("h") / 2));
|
||||
resultMap.put("to",afterRightToPoi);
|
||||
convertLinkerTypeMap.put(ShapeConstant.LINKER_TO_DIRECTION_KEY,"right");
|
||||
}else {
|
||||
// 有坑 正常来讲不会进入这里
|
||||
if (beforeConvertToAnchorPoi.getX() >= rightToPoi.getX() && beforeConvertToAnchorPoi.getY() > topToPoi.getY() && beforeConvertToAnchorPoi.getY() < bottomToPoi.getY()){
|
||||
// 转换前从右侧进入 转换后 从上侧进入
|
||||
Position afterTopToPoi = new Position(afterToShapeProps.getDoubleValue("x") + (afterToShapeProps.getDoubleValue("w") / 2),afterToShapeProps.getDoubleValue("y"));
|
||||
resultMap.put("to",afterTopToPoi);
|
||||
convertLinkerTypeMap.put(ShapeConstant.LINKER_TO_DIRECTION_KEY,"top");
|
||||
}else if (beforeConvertToAnchorPoi.getX() <= leftToPoi.getX() && beforeConvertToAnchorPoi.getY() > topToPoi.getY() && beforeConvertToAnchorPoi.getY() < bottomToPoi.getY()){
|
||||
// 转换前从左侧进入 转换后 从下侧进入
|
||||
Position afterBottomToPoi = new Position(afterToShapeProps.getDoubleValue("x") + (afterToShapeProps.getDoubleValue("w") / 2),afterToShapeProps.getDoubleValue("y") + afterToShapeProps.getDoubleValue("h"));
|
||||
resultMap.put("to",afterBottomToPoi);
|
||||
convertLinkerTypeMap.put(ShapeConstant.LINKER_TO_DIRECTION_KEY,"bottom");
|
||||
}else if (beforeConvertToAnchorPoi.getX() > leftToPoi.getX() && beforeConvertToAnchorPoi.getX() < rightToPoi.getX() && beforeConvertToAnchorPoi.getY() <= topToPoi.getY()){
|
||||
// 转换前从上侧进入 转换后 从左侧进入
|
||||
Position afterLeftToPoi = new Position(afterToShapeProps.getDoubleValue("x"),afterToShapeProps.getDoubleValue("y") + (afterToShapeProps.getDoubleValue("h") / 2));
|
||||
resultMap.put("to",afterLeftToPoi);
|
||||
convertLinkerTypeMap.put(ShapeConstant.LINKER_TO_DIRECTION_KEY,"left");
|
||||
}else if (beforeConvertToAnchorPoi.getX() > leftToPoi.getX() && beforeConvertToAnchorPoi.getX() < rightToPoi.getX() && beforeConvertToAnchorPoi.getY() >= bottomToPoi.getY()){
|
||||
// 转换前从下侧进入 转换后 从右侧进入
|
||||
Position afterRightToPoi = new Position(afterToShapeProps.getDoubleValue("x") + afterToShapeProps.getDoubleValue("w"),afterToShapeProps.getDoubleValue("y") + (afterToShapeProps.getDoubleValue("h") / 2));
|
||||
resultMap.put("to",afterRightToPoi);
|
||||
convertLinkerTypeMap.put(ShapeConstant.LINKER_TO_DIRECTION_KEY,"right");
|
||||
}
|
||||
}
|
||||
}else {
|
||||
}else {
|
||||
Position noneShape = new Position(linkerToObj.getDoubleValue("y"),beforeConvertElement.getJSONObject("page").getDoubleValue("width") - linkerToObj.getDoubleValue("x"));
|
||||
resultMap.put("to",noneShape);
|
||||
}
|
||||
@ -285,4 +340,85 @@ public class ConvertUtil {
|
||||
return resultMap;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取图形转换后的连线折点【基于垂直向下方向 转向 水平向右方向的转换】
|
||||
* 【大概思路】连线折点大概有三种
|
||||
* 水平线折点为连线中点
|
||||
* 含有一个明显折点的连线
|
||||
* 含有两个明显折点的连线
|
||||
* @return
|
||||
*/
|
||||
public static JSONArray getLinkerPoints(Map<String,String> convertLinkerTypeMap,Map<String, Position> anchorPoiMap,int pageHeight){
|
||||
|
||||
if (convertLinkerTypeMap.containsKey(ShapeConstant.LINKER_FROM_DIRECTION_KEY) && convertLinkerTypeMap.containsKey(ShapeConstant.LINKER_TO_DIRECTION_KEY)){
|
||||
JSONArray points = new JSONArray();
|
||||
Position fromPoi = anchorPoiMap.get("from");
|
||||
Position toPoi = anchorPoiMap.get("to");
|
||||
String fromDirection = convertLinkerTypeMap.get(ShapeConstant.LINKER_FROM_DIRECTION_KEY);
|
||||
String toDirection = convertLinkerTypeMap.get(ShapeConstant.LINKER_TO_DIRECTION_KEY);
|
||||
if ("right".equals(fromDirection) && "left".equals(toDirection)){ // 水平连线
|
||||
double x = (toPoi.getX() - fromPoi.getX()) / 2;
|
||||
JSONObject p1 = new JSONObject();
|
||||
p1.put("x",fromPoi.getX() + x);
|
||||
p1.put("y",fromPoi.getY());
|
||||
JSONObject p2 = new JSONObject();
|
||||
p2.put("x",fromPoi.getX() + x);
|
||||
p2.put("y",fromPoi.getY());
|
||||
points.add(p1);
|
||||
points.add(p2);
|
||||
}else if ("left".equals(fromDirection) && "right".equals(toDirection)){
|
||||
double x = (fromPoi.getX() - toPoi.getX()) / 2;
|
||||
JSONObject p1 = new JSONObject();
|
||||
p1.put("x",toPoi.getX() + x);
|
||||
p1.put("y",toPoi.getY());
|
||||
JSONObject p2 = new JSONObject();
|
||||
p2.put("x",toPoi.getX() + x);
|
||||
p2.put("y",toPoi.getY());
|
||||
points.add(p1);
|
||||
points.add(p2);
|
||||
}else if ("top".equals(fromDirection) && ("left".equals(toDirection) || "right".equals(toDirection))){
|
||||
JSONObject p = new JSONObject();
|
||||
p.put("x",fromPoi.getX());
|
||||
p.put("y",toPoi.getY());
|
||||
points.add(p);
|
||||
}else if ("top".equals(toDirection) && ("left".equals(fromDirection) || "right".equals(fromDirection))){
|
||||
JSONObject p = new JSONObject();
|
||||
p.put("x",toPoi.getX());
|
||||
p.put("y",fromPoi.getY());
|
||||
points.add(p);
|
||||
}else if ("bottom".equals(fromDirection) && ("left".equals(toDirection) || "right".equals(toDirection))){
|
||||
JSONObject p = new JSONObject();
|
||||
p.put("x",fromPoi.getX());
|
||||
p.put("y",toPoi.getY());
|
||||
points.add(p);
|
||||
}else if ("bottom".equals(toDirection) && ("left".equals(fromDirection) || "right".equals(fromDirection))){
|
||||
JSONObject p = new JSONObject();
|
||||
p.put("x",toPoi.getX());
|
||||
p.put("y",fromPoi.getY());
|
||||
points.add(p);
|
||||
}else if ("top".equals(fromDirection) && "top".equals(toDirection)){
|
||||
JSONObject p1 = new JSONObject();
|
||||
JSONObject p2 = new JSONObject();
|
||||
p1.put("x",fromPoi.getX());
|
||||
p1.put("y",100);
|
||||
p2.put("x",toPoi.getX());
|
||||
p2.put("y",100);
|
||||
points.add(p1);
|
||||
points.add(p2);
|
||||
}else if ("bottom".equals(fromDirection) && "bottom".equals(toDirection)){
|
||||
JSONObject p1 = new JSONObject();
|
||||
JSONObject p2 = new JSONObject();
|
||||
p1.put("x",fromPoi.getX());
|
||||
p1.put("y",pageHeight - 50);
|
||||
p2.put("x",toPoi.getX());
|
||||
p2.put("y",pageHeight - 50);
|
||||
points.add(p1);
|
||||
points.add(p2);
|
||||
}
|
||||
return points;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user