use of org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dc.JSIPoint in project kie-wb-common by kiegroup.
the class StunnerConverter method internalAugment.
private void internalAugment(final JSIDMNShape drgShape, final Bound ulBound, final RectangleDimensionsSet dimensionsSet, final Bound lrBound, final StylingSet stylingSet, final Consumer<Double> decisionServiceDividerLineYSetter) {
if (Objects.nonNull(ulBound)) {
ulBound.setX(xOfShape(drgShape));
ulBound.setY(yOfShape(drgShape));
}
dimensionsSet.setWidth(new Width(widthOfShape(drgShape)));
dimensionsSet.setHeight(new Height(heightOfShape(drgShape)));
if (Objects.nonNull(lrBound)) {
lrBound.setX(xOfShape(drgShape) + widthOfShape(drgShape));
lrBound.setY(yOfShape(drgShape) + heightOfShape(drgShape));
}
internalAugmentStyles(drgShape, stylingSet);
if (Objects.nonNull(drgShape.getDMNDecisionServiceDividerLine())) {
final JSIDMNDecisionServiceDividerLine divider = Js.uncheckedCast(drgShape.getDMNDecisionServiceDividerLine());
final List<JSIPoint> dividerPoints = divider.getWaypoint();
final JSIPoint dividerY = Js.uncheckedCast(dividerPoints.get(0));
decisionServiceDividerLineYSetter.accept(dividerY.getY());
}
}
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 testSetConnectionMagnets.
@Test
public void testSetConnectionMagnets() {
Edge edge = mock(Edge.class);
ViewConnector viewConnector = mock(ViewConnector.class);
JSIDMNEdge jsidmnEdge = mock(JSIDMNEdge.class);
Node sourceNode = mock(Node.class);
Node targetNode = mock(Node.class);
View<?> view = mock(View.class);
Bounds bounds = mock(Bounds.class);
JSIPoint start = mock(JSIPoint.class);
JSIPoint waypoint = mock(JSIPoint.class);
JSIPoint end = mock(JSIPoint.class);
List<JSIPoint> waypoints = new ArrayList<>();
waypoints.add(start);
waypoints.add(waypoint);
waypoints.add(end);
NodeConnector nodeConnector = mock(NodeConnector.class);
doCallRealMethod().when(nodeConnector).setConnectionMagnets(eq(edge), eq(viewConnector), eq(jsidmnEdge));
when(jsidmnEdge.getWaypoint()).thenReturn(waypoints);
when(jsidmnEdge.getId()).thenReturn(AUTO_SOURCE_CONNECTION + AUTO_TARGET_CONNECTION);
when(edge.getSourceNode()).thenReturn(sourceNode);
when(edge.getTargetNode()).thenReturn(targetNode);
when(sourceNode.getContent()).thenReturn(view);
when(targetNode.getContent()).thenReturn(view);
when(view.getBounds()).thenReturn(bounds);
when(bounds.getWidth()).thenReturn(0.0);
when(bounds.getHeight()).thenReturn(0.0);
when(start.getX()).thenReturn(0.0);
when(start.getY()).thenReturn(0.0);
when(waypoint.getX()).thenReturn(1.0);
when(waypoint.getY()).thenReturn(1.0);
when(start.getX()).thenReturn(1.0);
when(start.getY()).thenReturn(1.0);
nodeConnector.setConnectionMagnets(edge, viewConnector, jsidmnEdge);
verify(nodeConnector).isSourceAutoConnectionEdge(jsidmnEdge);
verify(nodeConnector).isTargetAutoConnectionEdge(jsidmnEdge);
verify(viewConnector).setControlPoints(any());
}
use of org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dc.JSIPoint in project kie-wb-common by kiegroup.
the class PointUtils method point2dToDMNDIPoint.
public static JSIPoint point2dToDMNDIPoint(final Point2D point2d) {
final JSIPoint result = new JSIPoint();
result.setX(point2d.getX());
result.setY(point2d.getY());
return result;
}
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 getSourceNode.
Optional<Node> getSourceNode(final JSIDMNEdge jsidmnEdge, final List<NodeEntry> entries) {
if (entries.size() == 1) {
return Optional.of(entries.get(0).getNode());
}
final JSIPoint jsiSource = Js.uncheckedCast(jsidmnEdge.getWaypoint().get(0));
final Point2D source = createPoint(jsiSource);
return getNodeFromPoint(source, entries);
}
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 getTargetNode.
Optional<Node> getTargetNode(final JSIDMNEdge jsidmnEdge, final List<NodeEntry> entries) {
if (entries.size() == 1) {
return Optional.of(entries.get(0).getNode());
}
final JSIPoint jsiTarget = Js.uncheckedCast(jsidmnEdge.getWaypoint().get(1));
final Point2D source = createPoint(jsiTarget);
return getNodeFromPoint(source, entries);
}
Aggregations