use of org.kie.workbench.common.stunner.core.graph.content.Bounds in project kie-wb-common by kiegroup.
the class BPMNDiagramMarshallerTest method testUnmarshallBoundaryEvents.
@Test
@SuppressWarnings("unchecked")
public void testUnmarshallBoundaryEvents() throws Exception {
Diagram<Graph, Metadata> diagram = unmarshall(BPMN_BOUNDARY_EVENTS);
// Basic assertions.
assertEquals("Boundary Event", diagram.getMetadata().getTitle());
assertDiagram(diagram, 6);
// Assert than the intermediate event is connected using a dock connector,
// so boundary to the task.
Node event = diagram.getGraph().getNode("_CB178D55-8DC2-4CAA-8C42-4F5028D4A1F6");
List<Edge> inEdges = event.getInEdges();
boolean foundDockConector = false;
for (Edge e : inEdges) {
if (e.getContent() instanceof Dock) {
foundDockConector = true;
}
}
assertTrue(foundDockConector);
// Assert relative position for the docked node.
Bounds bounds = ((View) event.getContent()).getBounds();
Bounds.Bound ul = bounds.getUpperLeft();
Bounds.Bound lr = bounds.getLowerRight();
assertEquals(57, ul.getX(), 0);
assertEquals(70, ul.getY(), 0);
assertEquals(87, lr.getX(), 0);
assertEquals(100, lr.getY(), 0);
}
use of org.kie.workbench.common.stunner.core.graph.content.Bounds in project kie-wb-common by kiegroup.
the class CanvasLayoutUtils method getBoundCoordinates.
private double[] getBoundCoordinates(final View view) {
final Bounds bounds = view.getBounds();
final Bounds.Bound ulBound = bounds.getUpperLeft();
final Bounds.Bound lrBound = bounds.getLowerRight();
final double lrX = lrBound.getX();
final double lrY = ulBound.getY();
return new double[] { lrX, lrY };
}
use of org.kie.workbench.common.stunner.core.graph.content.Bounds in project kie-wb-common by kiegroup.
the class UpdateElementPositionCommand method checkBounds.
@SuppressWarnings("unchecked")
private CommandResult<RuleViolation> checkBounds(final GraphCommandExecutionContext context) {
final Element<? extends View<?>> element = getNodeNotNull(context);
final Graph<DefinitionSet, Node> graph = (Graph<DefinitionSet, Node>) getGraph(context);
final BoundsImpl newBounds = getTargetBounds(element);
final GraphCommandResultBuilder result = new GraphCommandResultBuilder();
final Bounds parentBounds = getParentBounds(element, graph);
if (GraphUtils.checkBoundsExceeded(parentBounds, newBounds)) {
((View) element.getContent()).setBounds(newBounds);
} else {
result.addViolation(new BoundsExceededViolation(parentBounds).setUUID(element.getUUID()));
}
return result.build();
}
use of org.kie.workbench.common.stunner.core.graph.content.Bounds in project kie-wb-common by kiegroup.
the class AbstractGraphCommandTest method init.
@SuppressWarnings("unchecked")
public void init(final double width, final double height) {
MockitoAnnotations.initMocks(this);
Bounds bounds = mockBounds(0, 0, width, height);
when(graphContent.getBounds()).thenReturn(bounds);
when(graph.getUUID()).thenReturn(GRAPH_UUID);
when(graph.getContent()).thenReturn(graphContent);
when(graph.nodes()).thenReturn(graphNodes);
when(definitionManager.adapters()).thenReturn(adapterManager);
when(adapterManager.registry()).thenReturn(adapterRegistry);
when(adapterManager.forDefinition()).thenReturn(definitionAdapter);
when(adapterManager.forProperty()).thenReturn(propertyAdapter);
when(adapterRegistry.getDefinitionAdapter(any(Class.class))).thenReturn(definitionAdapter);
when(adapterRegistry.getPropertyAdapter(any(Class.class))).thenReturn(propertyAdapter);
when(graphCommandExecutionContext.getDefinitionManager()).thenReturn(definitionManager);
when(graphCommandExecutionContext.getFactoryManager()).thenReturn(factoryManager);
when(graphCommandExecutionContext.getRuleManager()).thenReturn(ruleManager);
when(graphCommandExecutionContext.getGraphIndex()).thenReturn(graphIndex);
when(graphCommandExecutionContext.getRuleSet()).thenReturn(ruleSet);
when(graphIndex.getGraph()).thenReturn(graph);
when(ruleManager.evaluate(any(RuleSet.class), any(RuleEvaluationContext.class))).thenReturn(EMPTY_VIOLATIONS);
}
use of org.kie.workbench.common.stunner.core.graph.content.Bounds in project kie-wb-common by kiegroup.
the class DRDContextMenuService method cloneNode.
@SuppressWarnings("unchecked")
private Node cloneNode(final Node nodeToClone, final DMNDiagramElement dmnElement) {
final View content = (View) nodeToClone.getContent();
final Bounds bounds = content.getBounds();
final Object definition = content.getDefinition();
final Node clonedNode = factoryManager.newElement(UUID.uuid(), getDefinitionId(definition.getClass())).asNode();
final View clonedContent = (View) clonedNode.getContent();
clonedContent.setDefinition(cloneDefinition(dmnElement, definition));
clonedContent.setBounds(cloneBounds(bounds));
return clonedNode;
}
Aggregations