Search in sources :

Example 21 with BoundImpl

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

the class CaseManagementCanvasHandlerTest method makeNode.

@SuppressWarnings("unchecked")
private Node<View<BPMNViewDefinition>, Edge> makeNode(final String uuid, final AbstractElementShape shape) {
    final Node<View<BPMNViewDefinition>, Edge> node = new NodeImpl<>(uuid);
    node.setContent(new ViewImpl(shape.getShapeDefinition(), new BoundsImpl(new BoundImpl(0.0, 0.0), new BoundImpl(10.0, 20.0))));
    when(canvas.getShape(eq(uuid))).thenReturn(shape);
    when(clientDefinitionManager.adapters()).thenReturn(adapterManager);
    when(adapterManager.forDefinition()).thenReturn(definitionAdapter);
    when(adapterManager.forProperty()).thenReturn(propertyAdapter);
    when(definitionAdapter.getMetaProperty(eq(PropertyMetaTypes.NAME), anyObject())).thenReturn(PropertyMetaTypes.NAME);
    when(propertyAdapter.getValue(eq(PropertyMetaTypes.NAME))).thenReturn("name");
    return node;
}
Also used : NodeImpl(org.kie.workbench.common.stunner.core.graph.impl.NodeImpl) BoundImpl(org.kie.workbench.common.stunner.core.graph.content.view.BoundImpl) ViewImpl(org.kie.workbench.common.stunner.core.graph.content.view.ViewImpl) BoundsImpl(org.kie.workbench.common.stunner.core.graph.content.view.BoundsImpl) PictureShapeView(org.kie.workbench.common.stunner.shapes.client.view.PictureShapeView) ActivityView(org.kie.workbench.common.stunner.cm.client.shape.view.ActivityView) View(org.kie.workbench.common.stunner.core.graph.content.view.View) Edge(org.kie.workbench.common.stunner.core.graph.Edge)

Example 22 with BoundImpl

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

the class CanvasLayoutUtilsTest method getNextFromRoot.

// TODO (AlessioP & Roger):
@Test
@Ignore
@SuppressWarnings("unchecked")
public void getNextFromRoot() {
    Node node1 = mock(Node.class);
    Bounds boundsNode1 = new BoundsImpl(new BoundImpl(100d, 100d), new BoundImpl(300d, 200d));
    View viewNode1 = mock(View.class);
    when(node1.getContent()).thenReturn(viewNode1);
    when(viewNode1.getBounds()).thenReturn(boundsNode1);
    Node node2 = mock(Node.class);
    Bounds boundsNode2 = new BoundsImpl(new BoundImpl(100d, 100d), new BoundImpl(300d, 200d));
    View viewNode2 = mock(View.class);
    when(node2.getContent()).thenReturn(viewNode2);
    when(viewNode2.getBounds()).thenReturn(boundsNode2);
    Node nodeRoot = mock(Node.class);
    double rootWidth = 40d;
    double rootHeight = 40d;
    Bounds rootBounds = new BoundsImpl(new BoundImpl(0d, 0d), new BoundImpl(rootWidth, rootHeight));
    View rootView = mock(View.class);
    when(nodeRoot.getContent()).thenReturn(rootView);
    when(rootView.getBounds()).thenReturn(rootBounds);
    List<Node> nodes = new ArrayList<>();
    List<Edge> edges = new ArrayList<>();
    Edge edge = mock(Edge.class);
    edges.add(edge);
    when(nodeRoot.getOutEdges()).thenReturn(edges);
    when(edge.getTargetNode()).thenReturn(node1);
    when(nodeRoot.getContent()).thenReturn(rootView);
    nodes.add(nodeRoot);
    when(graph.nodes()).thenReturn(nodes);
    when(node2.getInEdges()).thenReturn(edges);
    when(nodeRoot.asNode()).thenReturn(nodeRoot);
    Point2D next = canvasLayoutUtils.getNext(canvasHandler, nodeRoot, node2);
    assertTrue(next.getX() > rootWidth);
    assertTrue(next.getY() > NEW_NODE_HEIGHT);
}
Also used : Point2D(org.kie.workbench.common.stunner.core.graph.content.view.Point2D) Node(org.kie.workbench.common.stunner.core.graph.Node) Bounds(org.kie.workbench.common.stunner.core.graph.content.Bounds) BoundImpl(org.kie.workbench.common.stunner.core.graph.content.view.BoundImpl) ArrayList(java.util.ArrayList) BoundsImpl(org.kie.workbench.common.stunner.core.graph.content.view.BoundsImpl) View(org.kie.workbench.common.stunner.core.graph.content.view.View) Edge(org.kie.workbench.common.stunner.core.graph.Edge) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 23 with BoundImpl

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

