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);
}
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;
}
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);
}
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;
}
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));
}
}
Aggregations