private static Point2D createPoint2D(Point p, double factor) { return Point2D.create(p.getX() * factor, p.getY() * factor); }
private void createDockersForBoundaryEvent(BoundaryEvent boundaryEvent) { List<Point> dockers = _dockers.get(boundaryEvent.getId()); StringBuffer dockerBuff = new StringBuffer(); for (int i = 0; i < dockers.size(); i++) { dockerBuff.append(dockers.get(i).getX()); dockerBuff.append("^"); dockerBuff.append(dockers.get(i).getY()); dockerBuff.append("|"); } ExtendedMetaData metadata = ExtendedMetaData.INSTANCE; EAttributeImpl extensionAttribute = (EAttributeImpl) metadata.demandFeature( "http://www.jboss.org/drools", "dockerinfo", false, false); SimpleFeatureMapEntry extensionEntry = new SimpleFeatureMapEntry(extensionAttribute, dockerBuff.toString()); boundaryEvent.getAnyAttribute().add(extensionEntry); }
private List<Point> mockPoints(float mockXStart, float mockYStart, int size) { List<Point> result = new ArrayList<>(); for (int i = 0; i < size; i++) { Point point = mock(Point.class); when(point.getX()).thenReturn(mockXStart + i); when(point.getY()).thenReturn(mockYStart + i); result.add(point); } return result; } }
private static void assertPointsEqual(List<Point> expected, List<Point> given, String message) { assertEquals(expected.size(), given.size()); for (int i = 0; i < expected.size(); i++) { Point pe = expected.get(i); Point pg = given.get(i); if (pe.getX() != pg.getX() || pe.getY() != pg.getY()) { failNotEquals(message, expected, given); } } }
private static Point2D offsetPosition(Bounds sourceBounds, Point wayPoint, double factor) { return Point2D.create((wayPoint.getX() * factor) - (sourceBounds.getX() * factor), (wayPoint.getY() * factor) - (sourceBounds.getY() * factor)); } }
@Before public void setUp() { when(bounds.getX()).thenReturn(BOUNDS_X); when(bounds.getY()).thenReturn(BOUNDS_Y); when(bounds.getWidth()).thenReturn(BOUNDS_WIDTH); when(bounds.getHeight()).thenReturn(BOUNDS_HEIGHT); when(point.getX()).thenReturn(WAY_POINT_X); when(point.getY()).thenReturn(WAY_POINT_Y); when(definitionResolver.getResolutionFactor()).thenReturn(1d); when(definitionResolver.getEdge(EDGE_ID)).thenReturn(edge); when(definitionResolver.getShape(SHAPE_ID)).thenReturn(shape); when(shape.getBounds()).thenReturn(bounds); }
public static void assertWaypoint(float x, float y, int index, List<Point> waypoints) { assertEquals(x, waypoints.get(index).getX(), 0); assertEquals(y, waypoints.get(index).getY(), 0); }
private void assertPoints(List<Point> originalPoints, List<Point2D> points) { assertEquals(originalPoints.size(), points.size()); for (int i = 0; i < points.size(); i++) { assertEquals(originalPoints.get(i).getX(), points.get(i).getX(), 0); assertEquals(originalPoints.get(i).getY(), points.get(i).getY(), 0); } }
Bounds sourceBounds = _bounds.get(sequenceFlow.getSourceRef().getId()); if (dockers != null && dockers.size() > 0 && dockers.get(0).getX() > -1 && dockers.get(0).getY() > -1) { point.setX(sourceBounds.getX() + dockers.get(0).getX()); point.setY(sourceBounds.getY() + dockers.get(0).getY()); } else { Bounds targetBounds = _bounds.get(sequenceFlow.getTargetRef().getId()); if (dockers != null && dockers.size() > 1 && dockers.get(dockers.size() - 1).getX() > -1 && dockers.get(dockers.size() - 1).getY() > -1) { point.setX(targetBounds.getX() + dockers.get(dockers.size() - 1).getX()); point.setY(targetBounds.getY() + dockers.get(dockers.size() - 1).getY()); } else {
generator.writeStartObject(); generator.writeObjectField("x", p.getX()); generator.writeObjectField("y", p.getY());
@Test public void testResolutionFactoryIsBeingAppliedOnControlPoints() { when(definitionResolver.getResolutionFactor()).thenReturn(0.25d); when(edge.getWaypoint()).thenReturn(Collections.emptyList()); Point2D point = PropertyReaderUtils.getSourcePosition(definitionResolver, EDGE_ID, SHAPE_ID); assertPoint(0.5f, 0.5f, point); when(edge.getWaypoint()).thenReturn(Collections.emptyList()); point = PropertyReaderUtils.getTargetPosition(definitionResolver, EDGE_ID, SHAPE_ID); assertPoint(0, 0.5f, point); List<Point> waypoints = mockPoints(1, 2, 3); when(edge.getWaypoint()).thenReturn(waypoints); List<Point2D> result = PropertyReaderUtils.getControlPoints(definitionResolver, EDGE_ID); waypoints.remove(0); waypoints.remove(waypoints.size() - 1); assertEquals(waypoints.size(), result.size()); for (int i = 0; i < result.size(); i++) { assertEquals(waypoints.get(i).getX() * 0.25d, result.get(i).getX(), 0); assertEquals(waypoints.get(i).getY() * 0.25d, result.get(i).getY(), 0); } }
Point waypoint = waypoints.get(0); writeWaypointObject(generator, waypoint.getX() - sourceBounds.getX(), waypoint.getY() - sourceBounds.getY()); } else { Point waypoint = waypoints.get(i); writeWaypointObject(generator, waypoint.getX(), waypoint.getY()); Point waypoint = waypoints.get(waypoints.size() - 1); writeWaypointObject(generator, waypoint.getX() - targetBounds.getX(), waypoint.getY() - targetBounds.getY()); } else {
if (sourceBounds != null) { Point first = edgePoints.get(0); first.setX(first.getX() + getBoundsForElement(container, plane).getX()); first.setY(first.getY() + getBoundsForElement(container, if (targetBounds != null) { Point last = edgePoints.get(edgePoints.size() - 1); last.setX(last.getX() + getBoundsForElement(container, plane).getX()); last.setY(last.getY() + getBoundsForElement(container,
if (eleBounds != null) { Point first = edgePoints.get(0); first.setX(first.getX() + laneBounds.getX()); first.setY(first.getY() + laneBounds.getY()); if (eleBounds != null) { Point last = edgePoints.get(edgePoints.size() - 1); last.setX(last.getX() + laneBounds.getX()); last.setY(last.getY() + laneBounds.getY());
@Test public void get2Waypoints() { TestDefinitionsWriter d = new TestDefinitionsWriter(); PropertyReaderFactory factory = new PropertyReaderFactory(d.getDefinitionResolver()); Bounds sourceBounds = boundsOf(10, 10, 50, 50); FlowNode source = d.mockNode(SOURCE_ID, sourceBounds); Bounds targetBounds = boundsOf(100, 100, 60, 60); FlowNode target = d.mockNode(TARGET_ID, targetBounds); Point sourcePoint = pointOf(10, 20); Point mid1 = pointOf(15, 25); Point mid2 = pointOf(20, 30); Point targetPoint = pointOf(100, 120); List<Point> waypoints = asList(sourcePoint, mid1, mid2, targetPoint); SequenceFlow el = d.sequenceFlowOf(SEQ_ID, source, target, waypoints); SequenceFlowPropertyReader p = factory.of(el); List<Point2D> controlPoints = p.getControlPoints(); List<Point2D> expected = asList( Point2D.create(mid1.getX(), mid1.getY()), Point2D.create(mid2.getX(), mid2.getY())); assertEquals(expected, controlPoints); }
@Test public void getConnectionsWithWaypoints() { TestDefinitionsWriter d = new TestDefinitionsWriter(); PropertyReaderFactory factory = new PropertyReaderFactory(d.getDefinitionResolver()); Bounds sourceBounds = boundsOf(10, 10, 50, 50); FlowNode source = d.mockNode(SOURCE_ID, sourceBounds); Bounds targetBounds = boundsOf(100, 100, 60, 60); FlowNode target = d.mockNode(TARGET_ID, targetBounds); Point sourcePoint = pointOf(10, 20); Point targetPoint = pointOf(100, 120); List<Point> waypoints = asList(sourcePoint, targetPoint); SequenceFlow el = d.sequenceFlowOf(SEQ_ID, source, target, waypoints); SequenceFlowPropertyReader p = factory.of(el); Connection sourceConnection = p.getSourceConnection(); assertEquals(sourcePoint.getX() - sourceBounds.getX(), (float) sourceConnection.getLocation().getX()); assertEquals(sourcePoint.getY() - sourceBounds.getY(), (float) sourceConnection.getLocation().getY()); Connection targetConnection = p.getTargetConnection(); assertEquals(targetPoint.getX() - targetBounds.getX(), (float) targetConnection.getLocation().getX()); assertEquals(targetPoint.getY() - targetBounds.getY(), (float) targetConnection.getLocation().getY()); }
@Test public void get1Waypoint() { TestDefinitionsWriter d = new TestDefinitionsWriter(); PropertyReaderFactory factory = new PropertyReaderFactory(d.getDefinitionResolver()); Bounds sourceBounds = boundsOf(10, 10, 50, 50); FlowNode source = d.mockNode(SOURCE_ID, sourceBounds); Bounds targetBounds = boundsOf(100, 100, 60, 60); FlowNode target = d.mockNode(TARGET_ID, targetBounds); Point sourcePoint = pointOf(10, 20); Point mid1 = pointOf(15, 25); Point targetPoint = pointOf(100, 120); List<Point> waypoints = asList(sourcePoint, mid1, targetPoint); SequenceFlow el = d.sequenceFlowOf(SEQ_ID, source, target, waypoints); SequenceFlowPropertyReader p = factory.of(el); List<Point2D> controlPoints = p.getControlPoints(); List<Point2D> expected = Collections.singletonList( Point2D.create(mid1.getX(), mid1.getY())); assertEquals(expected, controlPoints); }