use of org.eclipse.dd.dc.Bounds in project kie-wb-common by kiegroup.
the class PropertyWriterUtils method getTargetLocation.
private static Point2D getTargetLocation(BasePropertyWriter target, Connection targetConnection) {
Point2D location = targetConnection.getLocation();
if (location == null) {
Bounds bounds = target.getShape().getBounds();
location = Point2D.create(0, bounds.getHeight() / 2);
}
return location;
}
use of org.eclipse.dd.dc.Bounds in project kie-wb-common by kiegroup.
the class PropertyWriterUtils method getSourceLocation.
private static Point2D getSourceLocation(BasePropertyWriter source, Connection sourceConnection) {
Point2D location = sourceConnection.getLocation();
if (location == null) {
Bounds bounds = source.getShape().getBounds();
location = Point2D.create(bounds.getWidth(), bounds.getHeight() / 2);
}
return location;
}
use of org.eclipse.dd.dc.Bounds in project kie-wb-common by kiegroup.
the class BoundaryEventPropertyWriterTest method testSetAbsoluteBoundsWhenDockedSourceNodeIsNotPresent.
@Test
@SuppressWarnings("unchecked")
public void testSetAbsoluteBoundsWhenDockedSourceNodeIsNotPresent() {
// no dock source is set
Node<View, Edge> node = (Node<View, Edge>) super.createNode();
org.kie.workbench.common.stunner.core.graph.content.Bounds relativeBounds = node.getContent().getBounds();
double absoluteX = PARENT_ABSOLUTE_X1 + relativeBounds.getUpperLeft().getX();
double absoluteY = PARENT_ABSOLUTE_Y1 + relativeBounds.getUpperLeft().getY();
propertyWriter.setAbsoluteBounds(node);
Bounds shapeBounds = propertyWriter.getShape().getBounds();
assertEquals(absoluteX, shapeBounds.getX(), 0);
assertEquals(absoluteY, 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 BaseEventPropertyReaderTest method testComputeBounds.
@Test
public void testComputeBounds() {
Bounds bounds = mockBounds(X, Y);
org.kie.workbench.common.stunner.core.graph.content.Bounds result = propertyReader.computeBounds(bounds);
assertBounds(X * RESOLUTION_FACTOR, Y * RESOLUTION_FACTOR, X * RESOLUTION_FACTOR + EventPropertyReader.WIDTH, Y * RESOLUTION_FACTOR + EventPropertyReader.HEIGHT, result);
}
use of org.eclipse.dd.dc.Bounds in project kie-wb-common by kiegroup.
the class SequenceFlowPropertyReaderTest method get2Waypoints.
@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);
}
Aggregations