@Override protected Bounds computeBounds(org.eclipse.dd.dc.Bounds bounds) { final double x = bounds.getX() * resolutionFactor; final double y = bounds.getY() * resolutionFactor; return Bounds.create(x, y, x + WIDTH, y + HEIGHT); }
@Override protected Bounds computeBounds(final org.eclipse.dd.dc.Bounds bounds) { final double x = bounds.getX() * resolutionFactor; final double y = bounds.getY() * resolutionFactor; return Bounds.create(x, y, x + WIDTH, y + HEIGHT); }
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)); } }
private static org.eclipse.dd.dc.Bounds mockBounds(float x, float y, float width, float height) { org.eclipse.dd.dc.Bounds bounds = mock(org.eclipse.dd.dc.Bounds.class); when(bounds.getX()).thenReturn(x); when(bounds.getY()).thenReturn(y); when(bounds.getWidth()).thenReturn(width); when(bounds.getHeight()).thenReturn(height); return bounds; } }
public static BPMNShape mockShape(String id, float x, float y, float width, float height) { BPMNShape shape = mock(BPMNShape.class); when(shape.getId()).thenReturn(id); Bounds bounds = mock(Bounds.class); when(bounds.getX()).thenReturn(x); when(bounds.getY()).thenReturn(y); when(bounds.getHeight()).thenReturn(height); when(bounds.getWidth()).thenReturn(width); when(shape.getBounds()).thenReturn(bounds); return shape; }
protected Bounds computeBounds(final org.eclipse.dd.dc.Bounds bounds) { final double x = bounds.getX() * resolutionFactor; final double y = bounds.getY() * resolutionFactor; final double width = bounds.getWidth() * resolutionFactor; final double height = bounds.getHeight() * resolutionFactor; return Bounds.create(x, y, x + width, y + height); }
public void updateShapeBoundsInLanes(BPMNPlane plane, BaseElement ele, Lane lane, float parentX, float parentY) { for (FlowNode fn : lane.getFlowNodeRefs()) { Bounds fnBounds = getBoundsForElement(fn, plane); if (fnBounds != null) { fnBounds.setX(fnBounds.getX() + parentX); fnBounds.setY(fnBounds.getY() + parentY); // if flownode is a subprocess update it too if (fn instanceof SubProcess) { updateShapeBoundsInSubprocessInLanes(plane, ele, (SubProcess) fn, fnBounds.getX(), fnBounds.getY()); } else if (fn instanceof Lane) { updateShapeBoundsInLanes(plane, ele, (Lane) fn, fnBounds.getX(), fnBounds.getY()); } } } }
public void updateShapeBoundsInSubprocessInLanes(BPMNPlane plane, BaseElement ele, SubProcess sub, float parentX, float parentY) { for (FlowElement subEle : sub.getFlowElements()) { Bounds subEleBounds = getBoundsForElement(subEle, plane); if (subEleBounds != null) { subEleBounds.setX(subEleBounds.getX() + parentX); subEleBounds.setY(subEleBounds.getY() + parentY); } if (subEle instanceof SubProcess) { updateShapeBoundsInSubprocessInLanes(plane, ele, (SubProcess) subEle, subEleBounds.getX(), subEleBounds.getY()); } } }
@Before public void setup() { FeatureMap featureMap = mock(FeatureMap.class); when(featureMap.isEmpty()).thenReturn(true); when(element.getAnyAttribute()).thenReturn(featureMap); org.eclipse.dd.dc.Bounds shapeBounds = mock(org.eclipse.dd.dc.Bounds.class); when(shapeBounds.getX()).thenReturn(1.1f); when(shapeBounds.getY()).thenReturn(2.2f); when(shapeBounds.getWidth()).thenReturn(100f); when(shapeBounds.getHeight()).thenReturn(545.34f); when(shape.getBounds()).thenReturn(shapeBounds); tested = new BasePropertyReader(element, diagram, shape, RESOLUTION_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); }
private void createBpmnEdgeForAssociation(BpmnDiFactory factory, BPMNPlane plane, Association association) { BPMNEdge edge = factory.createBPMNEdge(); edge.setBpmnElement(association); DcFactory dcFactory = DcFactory.eINSTANCE; Point point = dcFactory.createPoint(); Bounds sourceBounds = _bounds.get(association.getSourceRef().getId()); point.setX(sourceBounds.getX() + (sourceBounds.getWidth() / 2)); point.setY(sourceBounds.getY() + (sourceBounds.getHeight() / 2)); edge.getWaypoint().add(point); List<Point> dockers = _dockers.get(association.getId()); for (int i = 1; i < dockers.size() - 1; i++) { edge.getWaypoint().add(dockers.get(i)); } point = dcFactory.createPoint(); Bounds targetBounds = _bounds.get(association.getTargetRef().getId()); point.setX(targetBounds.getX() + (targetBounds.getWidth() / 2)); point.setY(targetBounds.getY() + (targetBounds.getHeight() / 2)); edge.getWaypoint().add(point); plane.getPlaneElement().add(edge); }
protected org.eclipse.dd.dc.Bounds getParentActivityBounds(org.eclipse.dd.dc.Bounds parentRect) { if (getShape().getBounds() == null) { throw new IllegalArgumentException( "Cannot set parent bounds if the child " + "has undefined bounds. Use setBounds() first."); } org.eclipse.dd.dc.Bounds relativeBounds = getShape().getBounds(); float x = relativeBounds.getX(); float y = relativeBounds.getY(); float width = relativeBounds.getWidth(); float height = relativeBounds.getHeight(); float parentX = parentRect.getX(); float parentY = parentRect.getY(); org.eclipse.dd.dc.Bounds bounds = dc.createBounds(); bounds.setX(parentX + x - width / 2); bounds.setY(parentY + y - height / 2); bounds.setWidth(width); bounds.setHeight(height); return bounds; }
protected org.eclipse.dd.dc.Bounds getParentBounds(org.eclipse.dd.dc.Bounds parentRect) { if (getShape() == null) { throw new NullPointerException( "Shape is null:" + getElement().getId()); } if (getShape().getBounds() == null) { throw new IllegalArgumentException( "Cannot set parent bounds if the child " + "has undefined bounds. Use setBounds() first." + getElement().getId()); } org.eclipse.dd.dc.Bounds relativeBounds = getShape().getBounds(); float x = relativeBounds.getX(); float y = relativeBounds.getY(); float width = relativeBounds.getWidth(); float height = relativeBounds.getHeight(); float parentX = parentRect.getX(); float parentY = parentRect.getY(); org.eclipse.dd.dc.Bounds bounds = dc.createBounds(); bounds.setX(parentX + x); bounds.setY(parentY + y); bounds.setWidth(width); bounds.setHeight(height); return bounds; }
@Test public void testMarshallEmbeddedCoords() throws Exception { String END_EVENT = "shape__FF050977-4D13-47F1-8B9B-D68FDE208666"; Diagram<Graph, Metadata> diagram = unmarshall(newMarshaller, BPMN_EMBEDDED_SUBPROCESS); // we start converting from the root, then pull out the result DefinitionsConverter definitionsConverter = new DefinitionsConverter(diagram.getGraph()); Definitions definitions = definitionsConverter.toDefinitions(); List<DiagramElement> planeElement = definitions.getDiagrams().get(0).getPlane().getPlaneElement(); DiagramElement diagramElement = planeElement.stream() .filter(BPMNShape.class::isInstance) .map(s -> (BPMNShape)s) .filter(el -> el.getId().equals(END_EVENT)).findFirst().get(); BPMNShape shape = (BPMNShape) diagramElement; assertThat(shape.getBounds().getX()).isEqualTo(885f); assertThat(shape.getBounds().getY()).isEqualTo(143f); } }
public static BPMNEdge createBPMNEdge(BasePropertyWriter source, BasePropertyWriter target, Connection sourceConnection, List<ControlPoint> mid, Connection targetConnection) { BPMNEdge bpmnEdge = di.createBPMNEdge(); bpmnEdge.setId(Ids.bpmnEdge(source.getShape().getId(), target.getShape().getId())); Point2D sourcePt = getSourceLocation(source, sourceConnection); Point2D targetPt = getTargetLocation(target, targetConnection); org.eclipse.dd.dc.Point sourcePoint = pointOf( source.getShape().getBounds().getX() + sourcePt.getX(), source.getShape().getBounds().getY() + sourcePt.getY()); org.eclipse.dd.dc.Point targetPoint = pointOf( target.getShape().getBounds().getX() + targetPt.getX(), target.getShape().getBounds().getY() + targetPt.getY()); List<Point> waypoints = bpmnEdge.getWaypoint(); waypoints.add(sourcePoint); mid.stream() .map(pt -> pointOf( pt.getLocation().getX(), pt.getLocation().getY())) .forEach(waypoints::add); waypoints.add(targetPoint); return bpmnEdge; }
@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()); }