Search in sources :

Example 1 with JSIPoint

use of org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dc.JSIPoint in project kie-wb-common by kiegroup.

the class NodeConnectorTest method testGetTargetNode.

@Test
public void testGetTargetNode() {
    final JSIDMNEdge jsiDMNEdge = mock(JSIDMNEdge.class);
    final double targetX = 7.0;
    final double targetY = 8.0;
    final JSIPoint sourcePoint = createPoint(1, 2);
    final JSIPoint targetPoint = createPoint(targetX, targetY);
    final List<JSIPoint> waypoints = Arrays.asList(sourcePoint, targetPoint);
    final List nodeEntries = mock(List.class);
    final Point2D targetPoint2D = new Point2D(targetX, targetY);
    when(jsiDMNEdge.getWaypoint()).thenReturn(waypoints);
    doReturn(Optional.of(mock(Node.class))).when(nodeConnector).getNodeFromPoint(targetPoint2D, nodeEntries);
    nodeConnector.getTargetNode(jsiDMNEdge, nodeEntries);
    verify(nodeConnector).getNodeFromPoint(targetPoint2D, nodeEntries);
}
Also used : Point2D(com.ait.lienzo.client.core.types.Point2D) JSIPoint(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dc.JSIPoint) ArrayList(java.util.ArrayList) Collections.singletonList(java.util.Collections.singletonList) List(java.util.List) JSIDMNEdge(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmndi12.JSIDMNEdge) Test(org.junit.Test)

Example 2 with JSIPoint

use of org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dc.JSIPoint in project kie-wb-common by kiegroup.

the class NodeConnectorTest method createPoint.

private JSIPoint createPoint(final double x, final double y) {
    final JSIPoint point = mock(JSIPoint.class);
    when(point.getX()).thenReturn(x);
    when(point.getY()).thenReturn(y);
    return point;
}
Also used : JSIPoint(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dc.JSIPoint)

Example 3 with JSIPoint

use of org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dc.JSIPoint in project kie-wb-common by kiegroup.

the class NodeConnectorTest method testGetSourceNode.

@Test
public void testGetSourceNode() {
    final JSIDMNEdge jsiDMNEdge = mock(JSIDMNEdge.class);
    final double sourceX = 1.0;
    final double sourceY = 2.0;
    final JSIPoint sourcePoint = createPoint(sourceX, sourceY);
    final JSIPoint targetPoint = createPoint(7, 8);
    final List<JSIPoint> waypoints = Arrays.asList(sourcePoint, targetPoint);
    final List nodeEntries = mock(List.class);
    final Point2D sourcePoint2D = new Point2D(sourceX, sourceY);
    when(jsiDMNEdge.getWaypoint()).thenReturn(waypoints);
    doReturn(Optional.of(mock(Node.class))).when(nodeConnector).getNodeFromPoint(sourcePoint2D, nodeEntries);
    nodeConnector.getSourceNode(jsiDMNEdge, nodeEntries);
    verify(nodeConnector).getNodeFromPoint(sourcePoint2D, nodeEntries);
}
Also used : Point2D(com.ait.lienzo.client.core.types.Point2D) JSIPoint(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dc.JSIPoint) ArrayList(java.util.ArrayList) Collections.singletonList(java.util.Collections.singletonList) List(java.util.List) JSIDMNEdge(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmndi12.JSIDMNEdge) Test(org.junit.Test)

Example 4 with JSIPoint

use of org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dc.JSIPoint in project kie-wb-common by kiegroup.

the class NodeConnector method newEdge.

JSIDMNEdge newEdge(double x, double y) {
    final JSIDMNEdge dmnEdge = new JSIDMNEdge();
    final JSIPoint point = new JSIPoint();
    point.setX(x);
    point.setY(y);
    dmnEdge.addAllWaypoint(point, point);
    return dmnEdge;
}
Also used : JSIPoint(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dc.JSIPoint) JSIDMNEdge(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmndi12.JSIDMNEdge)

Example 5 with JSIPoint

use of org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dc.JSIPoint in project kie-wb-common by kiegroup.

the class NodeConnector method setConnectionMagnets.

void setConnectionMagnets(final Edge edge, final ViewConnector connectionContent, final JSIDMNEdge jsidmnEdge) {
    final JSIDMNEdge e = Js.uncheckedCast(jsidmnEdge);
    final JSIPoint source = Js.uncheckedCast(e.getWaypoint().get(0));
    final Node<View<?>, Edge> sourceNode = edge.getSourceNode();
    if (null != sourceNode) {
        setConnectionMagnet(sourceNode, source, connectionContent::setSourceConnection, isSourceAutoConnectionEdge(jsidmnEdge));
    }
    final JSIPoint target = Js.uncheckedCast(e.getWaypoint().get(e.getWaypoint().size() - 1));
    final Node<View<?>, Edge> targetNode = edge.getTargetNode();
    if (null != targetNode) {
        setConnectionMagnet(targetNode, target, connectionContent::setTargetConnection, isTargetAutoConnectionEdge(jsidmnEdge));
    }
    if (e.getWaypoint().size() > 2) {
        connectionContent.setControlPoints(e.getWaypoint().subList(1, e.getWaypoint().size() - 1).stream().map(p -> ControlPoint.build(PointUtils.dmndiPointToPoint2D(p))).toArray(ControlPoint[]::new));
    }
}
Also used : JSIPoint(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dc.JSIPoint) ControlPoint(org.kie.workbench.common.stunner.core.graph.content.view.ControlPoint) JSIDMNEdge(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmndi12.JSIDMNEdge) View(org.kie.workbench.common.stunner.core.graph.content.view.View) Edge(org.kie.workbench.common.stunner.core.graph.Edge) JSIDMNEdge(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmndi12.JSIDMNEdge)

Aggregations

JSIPoint (org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dc.JSIPoint)11 JSIDMNEdge (org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmndi12.JSIDMNEdge)5 Point2D (com.ait.lienzo.client.core.types.Point2D)4 ArrayList (java.util.ArrayList)3 Test (org.junit.Test)3 Collections.singletonList (java.util.Collections.singletonList)2 List (java.util.List)2 JSIBounds (org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dc.JSIBounds)2 JSIDMNDecisionServiceDividerLine (org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmndi12.JSIDMNDecisionServiceDividerLine)2 Edge (org.kie.workbench.common.stunner.core.graph.Edge)2 BusinessKnowledgeModel (org.kie.workbench.common.dmn.api.definition.model.BusinessKnowledgeModel)1 DMNElement (org.kie.workbench.common.dmn.api.definition.model.DMNElement)1 Decision (org.kie.workbench.common.dmn.api.definition.model.Decision)1 DecisionService (org.kie.workbench.common.dmn.api.definition.model.DecisionService)1 InputData (org.kie.workbench.common.dmn.api.definition.model.InputData)1 KnowledgeSource (org.kie.workbench.common.dmn.api.definition.model.KnowledgeSource)1 TextAnnotation (org.kie.workbench.common.dmn.api.definition.model.TextAnnotation)1 Height (org.kie.workbench.common.dmn.api.property.dimensions.Height)1 Width (org.kie.workbench.common.dmn.api.property.dimensions.Width)1 JSITTextAnnotation (org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITTextAnnotation)1