use of org.kie.workbench.common.stunner.core.graph.content.Bound in project kie-wb-common by kiegroup.
the class PointUtilsTest method testConvertToAbsoluteBoundsWhenNotChild.
@Test
public void testConvertToAbsoluteBoundsWhenNotChild() {
final Node<View, ?> node = new NodeImpl<>(UUID.uuid());
final View nodeView = new ViewImpl<>(new Decision(), Bounds.create(10, 20, 50, 60));
node.setContent(nodeView);
PointUtils.convertToAbsoluteBounds(node);
final Bound ulBound = node.getContent().getBounds().getUpperLeft();
final Bound lrBound = node.getContent().getBounds().getLowerRight();
assertThat(ulBound.getX()).isEqualTo(10);
assertThat(ulBound.getY()).isEqualTo(20);
assertThat(lrBound.getX()).isEqualTo(50);
assertThat(lrBound.getY()).isEqualTo(60);
}
use of org.kie.workbench.common.stunner.core.graph.content.Bound in project kie-wb-common by kiegroup.
the class DomainObjectAwareLienzoMultipleSelectionControlTest method testIsClickedOnShapeWhenShapeIsClicked.
@Test
public void testIsClickedOnShapeWhenShapeIsClicked() {
final DomainObjectAwareLienzoMultipleSelectionControl partiallyMockedControl = mock(DomainObjectAwareLienzoMultipleSelectionControl.class);
final View view = mock(View.class);
when(partiallyMockedControl.getSelectedNodesStream(canvasHandler)).thenReturn(Stream.of(element));
when(element.getContent()).thenReturn(view);
when(view.getBounds()).thenReturn(new Bounds(new Bound(10d, 5d), new Bound(30d, 20d)));
when(partiallyMockedControl.isClickedOnShape(canvasHandler, 25, 15)).thenCallRealMethod();
assertThat(partiallyMockedControl.isClickedOnShape(canvasHandler, 25, 15)).isTrue();
}
use of org.kie.workbench.common.stunner.core.graph.content.Bound in project kie-wb-common by kiegroup.
the class AbstractGraphCommandTest method mockBounds.
public static Bounds mockBounds(final double x, final double y, final double w, final double h) {
Bounds bounds = mock(Bounds.class);
Bound boundUL = mock(Bound.class);
Bound boundLR = mock(Bound.class);
when(boundUL.getX()).thenReturn(x);
when(boundUL.getY()).thenReturn(y);
when(boundLR.getX()).thenReturn(x + w);
when(boundLR.getY()).thenReturn(y + h);
when(bounds.getLowerRight()).thenReturn(boundLR);
when(bounds.getUpperLeft()).thenReturn(boundUL);
return bounds;
}
use of org.kie.workbench.common.stunner.core.graph.content.Bound in project kie-wb-common by kiegroup.
the class CloneNodeCommand method cloneBounds.
Bounds cloneBounds(final Bounds bounds) {
final Bound ul = bounds.getUpperLeft();
final Bound lr = bounds.getLowerRight();
return Bounds.create(ul.getX(), ul.getY(), lr.getX(), lr.getY());
}
use of org.kie.workbench.common.stunner.core.graph.content.Bound in project kie-wb-common by kiegroup.
the class BoundaryEventPropertyWriter method setAbsoluteBounds.
@Override
public void setAbsoluteBounds(Node<? extends View, ?> node) {
Bound ul = node.getContent().getBounds().getUpperLeft();
// docker information is relative
setDockerInfo(Point2D.create(ul.getX(), ul.getY()));
Optional<Node<View, Edge>> dockSourceNode = getDockSourceNode(node);
if (dockSourceNode.isPresent()) {
// docked node bounds are relative to the dockSourceNode in Stunner, but not in bpmn2 standard so the node
// absolute bounds must be calculated by using hte dockSourceNode absolute coordinates.
Bounds dockSourceNodeBounds = absoluteBounds(dockSourceNode.get());
Bounds nodeBounds = node.getContent().getBounds();
double x = dockSourceNodeBounds.getX() + nodeBounds.getUpperLeft().getX();
double y = dockSourceNodeBounds.getY() + nodeBounds.getUpperLeft().getY();
super.setBounds(Bounds.create(x, y, x + nodeBounds.getWidth(), y + nodeBounds.getHeight()));
} else {
// uncommon case
super.setAbsoluteBounds(node);
}
}
Aggregations