提交 f1c5cdc1 编写于 作者: T Tijs Rademakers

Revert "#701 Remove JavaGeom dependency (#707)"

This reverts commit ca54e734.
上级 ca54e734
......@@ -72,15 +72,15 @@ flowable-ui-modeler-rest<version><.jar | -source.jar | -javadoc.jar>
flowable-ui-task-conf<version><.jar | -source.jar | -javadoc.jar>
flowable-ui-task-logic<version><.jar | -source.jar | -javadoc.jar>
flowable-ui-task-rest<version><.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-<version>.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
......
......@@ -55,7 +55,7 @@
</plugins>
<pluginManagement>
<plugins>
<!--This plugin's configuration is used to store Eclipse
<!--This plugin's configuration is used to store Eclipse
m2e settings only. It has no influence on the Maven build itself. -->
<plugin>
<groupId>org.eclipse.m2e</groupId>
......@@ -116,6 +116,10 @@
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
</dependency>
<dependency>
<groupId>math.geom2d</groupId>
<artifactId>javaGeom</artifactId>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
......
......@@ -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<GraphicInfo> 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<Point2D> intersections = getIntersections(firstLine, source2D);
Collection<Point2D> 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<Point2D> intersections = getIntersections(lastLine, target2D);
Collection<Point2D> 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<Point2D> 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<Point2D> 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) {
......
......@@ -12,7 +12,7 @@
<relativePath>../..</relativePath>
<version>6.3.0-SNAPSHOT</version>
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<flowable.artifact>
......@@ -115,15 +115,19 @@
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
</dependency>
<dependency>
<groupId>math.geom2d</groupId>
<artifactId>javaGeom</artifactId>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>provided</scope>
</dependency>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>
......@@ -134,7 +138,7 @@
<scope>test</scope>
</dependency>
</dependencies>
<profiles>
<profile>
<id>distro</id>
......
......@@ -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<GraphicInfo> 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<java.awt.geom.Point2D> intersections = getIntersections(firstLine, source2D);
Collection<Point2D> 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<java.awt.geom.Point2D> intersections = getIntersections(lastLine, target2D);
Collection<Point2D> 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<java.awt.geom.Point2D> 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<java.awt.geom.Point2D> 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) {
......
/* 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
/* 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> 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
......
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);
}
}
......@@ -859,6 +859,11 @@
<artifactId>imgscalr-lib</artifactId>
<version>4.2</version>
</dependency>
<dependency>
<groupId>math.geom2d</groupId>
<artifactId>javaGeom</artifactId>
<version>0.11.1</version>
</dependency>
<!-- Camel integration -->
<dependency>
<groupId>org.apache.camel</groupId>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册