use of org.kie.workbench.common.stunner.core.graph.content.view.View in project kie-wb-common by kiegroup.
the class CanvasLayoutUtilsTest method getNextFromRootWithParent.
@Test
@SuppressWarnings("unchecked")
public void getNextFromRootWithParent() {
this.graphTestHandlerParent = new TestingGraphMockHandler();
graphInstanceParent = TestingGraphInstanceBuilder.newGraph2(graphTestHandlerParent);
Node node = mock(Node.class);
Bounds boundsNode = new BoundsImpl(new BoundImpl(100d, 100d), new BoundImpl(300d, 200d));
View viewNode = mock(View.class);
when(node.getContent()).thenReturn(viewNode);
when(viewNode.getBounds()).thenReturn(boundsNode);
when(canvasHandler.getDiagram().getGraph()).thenReturn(graphInstanceParent.graph);
Point2D next = canvasLayoutUtils.getNext(canvasHandler, graphInstanceParent.startNode, node);
Node<View<?>, Edge> start = (Node<View<?>, Edge>) graphInstanceParent.startNode;
double[] size = GraphUtils.getNodeSize(start.getContent());
assertTrue(next.getX() == CanvasLayoutUtils.getPaddingX());
assertTrue(next.getY() > size[1]);
}
use of org.kie.workbench.common.stunner.core.graph.content.view.View in project kie-wb-common by kiegroup.
the class CanvasLayoutUtilsTest method getNextNewTaskWithNonEmptyPosition.
// TODO (AlessioP & Roger):
@Test
@Ignore
@SuppressWarnings("unchecked")
public void getNextNewTaskWithNonEmptyPosition() {
when(ruleManager.evaluate(eq(ruleSet), any(RuleEvaluationContext.class))).thenReturn(ruleViolations);
when(ruleViolations.violations(Violation.Type.ERROR)).thenReturn(ruleViolationIterable);
when(ruleViolations.violations(Violation.Type.ERROR).iterator()).thenReturn(ruleViolationIterator);
when(ruleViolations.violations(Violation.Type.ERROR).iterator().hasNext()).thenReturn(true);
this.graphTestHandler = new TestingGraphMockHandler();
graphInstance = TestingGraphInstanceBuilder.newGraph1(graphTestHandler);
Node newNode = mock(Node.class);
Bounds boundsNewNode = new BoundsImpl(new BoundImpl(200d, 300d), new BoundImpl(300d, 400d));
View viewNewNode = mock(View.class);
when(newNode.getContent()).thenReturn(viewNewNode);
when(viewNewNode.getBounds()).thenReturn(boundsNewNode);
when(canvasHandler.getDiagram().getGraph()).thenReturn(graphInstance.graph);
when(graphBoundsIndexer.getAt(140.0, 0.0, 100.0, 100.0, null)).thenReturn(graphInstance.intermNode);
graphInstance.startNode.getOutEdges().clear();
Point2D next = canvasLayoutUtils.getNext(canvasHandler, graphInstance.startNode, newNode);
Node<View<?>, Edge> startNode = (Node<View<?>, Edge>) graphInstance.startNode;
double[] sizeStartNode = GraphUtils.getNodeSize(startNode.getContent());
Node<View<?>, Edge> intermNode = (Node<View<?>, Edge>) graphInstance.intermNode;
double[] sizeIntermNode = GraphUtils.getNodeSize(intermNode.getContent());
assertTrue(next.getX() == sizeStartNode[0] + CanvasLayoutUtils.getPaddingX());
assertTrue(next.getY() > sizeIntermNode[1]);
}
use of org.kie.workbench.common.stunner.core.graph.content.view.View in project kie-wb-common by kiegroup.
the class GraphBoundsIndexerImplTest method testGetAreaAt.
@Test
public void testGetAreaAt() {
Point2D position = GraphUtils.getPosition((View) graphInstanceParent.startNode.getContent());
double[] size = GraphUtils.getNodeSize((View) graphInstanceParent.startNode.getContent());
double getAtX = position.getX() + (size[0] / 2);
double getAtY = position.getY() + (size[1] / 2);
Node<View<?>, Edge> node = graphBoundsIndexerImpl.getAt(getAtX, getAtY, size[0], size[1], graphInstanceParent.parentNode);
assertNotNull(node);
Node<View<?>, Edge> nodeFreePosition = graphBoundsIndexerImpl.getAt(getAtX, getAtY + 400, size[0], size[1], graphInstanceParent.parentNode);
assertNull(nodeFreePosition);
}
use of org.kie.workbench.common.stunner.core.graph.content.view.View in project kie-wb-common by kiegroup.
the class GraphBoundsIndexerImplTest method testGetAreaAtWithParent.
@Test
public void testGetAreaAtWithParent() {
Point2D position = GraphUtils.getPosition((View) graphInstanceParent.startNode.getContent());
double[] size = GraphUtils.getNodeSize((View) graphInstanceParent.startNode.getContent());
double getAtX = position.getX() + (size[0] / 2);
double getAtY = position.getY() + (size[1] / 2);
Node<View<?>, Edge> node = graphBoundsIndexerImpl.getAt(getAtX, getAtY, size[0], size[1], graphInstanceParent.parentNode);
assertNotNull(node);
Node<View<?>, Edge> nodeAtFreePosition = graphBoundsIndexerImpl.getAt(getAtX, getAtY + 200, size[0], size[1], graphInstanceParent.parentNode);
assertNull(nodeAtFreePosition);
}
use of org.kie.workbench.common.stunner.core.graph.content.view.View in project kie-wb-common by kiegroup.
the class AbstractGraphRuleHandlerTest method mockNode.
@SuppressWarnings("unchecked")
protected Node mockNode(String id, Set<String> labels) {
Node e = mock(Node.class);
View v = mock(View.class);
Object d = mock(Object.class);
when(e.getContent()).thenReturn(v);
when(v.getDefinition()).thenReturn(d);
when(definitionAdapter.getId(eq(d))).thenReturn(id);
when(definitionAdapter.getLabels(eq(d))).thenReturn(labels);
when(e.getLabels()).thenReturn(labels);
return e;
}
Aggregations