From f1c5cdc17f6c8f77f4acf2fdda3a5947d4d84e4e Mon Sep 17 00:00:00 2001 From: Tijs Rademakers Date: Wed, 20 Dec 2017 17:02:08 +0100 Subject: [PATCH] Revert "#701 Remove JavaGeom dependency (#707)" This reverts commit ca54e73443f34aacb3b1a1f00a8d4788f3020d61. --- distro/src/notice.txt | 7 +- modules/flowable-cmmn-json-converter/pom.xml | 6 +- .../json/converter/CmmnJsonConverter.java | 127 ++++++----------- modules/flowable-json-converter/pom.xml | 12 +- .../json/converter/BpmnJsonConverter.java | 128 ++++++------------ .../language/CollapsebleSubprocessTest.java | 27 ++-- .../EventSubprocessSequenceFlowTest.java | 15 +- .../json/converter/BpmnJsonConverterTest.java | 70 ---------- pom.xml | 5 + 9 files changed, 122 insertions(+), 275 deletions(-) delete mode 100644 modules/flowable-json-converter/src/test/java/org/flowable/editor/language/json/converter/BpmnJsonConverterTest.java diff --git a/distro/src/notice.txt b/distro/src/notice.txt index 4757b8a1a5..dff521c50a 100644 --- a/distro/src/notice.txt +++ b/distro/src/notice.txt @@ -72,15 +72,15 @@ flowable-ui-modeler-rest<.jar | -source.jar | -javadoc.jar> flowable-ui-task-conf<.jar | -source.jar | -javadoc.jar> flowable-ui-task-logic<.jar | -source.jar | -javadoc.jar> flowable-ui-task-rest<.jar | -source.jar | -javadoc.jar> - - + + You may not use these files except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0. Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an AS IS BASIS, WITHOUT WARRANTIES OR CONDITIONS OR ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. This software package also includes third party components as listed below. This software package includes changed source code of the following libraries: - + Quartz * Location: http://www.quartz-scheduler.org/ * CronExpression is included in flowable-engine-.jar in package org.flowable.engine.impl.calendar @@ -150,6 +150,7 @@ javax.activation activation 1.1.1 COMM javax.annotation jsr250-api 1.0 COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0 joda-time joda-time 2.9.9 Apache 2 log4j log4j 1.2.17 The Apache Software License, Version 2.0 +math.geom2d javaGeom 0.11.1 Lesser General Public License version 2.0 (LGPLv2) org.apache.commons commons-email 1.5 Apache License, Version 2.0 org.apache.commons commons-lang3 3.7 The Apache Software License, Version 2.0 org.apache.httpcomponents httpclient 4.5.3 Apache License, Version 2.0 diff --git a/modules/flowable-cmmn-json-converter/pom.xml b/modules/flowable-cmmn-json-converter/pom.xml index 4ab2ed86d3..ce8ebeacb2 100644 --- a/modules/flowable-cmmn-json-converter/pom.xml +++ b/modules/flowable-cmmn-json-converter/pom.xml @@ -55,7 +55,7 @@ - org.eclipse.m2e @@ -116,6 +116,10 @@ joda-time joda-time + + math.geom2d + javaGeom + junit junit diff --git a/modules/flowable-cmmn-json-converter/src/main/java/org/flowable/cmmn/editor/json/converter/CmmnJsonConverter.java b/modules/flowable-cmmn-json-converter/src/main/java/org/flowable/cmmn/editor/json/converter/CmmnJsonConverter.java index b0d298f903..cd50454fb9 100644 --- a/modules/flowable-cmmn-json-converter/src/main/java/org/flowable/cmmn/editor/json/converter/CmmnJsonConverter.java +++ b/modules/flowable-cmmn-json-converter/src/main/java/org/flowable/cmmn/editor/json/converter/CmmnJsonConverter.java @@ -12,10 +12,14 @@ */ package org.flowable.cmmn.editor.json.converter; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.node.ArrayNode; -import com.fasterxml.jackson.databind.node.ObjectNode; +import java.text.DateFormat; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + import org.apache.commons.lang3.StringUtils; import org.flowable.cmmn.editor.constants.CmmnStencilConstants; import org.flowable.cmmn.editor.constants.EditorJsonConstants; @@ -37,22 +41,16 @@ import org.flowable.cmmn.model.TimerEventListener; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.awt.*; -import java.awt.geom.Area; -import java.awt.geom.Ellipse2D; -import java.awt.geom.Line2D; -import java.awt.geom.Path2D; -import java.awt.geom.Point2D; -import java.awt.geom.Rectangle2D; -import java.text.DateFormat; -import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.node.ArrayNode; +import com.fasterxml.jackson.databind.node.ObjectNode; + +import math.geom2d.Point2D; +import math.geom2d.conic.Circle2D; +import math.geom2d.curve.AbstractContinuousCurve2D; +import math.geom2d.line.Line2D; +import math.geom2d.polygon.Polyline2D; /** * @author Tijs Rademakers @@ -101,7 +99,7 @@ public class CmmnJsonConverter implements EditorJsonConstants, CmmnStencilConsta static { DI_CIRCLES.add(STENCIL_TIMER_EVENT_LISTENER); - + DI_RECTANGLES.add(STENCIL_TASK); DI_RECTANGLES.add(STENCIL_TASK_HUMAN); DI_RECTANGLES.add(STENCIL_TASK_SERVICE); @@ -115,8 +113,6 @@ public class CmmnJsonConverter implements EditorJsonConstants, CmmnStencilConsta DI_SENTRY.add(STENCIL_EXIT_CRITERION); } - protected double lineWidth = 0.000001d; - public ObjectNode convertToJson(CmmnModel model) { return convertToJson(model, null, null); } @@ -675,18 +671,17 @@ public class CmmnJsonConverter implements EditorJsonConstants, CmmnStencilConsta nextPointInLineY += targetInfo.getY(); } - Line2D firstLine = new Line2D.Double(sourceRefLineX, sourceRefLineY, - nextPointInLineX, nextPointInLineY); + Line2D firstLine = new Line2D(sourceRefLineX, sourceRefLineY, nextPointInLineX, nextPointInLineY); String sourceRefStencilId = CmmnJsonConverterUtil.getStencilId(sourceRefNode); String targetRefStencilId = CmmnJsonConverterUtil.getStencilId(targetRefNode); List graphicInfoList = new ArrayList<>(); - Shape source2D = null; + AbstractContinuousCurve2D source2D = null; if (DI_CIRCLES.contains(sourceRefStencilId)) { - source2D = createEllipse(sourceInfo, sourceDockersX, sourceDockersY); - + source2D = new Circle2D(sourceInfo.getX() + sourceDockersX, sourceInfo.getY() + sourceDockersY, sourceDockersX); + } else if (DI_RECTANGLES.contains(sourceRefStencilId)) { source2D = createRectangle(sourceInfo); @@ -695,10 +690,10 @@ public class CmmnJsonConverter implements EditorJsonConstants, CmmnStencilConsta } if (source2D != null) { - Collection intersections = getIntersections(firstLine, source2D); + Collection intersections = source2D.intersections(firstLine); if (intersections != null && intersections.size() > 0) { Point2D intersection = intersections.iterator().next(); - graphicInfoList.add(createGraphicInfo(intersection.getX(), intersection.getY())); + graphicInfoList.add(createGraphicInfo(intersection.x(), intersection.y())); } else { graphicInfoList.add(createGraphicInfo(sourceRefLineX, sourceRefLineY)); } @@ -722,19 +717,19 @@ public class CmmnJsonConverter implements EditorJsonConstants, CmmnStencilConsta endLastLineX += targetInfo.getX(); endLastLineY += targetInfo.getY(); - lastLine = new Line2D.Double(startLastLineX, startLastLineY, endLastLineX, endLastLineY); + lastLine = new Line2D(startLastLineX, startLastLineY, endLastLineX, endLastLineY); } else { lastLine = firstLine; } - Shape target2D = null; + AbstractContinuousCurve2D target2D = null; if (DI_CIRCLES.contains(targetRefStencilId)) { double targetDockersX = dockersNode.get(dockersNode.size() - 1).get(EDITOR_BOUNDS_X).asDouble(); double targetDockersY = dockersNode.get(dockersNode.size() - 1).get(EDITOR_BOUNDS_Y).asDouble(); - target2D = createEllipse(targetInfo, targetDockersX, targetDockersY); - + target2D = new Circle2D(targetInfo.getX() + targetDockersX, targetInfo.getY() + targetDockersY, targetDockersX); + } if (DI_RECTANGLES.contains(targetRefStencilId)) { target2D = createRectangle(targetInfo); @@ -743,12 +738,12 @@ public class CmmnJsonConverter implements EditorJsonConstants, CmmnStencilConsta } if (target2D != null) { - Collection intersections = getIntersections(lastLine, target2D); + Collection intersections = target2D.intersections(lastLine); if (intersections != null && intersections.size() > 0) { Point2D intersection = intersections.iterator().next(); - graphicInfoList.add(createGraphicInfo(intersection.getX(), intersection.getY())); + graphicInfoList.add(createGraphicInfo(intersection.x(), intersection.y())); } else { - graphicInfoList.add(createGraphicInfo(lastLine.getX2(), lastLine.getY2())); + graphicInfoList.add(createGraphicInfo(lastLine.getPoint2().x(), lastLine.getPoint2().y())); } } @@ -756,63 +751,19 @@ public class CmmnJsonConverter implements EditorJsonConstants, CmmnStencilConsta } } - - protected Shape createEllipse(GraphicInfo sourceInfo, double halfWidth, double halfHeight) { - return new Ellipse2D.Double( - sourceInfo.getX(), sourceInfo.getY(), 2 * halfWidth, 2 * halfHeight - ); - } - - protected Collection getIntersections(java.awt.geom.Line2D line, Shape shape) { - Area intersectionArea = new Area(getLineShape(line)); - Area shapeArea = new Area(shape); - intersectionArea.intersect(shapeArea); - if (!intersectionArea.isEmpty()) { - Rectangle2D bounds2D = intersectionArea.getBounds2D(); - HashSet intersections = new HashSet<>(2); - - if (!shapeArea.contains(line.getX1(), line.getY1())) { - intersections.add(new java.awt.geom.Point2D.Double(bounds2D.getX(), bounds2D.getY())); - } - if (!shapeArea.contains(line.getX2(), line.getY2())) { - intersections.add(new java.awt.geom.Point2D.Double( - bounds2D.getX() + bounds2D.getWidth(), bounds2D.getY() + bounds2D.getHeight())); - } - - return intersections; - } - return Collections.EMPTY_SET; - } - - protected Shape getLineShape(java.awt.geom.Line2D line2D) { - Path2D line = new Path2D.Double(Path2D.WIND_NON_ZERO, 4); - line.moveTo(line2D.getX1(), line2D.getY1()); - line.lineTo(line2D.getX2(), line2D.getY2()); - line.lineTo(line2D.getX2() + lineWidth, line2D.getY2() + lineWidth); - line.closePath(); - return line; + protected Polyline2D createRectangle(GraphicInfo graphicInfo) { + return new Polyline2D(new Point2D(graphicInfo.getX(), graphicInfo.getY()), new Point2D(graphicInfo.getX() + graphicInfo.getWidth(), graphicInfo.getY()), + new Point2D(graphicInfo.getX() + graphicInfo.getWidth(), graphicInfo.getY() + graphicInfo.getHeight()), new Point2D(graphicInfo.getX(), graphicInfo.getY() + graphicInfo.getHeight()), + new Point2D(graphicInfo.getX(), graphicInfo.getY())); } - protected Shape createRectangle(GraphicInfo graphicInfo) { - return new Rectangle2D.Double( - graphicInfo.getX(), graphicInfo.getY(), - graphicInfo.getWidth(), graphicInfo.getHeight() - ); - } - - protected Shape createGateway(GraphicInfo graphicInfo) { + protected Polyline2D createGateway(GraphicInfo graphicInfo) { double middleX = graphicInfo.getX() + (graphicInfo.getWidth() / 2); double middleY = graphicInfo.getY() + (graphicInfo.getHeight() / 2); - Path2D.Double gatewayShape = new Path2D.Double(Path2D.WIND_NON_ZERO, 4); - gatewayShape.moveTo(graphicInfo.getX(), middleY); - gatewayShape.lineTo(middleX, graphicInfo.getY()); - gatewayShape.lineTo(graphicInfo.getX() + graphicInfo.getWidth(), middleY); - gatewayShape.lineTo(middleX, graphicInfo.getY() + graphicInfo.getHeight()); - gatewayShape.closePath(); - - return gatewayShape; + return new Polyline2D(new Point2D(graphicInfo.getX(), middleY), new Point2D(middleX, graphicInfo.getY()), new Point2D(graphicInfo.getX() + graphicInfo.getWidth(), middleY), + new Point2D(middleX, graphicInfo.getY() + graphicInfo.getHeight()), new Point2D(graphicInfo.getX(), middleY)); } protected GraphicInfo createGraphicInfo(double x, double y) { diff --git a/modules/flowable-json-converter/pom.xml b/modules/flowable-json-converter/pom.xml index 24ace482b9..19e4bacb6f 100644 --- a/modules/flowable-json-converter/pom.xml +++ b/modules/flowable-json-converter/pom.xml @@ -12,7 +12,7 @@ ../.. 6.3.0-SNAPSHOT - + UTF-8 @@ -115,15 +115,19 @@ joda-time joda-time + + math.geom2d + javaGeom + junit junit provided - + org.slf4j slf4j-api - + org.slf4j jcl-over-slf4j @@ -134,7 +138,7 @@ test - + distro diff --git a/modules/flowable-json-converter/src/main/java/org/flowable/editor/language/json/converter/BpmnJsonConverter.java b/modules/flowable-json-converter/src/main/java/org/flowable/editor/language/json/converter/BpmnJsonConverter.java index 3fe306aa28..8da759e856 100644 --- a/modules/flowable-json-converter/src/main/java/org/flowable/editor/language/json/converter/BpmnJsonConverter.java +++ b/modules/flowable-json-converter/src/main/java/org/flowable/editor/language/json/converter/BpmnJsonConverter.java @@ -12,10 +12,16 @@ */ package org.flowable.editor.language.json.converter; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.node.ArrayNode; -import com.fasterxml.jackson.databind.node.ObjectNode; +import java.text.DateFormat; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; + import org.apache.commons.lang3.StringUtils; import org.flowable.bpmn.model.Activity; import org.flowable.bpmn.model.Artifact; @@ -49,22 +55,16 @@ import org.flowable.editor.language.json.model.ModelInfo; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.awt.*; -import java.awt.geom.Area; -import java.awt.geom.Ellipse2D; -import java.awt.geom.Path2D; -import java.awt.geom.Rectangle2D; -import java.text.DateFormat; -import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.Collections; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; -import java.util.Map; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.node.ArrayNode; +import com.fasterxml.jackson.databind.node.ObjectNode; + +import math.geom2d.Point2D; +import math.geom2d.conic.Circle2D; +import math.geom2d.curve.AbstractContinuousCurve2D; +import math.geom2d.line.Line2D; +import math.geom2d.polygon.Polyline2D; /** * @author Tijs Rademakers @@ -190,8 +190,6 @@ public class BpmnJsonConverter implements EditorJsonConstants, StencilConstants, DI_GATEWAY.add(STENCIL_GATEWAY_PARALLEL); } - protected double lineWidth = 0.000001d; - public ObjectNode convertToJson(BpmnModel model) { return convertToJson(model, null, null); } @@ -936,16 +934,16 @@ public class BpmnJsonConverter implements EditorJsonConstants, StencilConstants, nextPointInLineY += targetInfo.getY(); } - java.awt.geom.Line2D firstLine = new java.awt.geom.Line2D.Double(sourceRefLineX, sourceRefLineY, nextPointInLineX, nextPointInLineY); + Line2D firstLine = new Line2D(sourceRefLineX, sourceRefLineY, nextPointInLineX, nextPointInLineY); String sourceRefStencilId = BpmnJsonConverterUtil.getStencilId(sourceRefNode); String targetRefStencilId = BpmnJsonConverterUtil.getStencilId(targetRefNode); List graphicInfoList = new ArrayList<>(); - Shape source2D = null; + AbstractContinuousCurve2D source2D = null; if (DI_CIRCLES.contains(sourceRefStencilId)) { - source2D = createEllipse(sourceInfo, sourceDockersX, sourceDockersY); + source2D = new Circle2D(sourceInfo.getX() + sourceDockersX, sourceInfo.getY() + sourceDockersY, sourceDockersX); } else if (DI_RECTANGLES.contains(sourceRefStencilId)) { source2D = createRectangle(sourceInfo); @@ -955,16 +953,16 @@ public class BpmnJsonConverter implements EditorJsonConstants, StencilConstants, } if (source2D != null) { - Collection intersections = getIntersections(firstLine, source2D); + Collection intersections = source2D.intersections(firstLine); if (intersections != null && intersections.size() > 0) { - java.awt.geom.Point2D intersection = intersections.iterator().next(); - graphicInfoList.add(createGraphicInfo(intersection.getX(), intersection.getY())); + Point2D intersection = intersections.iterator().next(); + graphicInfoList.add(createGraphicInfo(intersection.x(), intersection.y())); } else { graphicInfoList.add(createGraphicInfo(sourceRefLineX, sourceRefLineY)); } } - java.awt.geom.Line2D lastLine = null; + Line2D lastLine = null; if (dockersNode.size() > 2) { for (int i = 1; i < dockersNode.size() - 1; i++) { @@ -982,13 +980,13 @@ public class BpmnJsonConverter implements EditorJsonConstants, StencilConstants, endLastLineX += targetInfo.getX(); endLastLineY += targetInfo.getY(); - lastLine = new java.awt.geom.Line2D.Double(startLastLineX, startLastLineY, endLastLineX, endLastLineY); + lastLine = new Line2D(startLastLineX, startLastLineY, endLastLineX, endLastLineY); } else { lastLine = firstLine; } - Shape target2D = null; + AbstractContinuousCurve2D target2D = null; if (DI_RECTANGLES.contains(targetRefStencilId)) { target2D = createRectangle(targetInfo); @@ -997,19 +995,19 @@ public class BpmnJsonConverter implements EditorJsonConstants, StencilConstants, double targetDockersX = dockersNode.get(dockersNode.size() - 1).get(EDITOR_BOUNDS_X).asDouble(); double targetDockersY = dockersNode.get(dockersNode.size() - 1).get(EDITOR_BOUNDS_Y).asDouble(); - target2D = createEllipse(targetInfo, targetDockersX, targetDockersY); + target2D = new Circle2D(targetInfo.getX() + targetDockersX, targetInfo.getY() + targetDockersY, targetDockersX); } else if (DI_GATEWAY.contains(targetRefStencilId)) { target2D = createGateway(targetInfo); } if (target2D != null) { - Collection intersections = getIntersections(lastLine, target2D); + Collection intersections = target2D.intersections(lastLine); if (intersections != null && intersections.size() > 0) { - java.awt.geom.Point2D intersection = intersections.iterator().next(); - graphicInfoList.add(createGraphicInfo(intersection.getX(), intersection.getY())); + Point2D intersection = intersections.iterator().next(); + graphicInfoList.add(createGraphicInfo(intersection.x(), intersection.y())); } else { - graphicInfoList.add(createGraphicInfo(lastLine.getX2(), lastLine.getY2())); + graphicInfoList.add(createGraphicInfo(lastLine.getPoint2().x(), lastLine.getPoint2().y())); } } @@ -1017,62 +1015,22 @@ public class BpmnJsonConverter implements EditorJsonConstants, StencilConstants, } } - protected Shape createEllipse(GraphicInfo sourceInfo, double halfWidth, double halfHeight) { - return new Ellipse2D.Double( - sourceInfo.getX(), sourceInfo.getY(), 2* halfWidth, 2* halfHeight - ); - } - - protected Collection getIntersections(java.awt.geom.Line2D line, Shape shape) { - Area intersectionArea = new Area(getLineShape(line)); - Area shapeArea = new Area(shape); - intersectionArea.intersect(shapeArea); - if (!intersectionArea.isEmpty()) { - Rectangle2D bounds2D = intersectionArea.getBounds2D(); - HashSet intersections = new HashSet<>(2); - - if (!shapeArea.contains(line.getX1(), line.getY1())) { - intersections.add(new java.awt.geom.Point2D.Double(bounds2D.getX(), bounds2D.getY())); - } - if (!shapeArea.contains(line.getX2(), line.getY2())) { - intersections.add(new java.awt.geom.Point2D.Double( - bounds2D.getX() + bounds2D.getWidth(), bounds2D.getY() + bounds2D.getHeight())); - } - - return intersections; - } - return Collections.EMPTY_SET; - } - - protected Shape getLineShape(java.awt.geom.Line2D line2D) { - Path2D line = new Path2D.Double(Path2D.WIND_NON_ZERO, 4); - line.moveTo(line2D.getX1(), line2D.getY1()); - line.lineTo(line2D.getX2(), line2D.getY2()); - line.lineTo(line2D.getX2() + lineWidth, line2D.getY2() + lineWidth); - line.closePath(); - return line; - } - - protected Shape createRectangle(GraphicInfo graphicInfo) { - return new Rectangle2D.Double( - graphicInfo.getX(), graphicInfo.getY(), - graphicInfo.getWidth(), graphicInfo.getHeight() - ); + private Polyline2D createRectangle(GraphicInfo graphicInfo) { + Polyline2D rectangle = new Polyline2D(new Point2D(graphicInfo.getX(), graphicInfo.getY()), new Point2D(graphicInfo.getX() + graphicInfo.getWidth(), graphicInfo.getY()), + new Point2D(graphicInfo.getX() + graphicInfo.getWidth(), graphicInfo.getY() + graphicInfo.getHeight()), new Point2D(graphicInfo.getX(), graphicInfo.getY() + graphicInfo.getHeight()), + new Point2D(graphicInfo.getX(), graphicInfo.getY())); + return rectangle; } - protected Shape createGateway(GraphicInfo graphicInfo) { + private Polyline2D createGateway(GraphicInfo graphicInfo) { double middleX = graphicInfo.getX() + (graphicInfo.getWidth() / 2); double middleY = graphicInfo.getY() + (graphicInfo.getHeight() / 2); - Path2D.Double gatewayShape = new Path2D.Double(Path2D.WIND_NON_ZERO, 4); - gatewayShape.moveTo(graphicInfo.getX(), middleY); - gatewayShape.lineTo(middleX, graphicInfo.getY()); - gatewayShape.lineTo(graphicInfo.getX() + graphicInfo.getWidth(), middleY); - gatewayShape.lineTo(middleX, graphicInfo.getY() + graphicInfo.getHeight()); - gatewayShape.closePath(); + Polyline2D gatewayRectangle = new Polyline2D(new Point2D(graphicInfo.getX(), middleY), new Point2D(middleX, graphicInfo.getY()), new Point2D(graphicInfo.getX() + graphicInfo.getWidth(), middleY), + new Point2D(middleX, graphicInfo.getY() + graphicInfo.getHeight()), new Point2D(graphicInfo.getX(), middleY)); - return gatewayShape; + return gatewayRectangle; } private GraphicInfo createGraphicInfo(double x, double y) { diff --git a/modules/flowable-json-converter/src/test/java/org/flowable/editor/language/CollapsebleSubprocessTest.java b/modules/flowable-json-converter/src/test/java/org/flowable/editor/language/CollapsebleSubprocessTest.java index bc267960d5..b891dc898a 100644 --- a/modules/flowable-json-converter/src/test/java/org/flowable/editor/language/CollapsebleSubprocessTest.java +++ b/modules/flowable-json-converter/src/test/java/org/flowable/editor/language/CollapsebleSubprocessTest.java @@ -1,9 +1,9 @@ /* Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -14,7 +14,6 @@ package org.flowable.editor.language; import static org.hamcrest.CoreMatchers.instanceOf; import static org.hamcrest.core.Is.is; -import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertThat; import java.util.List; @@ -31,7 +30,7 @@ import org.junit.Test; * Created by Pardo David on 6/01/2017. */ public class CollapsebleSubprocessTest extends AbstractConverterTest { - + private static final String START_EVENT = "sid-89C70A03-C51B-4185-AB85-B8476E7A4F0C"; private static final String SEQUENCEFLOW_TO_COLLAPSEDSUBPROCESS = "sid-B80498C9-A45C-4D58-B4AA-5393A409ACAA"; private static final String COLLAPSEDSUBPROCESS = "sid-C20D5023-C2B9-4102-AA17-7F16E49E47C1"; @@ -40,8 +39,6 @@ public class CollapsebleSubprocessTest extends AbstractConverterTest { private static final String IN_CSB_USERTASK = "sid-F64640C9-9585-4927-806B-8B0A03DB2B8B"; private static final String IN_CSB_SEQUENCEFLOW_TO_END = "sid-C1EFE310-3B12-42DA-AEE6-5E442C2FEF19"; - private static final double PRECISION = 0.0002; - @Test public void testItShouldBePossibleToConvertModelerJsonToJava() throws Exception{ BpmnModel bpmnModel = readJsonFile(); @@ -77,12 +74,12 @@ public class CollapsebleSubprocessTest extends AbstractConverterTest { //the intersection points are not full values so its a strange double here... start = flowLocationGraphicInfo.get(0); - assertEquals(102.99814034216989, start.getX(), PRECISION); - assertEquals(111.23619118649086, start.getY(), PRECISION); + assertThat(start.getX(),is(102.99814034216989)); + assertThat(start.getY(),is(111.23619118649086)); end = flowLocationGraphicInfo.get(1); - assertEquals(165.0, end.getX(),PRECISION); - assertEquals(112.21259842519686, end.getY(), PRECISION); + assertThat(end.getX(),is(165.0)); + assertThat(end.getY(),is(112.21259842519686)); //validate graphic infos FlowElement flowElement = bpmnModel.getFlowElement(IN_CSB_START_EVENT); @@ -103,8 +100,8 @@ public class CollapsebleSubprocessTest extends AbstractConverterTest { assertThat(flowLocationGraphicInfo.size(),is(2)); start = flowLocationGraphicInfo.get(0); - assertEquals(120.0, start.getX(), PRECISION); - assertEquals(150.0, start.getY(), PRECISION); + assertThat(start.getX(),is(120.0)); + assertThat(start.getY(),is(150.0)); end = flowLocationGraphicInfo.get(1); assertThat(end.getX(),is(232.0)); @@ -128,8 +125,8 @@ public class CollapsebleSubprocessTest extends AbstractConverterTest { assertThat(flowLocationGraphicInfo.size() , is(2)); start = flowLocationGraphicInfo.get(0); - assertEquals(332.0, start.getX(), PRECISION); - assertEquals(150.0, start.getY(), PRECISION); + assertThat(start.getX(),is(332.0)); + assertThat(start.getY(),is(150.0)); end = flowLocationGraphicInfo.get(1); assertThat(end.getX(),is(435.0)); @@ -140,4 +137,4 @@ public class CollapsebleSubprocessTest extends AbstractConverterTest { protected String getResource() { return "test.collapsed-subprocess.json"; } -} +} \ No newline at end of file diff --git a/modules/flowable-json-converter/src/test/java/org/flowable/editor/language/EventSubprocessSequenceFlowTest.java b/modules/flowable-json-converter/src/test/java/org/flowable/editor/language/EventSubprocessSequenceFlowTest.java index 8ed4777476..a1416e5269 100644 --- a/modules/flowable-json-converter/src/test/java/org/flowable/editor/language/EventSubprocessSequenceFlowTest.java +++ b/modules/flowable-json-converter/src/test/java/org/flowable/editor/language/EventSubprocessSequenceFlowTest.java @@ -1,9 +1,9 @@ /* Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -13,7 +13,6 @@ package org.flowable.editor.language; import static org.hamcrest.CoreMatchers.is; -import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertThat; import java.util.List; @@ -30,8 +29,6 @@ public class EventSubprocessSequenceFlowTest extends AbstractConverterTest { private static final String EVENT_SUBPROCESS_ID = "sid-3AE5DD30-CE0E-4660-871F-A515E39EECA6"; private static final String FROM_SE_TO_TASK = "sid-45B32336-D4E3-4576-8377-2D81C0EE02C4"; - private static final double PRECISION = 0.0002; - @Test public void oneWay() throws Exception{ BpmnModel bpmnModel = readJsonFile(); @@ -53,12 +50,12 @@ public class EventSubprocessSequenceFlowTest extends AbstractConverterTest { List graphicInfo = model.getFlowLocationGraphicInfo(FROM_SE_TO_TASK); GraphicInfo start = graphicInfo.get(0); - assertEquals(180.5, start.getX(), PRECISION); //75.0+105.5 (parent + interception point) - assertEquals(314.0, start.getY(), PRECISION); //230.0 + 99.0 - 15.0 (parent + lower right y - bounds y) + assertThat(start.getX(),is(180.5)); //75.0+105.5 (parent + interception point) + assertThat(start.getY(),is(314.0)); //230.0 + 99.0 - 15.0 (parent + lower right y - bounds y) GraphicInfo end = graphicInfo.get(1); - assertEquals(225.5, end.getX(), PRECISION); //75.0 +150.5 - assertEquals(314.0, end.getY(), PRECISION); //230.0 + 44.0 + 40 + assertThat(end.getX(),is(225.5)); //75.0 +150.5 + assertThat(end.getY(),is(314.0)); //230.0 + 44.0 + 40 } @Override diff --git a/modules/flowable-json-converter/src/test/java/org/flowable/editor/language/json/converter/BpmnJsonConverterTest.java b/modules/flowable-json-converter/src/test/java/org/flowable/editor/language/json/converter/BpmnJsonConverterTest.java deleted file mode 100644 index 4055d27cca..0000000000 --- a/modules/flowable-json-converter/src/test/java/org/flowable/editor/language/json/converter/BpmnJsonConverterTest.java +++ /dev/null @@ -1,70 +0,0 @@ -package org.flowable.editor.language.json.converter; - -import org.junit.Test; - -import java.awt.*; -import java.awt.geom.Area; -import java.awt.geom.Ellipse2D; -import java.awt.geom.Line2D; -import java.awt.geom.Path2D; -import java.awt.geom.Rectangle2D; - -import static org.hamcrest.CoreMatchers.is; -import static org.hamcrest.MatcherAssert.assertThat; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; - -/** - * This class tests {@link BpmnJsonConverter} implementation - */ -public class BpmnJsonConverterTest { - - private static final double SMALL_DELTA = 0.000001; - private static final double PRECISION = 0.0002; - - @Test - public void testLineCircleIntersections() { - // Arrange - Path2D line = new Path2D.Double(Path2D.WIND_NON_ZERO, 3); - line.moveTo(1, 10); - line.lineTo(20-1, 10); - line.lineTo(20-1 + SMALL_DELTA, 10 + SMALL_DELTA); - line.closePath(); - Ellipse2D.Double circle = new Ellipse2D.Double(4, 8, 4, 4); - - // Act - Area intersectionArea = new Area(line); - intersectionArea.intersect(new Area(circle)); - - // Assert - assertFalse(intersectionArea.isEmpty()); - Rectangle2D bounds2D = intersectionArea.getBounds2D(); - assertEquals(4d, bounds2D.getX(), PRECISION); - assertEquals(10d, bounds2D.getY(), PRECISION); - assertEquals(8d, bounds2D.getX() + bounds2D.getWidth(), PRECISION); - assertEquals(10d, bounds2D.getY() + bounds2D.getHeight(), PRECISION); - } - - @Test - public void testLineRectangleIntersections() { - // Arrange - Path2D line = new Path2D.Double(Path2D.WIND_NON_ZERO, 3); - line.moveTo(1, 10); - line.lineTo(20 - 1, 10); - line.lineTo(20 - 1 + SMALL_DELTA, 10 + SMALL_DELTA); - line.closePath(); - Rectangle2D.Double rectangle = new Rectangle2D.Double(4, 8, 4, 4); - - // Act - Area intersectionArea = new Area(line); - intersectionArea.intersect(new Area(rectangle)); - - // Assert - assertFalse(intersectionArea.isEmpty()); - Rectangle2D bounds2D = intersectionArea.getBounds2D(); - assertEquals(4d, bounds2D.getX(), PRECISION); - assertEquals(10d, bounds2D.getY(), PRECISION); - assertEquals(8d, bounds2D.getX() + bounds2D.getWidth(), PRECISION); - assertEquals(10d, bounds2D.getY() + bounds2D.getHeight(), PRECISION); - } -} diff --git a/pom.xml b/pom.xml index fd99060100..bbe24fbb30 100755 --- a/pom.xml +++ b/pom.xml @@ -859,6 +859,11 @@ imgscalr-lib 4.2 + + math.geom2d + javaGeom + 0.11.1 + org.apache.camel -- GitLab