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