Search in sources :

Example 71 with Bounds

use of org.kie.workbench.common.stunner.core.graph.content.Bounds in project kie-wb-common by kiegroup.

the class UpdateElementPositionCommandTest method testExecuteDockedNode.

@Test
@SuppressWarnings("unchecked")
public void testExecuteDockedNode() {
    ArgumentCaptor<Bounds> boundsArgumentCaptor = ArgumentCaptor.forClass(Bounds.class);
    this.tested = new UpdateElementPositionCommand(dockedNode, new Point2D(600d, 600d));
    final CommandResult<RuleViolation> result = tested.execute(graphCommandExecutionContext);
    verify((View) dockedNode.getContent(), times(1)).setBounds(boundsArgumentCaptor.capture());
    assertEquals(CommandResult.Type.INFO, result.getType());
    Bounds bounds = boundsArgumentCaptor.getValue();
    assertEquals(bounds.getUpperLeft(), Bound.create(600d, 600d));
    assertEquals(bounds.getLowerRight(), Bound.create(650d, 650d));
}
Also used : Point2D(org.kie.workbench.common.stunner.core.graph.content.view.Point2D) Bounds(org.kie.workbench.common.stunner.core.graph.content.Bounds) RuleViolation(org.kie.workbench.common.stunner.core.rule.RuleViolation) View(org.kie.workbench.common.stunner.core.graph.content.view.View) Test(org.junit.Test)

Example 72 with Bounds

use of org.kie.workbench.common.stunner.core.graph.content.Bounds in project kie-wb-common by kiegroup.

the class MagnetConnectionTest method testForTargetAtRight.

@Test
@SuppressWarnings("unchecked")
public void testForTargetAtRight() {
    Bounds bounds2 = Bounds.create(120d, 30d, 200d, 300d);
    when(element2.getContent()).thenReturn(content2);
    when(content2.getBounds()).thenReturn(bounds2);
    MagnetConnection m1 = MagnetConnection.Builder.forTarget(element, element2);
    assertEquals(Point2D.create(90, 90), m1.getLocation());
    assertEquals(MagnetConnection.MAGNET_RIGHT, m1.getMagnetIndex().getAsInt());
    assertTrue(m1.isAuto());
}
Also used : Bounds(org.kie.workbench.common.stunner.core.graph.content.Bounds) Test(org.junit.Test)

Example 73 with Bounds

use of org.kie.workbench.common.stunner.core.graph.content.Bounds in project kie-wb-common by kiegroup.

the class MagnetConnectionTest method testForTargetAtLeft.

@Test
@SuppressWarnings("unchecked")
public void testForTargetAtLeft() {
    Bounds bounds2 = Bounds.create(-40d, 10d, 0d, 300d);
    when(element2.getContent()).thenReturn(content2);
    when(content2.getBounds()).thenReturn(bounds2);
    MagnetConnection m1 = MagnetConnection.Builder.forTarget(element, element2);
    assertEquals(Point2D.create(0, 90), m1.getLocation());
    assertEquals(MagnetConnection.MAGNET_LEFT, m1.getMagnetIndex().getAsInt());
    assertTrue(m1.isAuto());
}
Also used : Bounds(org.kie.workbench.common.stunner.core.graph.content.Bounds) Test(org.junit.Test)

Example 74 with Bounds

use of org.kie.workbench.common.stunner.core.graph.content.Bounds in project kie-wb-common by kiegroup.

the class SugiyamaLayoutServiceTest method testGetWidth.

@Test
public void testGetWidth() {
    final Node n = mock(Node.class);
    final HasBounds hasBounds = mock(HasBounds.class);
    final Bounds bounds = mock(Bounds.class);
    final double width = 17;
    final int expected = (int) width;
    when(bounds.getWidth()).thenReturn(width);
    when(hasBounds.getBounds()).thenReturn(bounds);
    when(n.getContent()).thenReturn(hasBounds);
    int actual = layoutService.getWidth(n);
    assertEquals(expected, actual);
}
Also used : Node(org.kie.workbench.common.stunner.core.graph.Node) HasBounds(org.kie.workbench.common.stunner.core.graph.content.HasBounds) Bounds(org.kie.workbench.common.stunner.core.graph.content.Bounds) HasBounds(org.kie.workbench.common.stunner.core.graph.content.HasBounds) Test(org.junit.Test)

Example 75 with Bounds

use of org.kie.workbench.common.stunner.core.graph.content.Bounds in project kie-wb-common by kiegroup.

the class CloneNodeCommandTest method testCloneNodeContentWithProperties.

@Test
public void testCloneNodeContentWithProperties() {
    final View cloneContent = mock(View.class);
    final DefinitionManager definitionManager = mock(DefinitionManager.class);
    final CloneManager cloneManager = mock(CloneManager.class);
    final Object clonedDefinition = mock(Object.class);
    cloneNodeCommand.setClone(clone);
    when(clone.getContent()).thenReturn(cloneContent);
    when(graphCommandExecutionContext.getDefinitionManager()).thenReturn(definitionManager);
    when(definitionManager.cloneManager()).thenReturn(cloneManager);
    when(cloneManager.clone(candidateContent.getDefinition(), ClonePolicy.ALL)).thenReturn(clonedDefinition);
    cloneNodeCommand.cloneNodeContentWithProperties(graphCommandExecutionContext);
    verify(cloneContent).setBounds(boundsArgumentCaptor.capture());
    verify(cloneContent).setDefinition(clonedDefinition);
    final Bounds clonedBounds = boundsArgumentCaptor.getValue();
    assertEquals(candidateBounds, clonedBounds);
    assertNotSame(candidateBounds, clonedBounds);
}
Also used : CloneManager(org.kie.workbench.common.stunner.core.definition.clone.CloneManager) DefinitionManager(org.kie.workbench.common.stunner.core.api.DefinitionManager) Bounds(org.kie.workbench.common.stunner.core.graph.content.Bounds) View(org.kie.workbench.common.stunner.core.graph.content.view.View) Test(org.junit.Test)

Aggregations

Bounds (org.kie.workbench.common.stunner.core.graph.content.Bounds)95 Test (org.junit.Test)42 View (org.kie.workbench.common.stunner.core.graph.content.view.View)34 Bound (org.kie.workbench.common.stunner.core.graph.content.Bound)26 Node (org.kie.workbench.common.stunner.core.graph.Node)24 Edge (org.kie.workbench.common.stunner.core.graph.Edge)20 Point2D (org.kie.workbench.common.stunner.core.graph.content.view.Point2D)20 Graph (org.kie.workbench.common.stunner.core.graph.Graph)9 ArrayList (java.util.ArrayList)8 Metadata (org.kie.workbench.common.stunner.core.diagram.Metadata)7 HasBounds (org.kie.workbench.common.stunner.core.graph.content.HasBounds)7 Connection (org.kie.workbench.common.stunner.core.graph.content.view.Connection)7 Dock (org.kie.workbench.common.stunner.core.graph.content.relationship.Dock)6 NodeImpl (org.kie.workbench.common.stunner.core.graph.impl.NodeImpl)6 Before (org.junit.Before)5 Definition (org.kie.workbench.common.stunner.core.graph.content.definition.Definition)5 ViewImpl (org.kie.workbench.common.stunner.core.graph.content.view.ViewImpl)5 List (java.util.List)4 Ignore (org.junit.Ignore)4 Lane (org.kie.workbench.common.stunner.bpmn.definition.Lane)4