the class CanvasLayoutUtilsTest method getNextOutOfCanvas.

// TODO (AlessioP & Roger):
@Test
@Ignore
@SuppressWarnings("unchecked")
public void getNextOutOfCanvas() {
    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 node = mock(Node.class);
    Bounds boundsNode = new BoundsImpl(new BoundImpl(100d, 0d), new BoundImpl(300d, 1400d));
    View viewNode = mock(View.class);
    when(node.getContent()).thenReturn(viewNode);
    when(viewNode.getBounds()).thenReturn(boundsNode);
    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(graphInstance.graph);
    when(graphBoundsIndexer.getAt(140.0, 0.0, 200.0, 100.0, null)).thenReturn(node);
    graphInstance.startNode.getOutEdges().clear();
    Point2D next = canvasLayoutUtils.getNext(canvasHandler, graphInstance.startNode, newNode);
    Node<View<?>, Edge> intermNode = (Node<View<?>, Edge>) graphInstance.intermNode;
    double[] size = GraphUtils.getNodeSize(intermNode.getContent());
    assertTrue(next.getX() > size[0]);
    assertTrue(next.getY() == CanvasLayoutUtils.getPaddingY());
}
Also used : Point2D(org.kie.workbench.common.stunner.core.graph.content.view.Point2D) Node(org.kie.workbench.common.stunner.core.graph.Node) Bounds(org.kie.workbench.common.stunner.core.graph.content.Bounds) BoundImpl(org.kie.workbench.common.stunner.core.graph.content.view.BoundImpl) RuleEvaluationContext(org.kie.workbench.common.stunner.core.rule.RuleEvaluationContext) TestingGraphMockHandler(org.kie.workbench.common.stunner.core.TestingGraphMockHandler) BoundsImpl(org.kie.workbench.common.stunner.core.graph.content.view.BoundsImpl) View(org.kie.workbench.common.stunner.core.graph.content.view.View) Edge(org.kie.workbench.common.stunner.core.graph.Edge) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 24 with BoundImpl

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

the class PasteSelectionSessionCommandTest method setUp.

@Before
@SuppressWarnings("unchecked")
public void setUp() throws Exception {
    clipboardControl = spy(new LocalClipboardControl());
    TestingGraphMockHandler graphMockHandler = new TestingGraphMockHandler();
    this.graphInstance = TestingGraphInstanceBuilder.newGraph2(graphMockHandler);
    node = graphInstance.startNode;
    node.setContent(view);
    node2 = graphInstance.intermNode;
    node2.setContent(view);
    when(session.getCanvasHandler()).thenReturn(canvasHandler);
    when(canvasHandler.getGraphIndex()).thenReturn(graphMockHandler.graphIndex);
    when(view.getBounds()).thenReturn(new BoundsImpl(new BoundImpl(X, Y), new BoundImpl(X + NODE_SIZE, Y + NODE_SIZE)));
    when(canvasHandler.getDiagram()).thenReturn(diagram);
    when(diagram.getMetadata()).thenReturn(metadata);
    when(metadata.getCanvasRootUUID()).thenReturn(CANVAS_UUID);
    when(sessionCommandManager.execute(eq(canvasHandler), any())).thenReturn(commandResult);
    when(sessionCommandManager.execute(canvasHandler, cloneConnectorCommand)).thenReturn(commandResultConnector);
    when(commandResult.getType()).thenReturn(CommandResult.Type.INFO);
    when(commandResultConnector.getType()).thenReturn(CommandResult.Type.INFO);
    when(clone.getUUID()).thenReturn(CLONE_UUID);
    when(clone2.getUUID()).thenReturn(CLONE2_UUID);
    when(session.getClipboardControl()).thenReturn(clipboardControl);
    when(sessionCommandFactory.newCopySelectionCommand()).thenReturn(copySelectionSessionCommand);
    when(sessionCommandManager.getRegistry()).thenReturn(commandRegistry);
    cloneMap = new HashMap() {

        {
            put(node, clone);
            put(node2, clone2);
        }
    };
    super.setup();
    this.pasteSelectionSessionCommand = getCommand();
}
Also used : HashMap(java.util.HashMap) BoundImpl(org.kie.workbench.common.stunner.core.graph.content.view.BoundImpl) TestingGraphMockHandler(org.kie.workbench.common.stunner.core.TestingGraphMockHandler) BoundsImpl(org.kie.workbench.common.stunner.core.graph.content.view.BoundsImpl) LocalClipboardControl(org.kie.workbench.common.stunner.core.client.canvas.controls.clipboard.LocalClipboardControl) Before(org.junit.Before)

