use of org.kie.workbench.common.stunner.core.graph.content.Bounds in project kie-wb-common by kiegroup.
the class BPMNDirectDiagramMarshallerTest method testUnmarshallNotBoundaryEvents.
@Test
@SuppressWarnings("unchecked")
public void testUnmarshallNotBoundaryEvents() throws Exception {
Diagram<Graph, Metadata> diagram = unmarshall(BPMN_NOT_BOUNDARY_EVENTS);
assertEquals("Not Boundary Event", diagram.getMetadata().getTitle());
assertDiagram(diagram, 6);
// Assert than the intermediate event is connected using a view connector,
// so not boundary to the task ( not docked ).
Node event = diagram.getGraph().getNode("_CB178D55-8DC2-4CAA-8C42-4F5028D4A1F6");
List<Edge> inEdges = event.getInEdges();
boolean foundViewConnector = false;
for (Edge e : inEdges) {
if (e.getContent() instanceof ViewConnector) {
foundViewConnector = true;
}
}
assertTrue(foundViewConnector);
// Assert absolute position as the node is not docked.
Bounds bounds = ((View) event.getContent()).getBounds();
Bound ul = bounds.getUpperLeft();
Bound lr = bounds.getLowerRight();
assertEquals(305, ul.getX(), 0);
assertEquals(300, ul.getY(), 0);
assertEquals(361, lr.getX(), 0);
assertEquals(356, lr.getY(), 0);
}
use of org.kie.workbench.common.stunner.core.graph.content.Bounds in project kie-wb-common by kiegroup.
the class BPMNDirectDiagramMarshallerTest method testUnmarshallNestedSubprocesses.
@Test
@SuppressWarnings("unchecked")
public void testUnmarshallNestedSubprocesses() throws Exception {
Diagram<Graph, Metadata> diagram = unmarshall(BPMN_NESTED_SUBPROCESSES);
assertDiagram(diagram, 8);
Bounds event1ExpectedBounds = Bounds.create(84.0, 275.0, 140.0, 331.0);
Node<View<? extends Definition>, ?> event1 = diagram.getGraph().getNode("_46579C86-4ED2-4DDC-BBD0-51AC99034F0A");
assertEquals(event1ExpectedBounds, event1.getContent().getBounds());
Bounds subProcess1ExpectedBounds = Bounds.create(278.0, 68.0, 1443.0, 537.0);
Bounds subProcess2ExpectedBounds = Bounds.create(196.0, 63.0, 1095.0, 428.0);
Bounds task1ExpectedBounds = Bounds.create(25.0, 143.0, 179.0, 245.0);
Node<View<? extends Definition>, ?> subProcess1 = diagram.getGraph().getNode("_3EF003AC-1AB2-416A-83EA-926A3978D6C0");
Node<View<? extends Definition>, ?> task1 = diagram.getGraph().getNode("_529CFC51-DEAE-4E40-8404-BEAABC043171");
Node<View<? extends Definition>, ?> subProcess2 = diagram.getGraph().getNode("_793D68BA-AC40-4B16-A036-36353F686977");
List subProcess1Children = GraphUtils.getChildNodes(subProcess1);
assertEquals(2, subProcess1Children.size());
assertTrue(subProcess1Children.contains(task1));
assertTrue(subProcess1Children.contains(subProcess2));
assertEquals(subProcess1ExpectedBounds, subProcess1.getContent().getBounds());
assertEquals(subProcess2ExpectedBounds, subProcess2.getContent().getBounds());
assertEquals(task1ExpectedBounds, task1.getContent().getBounds());
Bounds subProcess3ExpectedBounds = Bounds.create(193.0, 46.0, 846.0, 299.0);
Bounds task2ExpectedBounds = Bounds.create(20.0, 80.0, 174.0, 182.0);
Node<View<? extends Definition>, ?> subProcess3 = diagram.getGraph().getNode("_AE368C8F-8BE4-40A5-BC48-5CE5ACF05605");
Node<View<? extends Definition>, ?> task2 = diagram.getGraph().getNode("_2265BA12-91FA-4064-8A7E-C963E15517EB");
List subProcess2Children = GraphUtils.getChildNodes(subProcess2);
assertEquals(2, subProcess2Children.size());
assertTrue(subProcess2Children.contains(task2));
assertTrue(subProcess2Children.contains(subProcess3));
assertEquals(subProcess3ExpectedBounds, subProcess3.getContent().getBounds());
assertEquals(task2ExpectedBounds, task2.getContent().getBounds());
Bounds task3ExpectedBounds = Bounds.create(24.0, 34.0, 178.0, 136.0);
Node<View<? extends Definition>, ?> task3 = diagram.getGraph().getNode("_B7873741-0FFA-4E46-B2E7-3B81D25842B3");
List subProcess3Children = GraphUtils.getChildNodes(subProcess3);
assertEquals(1, subProcess3Children.size());
assertTrue(subProcess3Children.contains(task3));
assertEquals(task3ExpectedBounds, task3.getContent().getBounds());
}
use of org.kie.workbench.common.stunner.core.graph.content.Bounds in project kie-wb-common by kiegroup.
the class BPMNDirectDiagramMarshallerTest method testUnmarshallEvaluation.
@Test
@SuppressWarnings("unchecked")
public void testUnmarshallEvaluation() throws Exception {
Diagram<Graph, Metadata> diagram = unmarshall(BPMN_EVALUATION);
assertDiagram(diagram, 8);
assertEquals("Evaluation", diagram.getMetadata().getTitle());
Node<? extends View, ?> task1 = diagram.getGraph().getNode("_88233779-B395-4B8C-A086-9EF43698426C");
Node<? extends View, ?> task2 = diagram.getGraph().getNode("_AE5BF0DC-B720-4FDE-9499-5ED89D41FB1A");
Node<? extends View, ?> task3 = diagram.getGraph().getNode("_6063D302-9D81-4C86-920B-E808A45377C2");
assertTrue(task1.getContent().getDefinition() instanceof UserTask);
assertTrue(task2.getContent().getDefinition() instanceof UserTask);
assertTrue(task3.getContent().getDefinition() instanceof UserTask);
// Assert bounds.
Bounds task1Bounds = task1.getContent().getBounds();
Bound task1ULBound = task1Bounds.getUpperLeft();
Bound task1LRBound = task1Bounds.getLowerRight();
assertEquals(648d, task1ULBound.getX(), 0);
assertEquals(149d, task1ULBound.getY(), 0);
assertEquals(784d, task1LRBound.getX(), 0);
assertEquals(197d, task1LRBound.getY(), 0);
}
use of org.kie.workbench.common.stunner.core.graph.content.Bounds in project kie-wb-common by kiegroup.
the class FixedBoundsPropertyReadersTest method testBounds.
@Test
public void testBounds() {
org.eclipse.dd.dc.Bounds catchEventShapeBounds = mockBounds(1f, 2f, 123.2f, 322.3f);
when(catchEventShape.getBounds()).thenReturn(catchEventShapeBounds);
org.eclipse.dd.dc.Bounds throwEventShapeBounds = mockBounds(5f, 6f, 2144.67f, 853.34f);
when(throwEventShape.getBounds()).thenReturn(throwEventShapeBounds);
doReturn(Point2D.create(3d, 4d)).when(boundaryEventPropertyReader).getDockerInfo();
org.eclipse.dd.dc.Bounds gatewayEventShapeBounds = mockBounds(7f, 8f, 4543.2f, 25.3f);
when(gatewayEventShape.getBounds()).thenReturn(gatewayEventShapeBounds);
Bounds catchEventBounds = catchEventPropertyReader.getBounds();
Bounds boundaryEventBounds = boundaryEventPropertyReader.getBounds();
Bounds throwEventBounds = throwEventPropertyReader.getBounds();
Bounds gatewayEventBounds = gatewayPropertyReader.getBounds();
assertEquals(Bounds.create(1, 2, 57, 58), catchEventBounds);
assertEquals(Bounds.create(3, 4, 59, 60), boundaryEventBounds);
assertEquals(Bounds.create(5, 6, 61, 62), throwEventBounds);
assertEquals(Bounds.create(7, 8, 63, 64), gatewayEventBounds);
}
use of org.kie.workbench.common.stunner.core.graph.content.Bounds in project kie-wb-common by kiegroup.
the class LanePropertyReaderTest method testGetBounds.
@Test
public void testGetBounds() {
LanePropertyReader propertyReader = new LanePropertyReader(lane, diagram, shape, RESOLUTION_FACTOR);
Bounds result = propertyReader.getBounds();
assertBounds(X * RESOLUTION_FACTOR, Y * RESOLUTION_FACTOR, X * RESOLUTION_FACTOR + WIDTH * RESOLUTION_FACTOR, Y * RESOLUTION_FACTOR + HEIGHT * RESOLUTION_FACTOR, result);
}
Aggregations