Search in sources :

Example 6 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 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());
    }
}
Also used : JSIDMNDecisionServiceDividerLine(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmndi12.JSIDMNDecisionServiceDividerLine) JSIPoint(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dc.JSIPoint) Height(org.kie.workbench.common.dmn.api.property.dimensions.Height) Width(org.kie.workbench.common.dmn.api.property.dimensions.Width)

Example 7 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 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());
}
Also used : ViewConnector(org.kie.workbench.common.stunner.core.graph.content.view.ViewConnector) Node(org.kie.workbench.common.stunner.core.graph.Node) JSIBounds(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dc.JSIBounds) Bounds(org.kie.workbench.common.stunner.core.graph.content.Bounds) ArrayList(java.util.ArrayList) 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) Edge(org.kie.workbench.common.stunner.core.graph.Edge) JSIDMNEdge(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmndi12.JSIDMNEdge) Test(org.junit.Test)

Example 8 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 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;
}
Also used : JSIPoint(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dc.JSIPoint)

Example 9 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 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);
}
Also used : Point2D(com.ait.lienzo.client.core.types.Point2D) JSIPoint(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dc.JSIPoint)

Example 10 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 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);
}
Also used : Point2D(com.ait.lienzo.client.core.types.Point2D) JSIPoint(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dc.JSIPoint)

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