Search in sources :

Example 1 with JSIDMNShape

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

the class NodeConnectorTest method createNodeEntryWithBounds.

NodeEntry createNodeEntryWithBounds(final double x, final double y, final double width, final double height) {
    final NodeEntry nodeEntry = mock(NodeEntry.class);
    final JSIDMNShape shape = mock(JSIDMNShape.class);
    final JSIBounds bounds = mock(JSIBounds.class);
    when(bounds.getHeight()).thenReturn(height);
    when(bounds.getWidth()).thenReturn(width);
    when(bounds.getX()).thenReturn(x);
    when(bounds.getY()).thenReturn(y);
    when(nodeEntry.getDmnShape()).thenReturn(shape);
    when(shape.getBounds()).thenReturn(bounds);
    return nodeEntry;
}
Also used : JSIBounds(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dc.JSIBounds) JSIDMNShape(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmndi12.JSIDMNShape)

Example 2 with JSIDMNShape

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

the class StunnerConverterTest method testDecision.

@Test
public void testDecision() {
    final StylingSet decisionStylingSet = mock(StylingSet.class);
    final Decision decision = spy(new Decision());
    when(decision.getStylingSet()).thenReturn(decisionStylingSet);
    final JSITDecision jsitDecision = mock(JSITDecision.class);
    when(jsitDecision.getTYPE_NAME()).thenReturn(JSITDecision.TYPE);
    final JSIStyle style = mock(JSIStyle.class);
    final JSIDMNShape shape = mock(JSIDMNShape.class);
    final JSIDMNStyle dmnStyleOfDrgShape = mock(JSIDMNStyle.class);
    when(shape.getStyle()).thenReturn(style);
    doReturn(style).when(converter).getUnwrappedJSIStyle(style);
    doReturn(true).when(converter).isJSIDMNStyle(style);
    doReturn(dmnStyleOfDrgShape).when(converter).getJSIDmnStyle(style);
    final NodeEntry nodeEntry = mock(NodeEntry.class);
    when(nodeEntry.getDmnElement()).thenReturn(jsitDecision);
    when(nodeEntry.getId()).thenReturn("_id");
    when(nodeEntry.getDmnShape()).thenReturn(shape);
    final Element graphElement = mock(Element.class);
    final Node graphNode = mock(Node.class);
    final View content = mock(View.class);
    when(factoryManager.newElement(anyString(), anyString())).thenReturn(graphElement);
    when(graphElement.asNode()).thenReturn(graphNode);
    when(graphNode.getContent()).thenReturn(content);
    when(content.getDefinition()).thenReturn(decision);
    final JSIColor randomColor = mock(JSIColor.class);
    when(randomColor.getRed()).thenReturn(12);
    when(randomColor.getGreen()).thenReturn(34);
    when(randomColor.getBlue()).thenReturn(56);
    when(dmnStyleOfDrgShape.getFontColor()).thenReturn(randomColor);
    when(dmnStyleOfDrgShape.getStrokeColor()).thenReturn(randomColor);
    when(dmnStyleOfDrgShape.getFillColor()).thenReturn(randomColor);
    when(dmnStyleOfDrgShape.getFontSize()).thenReturn(11d);
    converter.make(nodeEntry);
    verify(decisionStylingSet).setFontSize(fontSizeArgumentCaptor.capture());
    Assertions.assertThat(fontSizeArgumentCaptor.getValue().getValue()).isEqualTo(11d);
    verify(decisionStylingSet).setBorderColour(borderColourArgumentCaptor.capture());
    Assertions.assertThat(borderColourArgumentCaptor.getValue().getValue()).isEqualTo("#0c2238");
    verify(decisionStylingSet).setBgColour(bgColourArgumentCaptor.capture());
    Assertions.assertThat(bgColourArgumentCaptor.getValue().getValue()).isEqualTo("#0c2238");
    verify(decisionStylingSet).setFontColour(fontColourArgumentCaptor.capture());
    Assertions.assertThat(fontColourArgumentCaptor.getValue().getValue()).isEqualTo("#0c2238");
}
Also used : JSIColor(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dc.JSIColor) JSIStyle(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.di.JSIStyle) JSIDMNShape(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmndi12.JSIDMNShape) Element(org.kie.workbench.common.stunner.core.graph.Element) Node(org.kie.workbench.common.stunner.core.graph.Node) StylingSet(org.kie.workbench.common.dmn.api.property.styling.StylingSet) JSITDecision(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITDecision) JSIDMNStyle(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmndi12.JSIDMNStyle) View(org.kie.workbench.common.stunner.core.graph.content.view.View) JSITDecision(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITDecision) Decision(org.kie.workbench.common.dmn.api.definition.model.Decision) Test(org.junit.Test)

