use of org.eclipse.dd.dc.Bounds in project kie-wb-common by kiegroup.
the class BoundaryEventPropertyWriterTest method testSetAbsoluteBounds.
@Test
@SuppressWarnings("unchecked")
public void testSetAbsoluteBounds() {
Node<View, Edge> node = (Node<View, Edge>) super.createNode();
Node<View, ?> dockSourceParentNode = mockNode(new Object(), org.kie.workbench.common.stunner.core.graph.content.Bounds.create(PARENT_ABSOLUTE_X1, PARENT_ABSOLUTE_Y1, PARENT_ABSOLUTE_X2, PARENT_ABSOLUTE_Y2));
double dockSourceRelativeX1 = 15d;
double dockSourceRelativeY1 = 20d;
double dockSourceRelativeX2 = 50d;
double dockSourceAbsoluteY2 = 45d;
Node<View, ?> dockSourceNode = mockNode(new Object(), org.kie.workbench.common.stunner.core.graph.content.Bounds.create(dockSourceRelativeX1, dockSourceRelativeY1, dockSourceRelativeX2, dockSourceAbsoluteY2), dockSourceParentNode);
Edge dockEdge = mock(Edge.class);
when(dockEdge.getSourceNode()).thenReturn(dockSourceNode);
Dock dock = mock(Dock.class);
when(dockEdge.getContent()).thenReturn(dock);
node.getInEdges().clear();
node.getInEdges().add(dockEdge);
propertyWriter.setAbsoluteBounds(node);
Bounds shapeBounds = propertyWriter.getShape().getBounds();
org.kie.workbench.common.stunner.core.graph.content.Bounds relativeBounds = node.getContent().getBounds();
double dockSourceAbsoluteX = PARENT_ABSOLUTE_X1 + dockSourceRelativeX1;
double dockSourceAbsoluteY = PARENT_ABSOLUTE_Y1 + dockSourceRelativeY1;
assertEquals(dockSourceAbsoluteX + relativeBounds.getX(), shapeBounds.getX(), 0);
assertEquals(dockSourceAbsoluteY + relativeBounds.getY(), shapeBounds.getY(), 0);
assertEquals(relativeBounds.getWidth(), shapeBounds.getWidth(), 0);
assertEquals(relativeBounds.getHeight(), shapeBounds.getHeight(), 0);
verifyDockerInfoWasSet(relativeBounds);
}
use of org.eclipse.dd.dc.Bounds in project kie-wb-common by kiegroup.
the class PropertyWriterUtilsTest method mockShape.
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(shape.getBounds()).thenReturn(bounds);
return shape;
}
use of org.eclipse.dd.dc.Bounds in project kie-wb-common by kiegroup.
the class PropertyReaderUtils method getTargetPosition.
public static Point2D getTargetPosition(DefinitionResolver definitionResolver, String edgeId, String targetId) {
final double resolutionFactor = definitionResolver.getResolutionFactor();
final Bounds targetBounds = definitionResolver.getShape(targetId).getBounds();
final List<Point> waypoint = definitionResolver.getEdge(edgeId).getWaypoint();
return waypoint.isEmpty() ? targetPosition(targetBounds, resolutionFactor) : offsetPosition(targetBounds, waypoint.get(waypoint.size() - 1), resolutionFactor);
}
use of org.eclipse.dd.dc.Bounds in project kie-wb-common by kiegroup.
the class PropertyReaderUtils method getSourcePosition.
public static Point2D getSourcePosition(DefinitionResolver definitionResolver, String edgeId, String sourceId) {
final double resolutionFactor = definitionResolver.getResolutionFactor();
final Bounds sourceBounds = definitionResolver.getShape(sourceId).getBounds();
final List<Point> waypoint = definitionResolver.getEdge(edgeId).getWaypoint();
return waypoint.isEmpty() ? sourcePosition(sourceBounds, resolutionFactor) : offsetPosition(sourceBounds, waypoint.get(0), resolutionFactor);
}
use of org.eclipse.dd.dc.Bounds in project kie-wb-common by kiegroup.
the class TestUtils method mockBounds.
public static Bounds mockBounds(float x, float y) {
Bounds bounds = mock(Bounds.class);
when(bounds.getX()).thenReturn(x);
when(bounds.getY()).thenReturn(y);
return bounds;
}
Aggregations