use of org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dc.JSIBounds in project kie-wb-common by kiegroup.
the class WrapperUtils method stunnerToDDExt.
private static JSIDMNShape stunnerToDDExt(final JSIDMNDiagram diagram, final List<String> dmnDiagramElementIds, final Definitions definitionsStunnerPojo, final View<? extends DMNElement> v, final String namespaceURI) {
final JSIDMNShape result = new JSIDMNShape();
final DMNElement definition = v.getDefinition();
final String dmnElementId = definition.getId().getValue();
final String shapeId = getShapeId(diagram, dmnDiagramElementIds, dmnElementId);
result.setId(shapeId);
result.setDmnElementRef(getDmnElementRef(definitionsStunnerPojo, v, namespaceURI));
final JSIBounds bounds = new JSIBounds();
result.setBounds(bounds);
bounds.setX(xOfBound(upperLeftBound(v)));
bounds.setY(yOfBound(upperLeftBound(v)));
result.setDMNLabel(new JSIDMNLabel());
// TODO {gcardosi}: HARDCODED
result.setIsCollapsed(false);
final JSIDMNStyle style = new JSIDMNStyle();
if (v.getDefinition() instanceof Decision) {
final Decision d = (Decision) v.getDefinition();
applyBounds(d.getDimensionsSet(), bounds);
applyStylingStyles(d.getStylingSet(), style);
} else if (v.getDefinition() instanceof InputData) {
InputData d = (InputData) v.getDefinition();
applyBounds(d.getDimensionsSet(), bounds);
applyStylingStyles(d.getStylingSet(), style);
} else if (v.getDefinition() instanceof BusinessKnowledgeModel) {
final BusinessKnowledgeModel d = (BusinessKnowledgeModel) v.getDefinition();
applyBounds(d.getDimensionsSet(), bounds);
applyStylingStyles(d.getStylingSet(), style);
} else if (v.getDefinition() instanceof KnowledgeSource) {
final KnowledgeSource d = (KnowledgeSource) v.getDefinition();
applyBounds(d.getDimensionsSet(), bounds);
applyStylingStyles(d.getStylingSet(), style);
} else if (v.getDefinition() instanceof TextAnnotation) {
final TextAnnotation d = (TextAnnotation) v.getDefinition();
applyBounds(d.getDimensionsSet(), bounds);
applyStylingStyles(d.getStylingSet(), style);
} else if (v.getDefinition() instanceof DecisionService) {
final DecisionService d = (DecisionService) v.getDefinition();
applyBounds(d.getDimensionsSet(), bounds);
applyStylingStyles(d.getStylingSet(), style);
final JSIDMNDecisionServiceDividerLine dl = new JSIDMNDecisionServiceDividerLine();
final JSIPoint leftPoint = new JSIPoint();
leftPoint.setX(v.getBounds().getUpperLeft().getX());
final double dlY = v.getBounds().getUpperLeft().getY() + d.getDividerLineY().getValue();
leftPoint.setY(dlY);
dl.addWaypoint(leftPoint);
final JSIPoint rightPoint = new JSIPoint();
rightPoint.setX(v.getBounds().getLowerRight().getX());
rightPoint.setY(dlY);
dl.addWaypoint(rightPoint);
result.setDMNDecisionServiceDividerLine(dl);
}
result.setStyle(getWrappedJSIDMNStyle(style));
return result;
}
use of org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dc.JSIBounds 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