use of org.kie.workbench.common.stunner.core.graph.content.view.Point2D in project kie-wb-common by kiegroup.
the class CanvasLayoutUtilsTest method getNextFromNewTaskWithNonEmptyPositionWithParent.
// TODO (AlessioP & Roger):
@Test
@Ignore
@SuppressWarnings("unchecked")
public void getNextFromNewTaskWithNonEmptyPositionWithParent() {
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(false);
this.graphTestHandlerParent = new TestingGraphMockHandler();
graphInstanceParent = TestingGraphInstanceBuilder.newGraph2(graphTestHandlerParent);
Node newNode = mock(Node.class);
Bounds boundsNewNode = new BoundsImpl(new BoundImpl(100d, 200d), new BoundImpl(300d, 300d));
View viewNewNode = mock(View.class);
when(newNode.getContent()).thenReturn(viewNewNode);
when(viewNewNode.getBounds()).thenReturn(boundsNewNode);
when(canvasHandler.getDiagram().getGraph()).thenReturn(graphInstanceParent.graph);
when(graphBoundsIndexer.getAt(280.0, 100.0, 100.0, 100.0, graphInstanceParent.parentNode)).thenReturn(graphInstanceParent.intermNode);
graphInstanceParent.startNode.getOutEdges().clear();
Point2D next = canvasLayoutUtils.getNext(canvasHandler, graphInstanceParent.startNode, newNode);
Node<View<?>, Edge> intermNode = (Node<View<?>, Edge>) graphInstanceParent.intermNode;
double[] size = GraphUtils.getNodeSize(intermNode.getContent());
assertTrue(next.getX() == CanvasLayoutUtils.getPaddingX());
assertTrue(next.getY() > size[1]);
}
use of org.kie.workbench.common.stunner.core.graph.content.view.Point2D in project kie-wb-common by kiegroup.
the class CanvasLayoutUtilsTest method setup.
@Before
@SuppressWarnings("unchecked")
public void setup() throws Exception {
when(diagram.getMetadata()).thenReturn(metadata);
when(canvasHandler.getDiagram()).thenReturn(diagram);
when(canvasHandler.getDiagram().getGraph()).thenReturn(graph);
when(canvasHandler.getDiagram().getGraph().getNode("canvas_root")).thenReturn(nodeRoot);
when(graph.getContent()).thenReturn(definitionSet);
when(graph.getContent().getBounds()).thenReturn(canvasBounds);
when(canvasHandler.getDiagram().getGraph().getNode("canvas_root")).thenReturn(nodeRoot);
when(parentCanvasRoot.getUUID()).thenReturn("canvas_root");
when(parentNotCanvasRoot.getUUID()).thenReturn("canvas_not_root");
when(canvasBounds.getUpperLeft()).thenReturn(minCanvasBound);
when(canvasBounds.getLowerRight()).thenReturn(maxCanvasBound);
when(canvasHandler.getCanvas()).thenReturn(canvas);
Point2D canvasMin = new Point2D(0d, 0d);
when(minCanvasBound.getX()).thenReturn(canvasMin.getX());
when(minCanvasBound.getY()).thenReturn(canvasMin.getY());
Point2D canvasMax = new Point2D(1200d, 1200d);
when(maxCanvasBound.getX()).thenReturn(canvasMax.getX());
when(maxCanvasBound.getY()).thenReturn(canvasMax.getY());
when(canvasHandler.getCanvas().getHeight()).thenReturn((int) canvasMax.getY());
when(canvasHandler.getCanvas().getWidth()).thenReturn((int) canvasMax.getX());
canvasLayoutUtils = new CanvasLayoutUtils(graphBoundsIndexer, ruleManager, definitionManager);
when(metadata.getDefinitionSetId()).thenReturn("definitionSetId");
when(definitionManager.definitionSets()).thenReturn(typeDefinitionSetRegistry);
when(typeDefinitionSetRegistry.getDefinitionSetById(eq("definitionSetId"))).thenReturn(defSet);
when(definitionManager.adapters()).thenReturn(adapterManager);
when(adapterManager.forRules()).thenReturn(definitionSetRuleAdapter);
when(definitionSetRuleAdapter.getRuleSet(defSet)).thenReturn(ruleSet);
}
use of org.kie.workbench.common.stunner.core.graph.content.view.Point2D 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.Point2D 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.Point2D in project kie-wb-common by kiegroup.
the class CanvasDefinitionTooltipTest method testSetCanvasLocation.
@Test
public void testSetCanvasLocation() {
final Point2D point = new Point2D(22, 66);
tested.setCanvasLocation(point);
verify(textTooltip, times(1)).setCanvasLocation(eq(point));
}
Aggregations