Search in sources :

Example 11 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 DMNDiagramElementsUtils method generateDRGElement.

private JSIDMNDiagram generateDRGElement(final JSITDefinitions dmnDefinitions) {
    final JSIDMNDiagram drg = DRGDiagramUtils.newJSIDRGInstance();
    final double[] globalOriginX = { 0 };
    forEach(getDmnDiagram(dmnDefinitions), dmnDiagram -> {
        final List<JSIDiagramElement> elements = dmnDiagram.getDMNDiagramElement();
        final double[] diagramOriginX = { globalOriginX[0] };
        forEach(elements, element -> {
            final JSIDiagramElement copy = Js.uncheckedCast(jsCopy(element));
            if (JSIDMNShape.instanceOf(copy)) {
                final JSIDMNShape shape = Js.uncheckedCast(copy);
                final JSIBounds bounds = shape.getBounds();
                final double currentMax = bounds.getX() + bounds.getWidth();
                shape.setId(uniqueId());
                bounds.setX(diagramOriginX[0] + bounds.getX());
                if (currentMax > globalOriginX[0]) {
                    globalOriginX[0] = currentMax;
                }
            }
            if (JSIDMNEdge.instanceOf(copy)) {
                final JSIDMNEdge shape = Js.uncheckedCast(copy);
                shape.setId(uniqueId());
                shape.setOtherAttributes(null);
                forEach(shape.getWaypoint(), jsiPoint -> jsiPoint.setX(diagramOriginX[0] + jsiPoint.getX()));
            }
            drg.addDMNDiagramElement(Js.uncheckedCast(JsUtils.getWrappedElement(copy)));
        });
    });
    return drg;
}
Also used : JSIDMNDiagram(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmndi12.JSIDMNDiagram) JSIDiagramElement(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.di.JSIDiagramElement) 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) JSIDMNEdge(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmndi12.JSIDMNEdge)

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