Search in sources :

Example 6 with Bound

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);
}
Also used : NodeImpl(org.kie.workbench.common.stunner.core.graph.impl.NodeImpl) Bound(org.kie.workbench.common.stunner.core.graph.content.Bound) ViewImpl(org.kie.workbench.common.stunner.core.graph.content.view.ViewImpl) View(org.kie.workbench.common.stunner.core.graph.content.view.View) Decision(org.kie.workbench.common.dmn.api.definition.model.Decision) Test(org.junit.Test)

Example 7 with Bound

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();
}
Also used : Bounds(org.kie.workbench.common.stunner.core.graph.content.Bounds) Bound(org.kie.workbench.common.stunner.core.graph.content.Bound) View(org.kie.workbench.common.stunner.core.graph.content.view.View) WiresCanvasView(org.kie.workbench.common.stunner.client.lienzo.canvas.wires.WiresCanvasView) Test(org.junit.Test)

Example 8 with Bound

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;
}
Also used : Bounds(org.kie.workbench.common.stunner.core.graph.content.Bounds) Bound(org.kie.workbench.common.stunner.core.graph.content.Bound)

Example 9 with Bound

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());
}
Also used : Bound(org.kie.workbench.common.stunner.core.graph.content.Bound)

Example 10 with Bound

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);
    }
}
Also used : PropertyWriterUtils.getDockSourceNode(org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.properties.util.PropertyWriterUtils.getDockSourceNode) Node(org.kie.workbench.common.stunner.core.graph.Node) Bounds(org.kie.workbench.common.stunner.core.graph.content.Bounds) Bound(org.kie.workbench.common.stunner.core.graph.content.Bound)

Aggregations

Bound (org.kie.workbench.common.stunner.core.graph.content.Bound)40 Bounds (org.kie.workbench.common.stunner.core.graph.content.Bounds)24 View (org.kie.workbench.common.stunner.core.graph.content.view.View)22 Edge (org.kie.workbench.common.stunner.core.graph.Edge)12 Node (org.kie.workbench.common.stunner.core.graph.Node)12 Test (org.junit.Test)10 Point2D (org.kie.workbench.common.stunner.core.graph.content.view.Point2D)9 Decision (org.kie.workbench.common.dmn.api.definition.model.Decision)7 List (java.util.List)6 Child (org.kie.workbench.common.stunner.core.graph.content.relationship.Child)6 NodeImpl (org.kie.workbench.common.stunner.core.graph.impl.NodeImpl)5 ArrayList (java.util.ArrayList)4 Optional (java.util.Optional)4 InputData (org.kie.workbench.common.dmn.api.definition.model.InputData)4 Metadata (org.kie.workbench.common.stunner.core.diagram.Metadata)4 Graph (org.kie.workbench.common.stunner.core.graph.Graph)4 HashMap (java.util.HashMap)3 Objects (java.util.Objects)3 Consumer (java.util.function.Consumer)3 Collectors (java.util.stream.Collectors)3