Example 3 with JSIDMNShape

use of org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmndi12.JSIDMNShape 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 4 with JSIDMNShape

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

the class NodeEntriesBuilder method makeStandardShape.

private JSIDMNShape makeStandardShape() {
    final JSIDMNShape jsidmnShape = new JSIDMNShape();
    final JSIBounds boundsParam = new JSIBounds();
    boundsParam.setX(0);
    boundsParam.setY(0);
    boundsParam.setWidth(100);
    boundsParam.setHeight(50);
    jsidmnShape.setBounds(boundsParam);
    return jsidmnShape;
}
Also used : JSIBounds(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dc.JSIBounds) JSIDMNShape(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmndi12.JSIDMNShape)

Example 5 with JSIDMNShape

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

the class WrapperUtils method getWrappedJSIDMNShape.

public static JSIDMNShape getWrappedJSIDMNShape(final JSIDMNDiagram diagram, final List<String> dmnDiagramElementIds, final Definitions definitionsStunnerPojo, final View<? extends DMNElement> v, final String namespaceURI) {
    final JSIDMNShape unwrappedJSIDMNShape = stunnerToDDExt(diagram, dmnDiagramElementIds, definitionsStunnerPojo, v, namespaceURI);
    final JSIDMNShape toReturn = Js.uncheckedCast(JsUtils.getWrappedElement(unwrappedJSIDMNShape));
    final JSIName jsiName = JSIDMNShape.getJSIName();
    updateJSIName(jsiName, "dmndi", "DMNShape");
    JsUtils.setNameOnWrapped(toReturn, jsiName);
    return toReturn;
}
Also used : JSIName(org.kie.workbench.common.dmn.webapp.kogito.marshaller.mapper.JSIName) JSIDMNShape(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmndi12.JSIDMNShape)

Aggregations

JSIDMNShape (org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmndi12.JSIDMNShape)10 JSIBounds (org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dc.JSIBounds)4 JSIDMNStyle (org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmndi12.JSIDMNStyle)4 Decision (org.kie.workbench.common.dmn.api.definition.model.Decision)3 StylingSet (org.kie.workbench.common.dmn.api.property.styling.StylingSet)3 JSIPoint (org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dc.JSIPoint)3 JSIStyle (org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.di.JSIStyle)3 JSIDMNDecisionServiceDividerLine (org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmndi12.JSIDMNDecisionServiceDividerLine)3 BusinessKnowledgeModel (org.kie.workbench.common.dmn.api.definition.model.BusinessKnowledgeModel)2 DecisionService (org.kie.workbench.common.dmn.api.definition.model.DecisionService)2 InputData (org.kie.workbench.common.dmn.api.definition.model.InputData)2 KnowledgeSource (org.kie.workbench.common.dmn.api.definition.model.KnowledgeSource)2 TextAnnotation (org.kie.workbench.common.dmn.api.definition.model.TextAnnotation)2 Height (org.kie.workbench.common.dmn.api.property.dimensions.Height)2 Width (org.kie.workbench.common.dmn.api.property.dimensions.Width)2 BgColour (org.kie.workbench.common.dmn.api.property.styling.BgColour)2 BorderColour (org.kie.workbench.common.dmn.api.property.styling.BorderColour)2 JSIDiagramElement (org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.di.JSIDiagramElement)2 JSITTextAnnotation (org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITTextAnnotation)2 JSIDMNDiagram (org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmndi12.JSIDMNDiagram)2