Example 25 with BoundImpl

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

the class ConnectorShapeTest method testApplyConnections.

@Test
@SuppressWarnings("unchecked")
public void testApplyConnections() {
    final Object def = mock(Object.class);
    final Edge<ViewConnector<Object>, Node> edge = new EdgeImpl<>("uuid1");
    final ViewConnectorImpl<Object> content = new ViewConnectorImpl<>(def, new BoundsImpl(new BoundImpl(0d, 0d), new BoundImpl(15d, 40d)));
    Connection sourceConnection = mock(Connection.class);
    Connection targetConnection = mock(Connection.class);
    content.setSourceConnection(sourceConnection);
    content.setTargetConnection(targetConnection);
    edge.setContent(content);
    final ShapeView<?> source = mock(ShapeView.class);
    final ShapeView<?> target = mock(ShapeView.class);
    tested.applyConnections(edge, source, target, MutationContext.STATIC);
    verify(((IsConnector) shapeView), times(1)).connect(eq(source), eq(sourceConnection), eq(target), eq(targetConnection));
}
Also used : ViewConnector(org.kie.workbench.common.stunner.core.graph.content.view.ViewConnector) ViewConnectorImpl(org.kie.workbench.common.stunner.core.graph.content.view.ViewConnectorImpl) Node(org.kie.workbench.common.stunner.core.graph.Node) BoundImpl(org.kie.workbench.common.stunner.core.graph.content.view.BoundImpl) EdgeImpl(org.kie.workbench.common.stunner.core.graph.impl.EdgeImpl) Connection(org.kie.workbench.common.stunner.core.graph.content.view.Connection) BoundsImpl(org.kie.workbench.common.stunner.core.graph.content.view.BoundsImpl) Test(org.junit.Test)

Aggregations

BoundImpl (org.kie.workbench.common.stunner.core.graph.content.view.BoundImpl)30 BoundsImpl (org.kie.workbench.common.stunner.core.graph.content.view.BoundsImpl)28 Edge (org.kie.workbench.common.stunner.core.graph.Edge)13 Bounds (org.kie.workbench.common.stunner.core.graph.content.Bounds)12 View (org.kie.workbench.common.stunner.core.graph.content.view.View)12 Node (org.kie.workbench.common.stunner.core.graph.Node)11 Test (org.junit.Test)10 Point2D (org.kie.workbench.common.stunner.core.graph.content.view.Point2D)9 Before (org.junit.Before)8 TestingGraphMockHandler (org.kie.workbench.common.stunner.core.TestingGraphMockHandler)6 ViewImpl (org.kie.workbench.common.stunner.core.graph.content.view.ViewImpl)6 Ignore (org.junit.Ignore)4 NodeImpl (org.kie.workbench.common.stunner.core.graph.impl.NodeImpl)4 Consumer (java.util.function.Consumer)3 BusinessKnowledgeModel (org.kie.workbench.common.dmn.api.definition.v1_1.BusinessKnowledgeModel)3 Decision (org.kie.workbench.common.dmn.api.definition.v1_1.Decision)3 Command (org.kie.workbench.common.stunner.core.command.Command)3 HashMap (java.util.HashMap)2 AbstractCanvasHandler (org.kie.workbench.common.stunner.core.client.canvas.AbstractCanvasHandler)2 UpdateElementPositionCommand (org.kie.workbench.common.stunner.core.client.canvas.command.UpdateElementPositionCommand)2