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 copy.
private JSIDMNShape copy(final JSIDMNShape shape) {
final JSIDMNShape copy = Js.uncheckedCast(JsInteropUtils.jsCopy(shape));
copy.setId(uniqueId());
return copy;
}
use of org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmndi12.JSIDMNShape in project kie-wb-common by kiegroup.
the class NodeEntriesFactory method getShapesByDiagramId.
private Map<JSIDMNShape, String> getShapesByDiagramId(final JSITDefinitions definitions) {
final Map<JSIDMNShape, String> dmnShapesByDiagramId = new HashMap<>();
final List<JSIDMNDiagram> diagrams = definitions.getDMNDI().getDMNDiagram();
forEach(diagrams, diagram -> {
final String diagramId = diagram.getId();
final List<JSIDiagramElement> diagramElements = diagram.getDMNDiagramElement();
forEach(diagramElements, diagramElement -> {
if (JSIDMNShape.instanceOf(diagramElement)) {
final JSIDMNShape shape = Js.uncheckedCast(diagramElement);
dmnShapesByDiagramId.put(shape, diagramId);
}
});
});
return dmnShapesByDiagramId;
}
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 ddExtAugmentStunner.
private void ddExtAugmentStunner(final Node currentNode, final JSIDMNShape shape) {
final View content = (View) currentNode.getContent();
final Bound ulBound = upperLeftBound(content);
final Bound lrBound = lowerRightBound(content);
final Object definition = content.getDefinition();
if (definition instanceof Decision) {
final Decision decision = (Decision) definition;
internalAugment(shape, ulBound, decision.getDimensionsSet(), lrBound, decision.getStylingSet(), (line) -> {
/*NOP*/
});
} else if (definition instanceof InputData) {
final InputData inputData = (InputData) definition;
internalAugment(shape, ulBound, inputData.getDimensionsSet(), lrBound, inputData.getStylingSet(), (line) -> {
/*NOP*/
});
} else if (definition instanceof BusinessKnowledgeModel) {
final BusinessKnowledgeModel businessKnowledgeModel = (BusinessKnowledgeModel) definition;
internalAugment(shape, ulBound, businessKnowledgeModel.getDimensionsSet(), lrBound, businessKnowledgeModel.getStylingSet(), (line) -> {
/*NOP*/
});
} else if (definition instanceof KnowledgeSource) {
final KnowledgeSource knowledgeSource = (KnowledgeSource) definition;
internalAugment(shape, ulBound, knowledgeSource.getDimensionsSet(), lrBound, knowledgeSource.getStylingSet(), (line) -> {
/*NOP*/
});
} else if (definition instanceof TextAnnotation) {
final TextAnnotation textAnnotation = (TextAnnotation) definition;
internalAugment(shape, ulBound, textAnnotation.getDimensionsSet(), lrBound, textAnnotation.getStylingSet(), (line) -> {
/*NOP*/
});
} else if (definition instanceof DecisionService) {
final DecisionService decisionService = (DecisionService) definition;
internalAugment(shape, ulBound, decisionService.getDimensionsSet(), lrBound, decisionService.getStylingSet(), (dividerLineY) -> decisionService.setDividerLineY(new DecisionServiceDividerLineY(dividerLineY - ulBound.getY())));
}
}
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 internalAugmentStyles.
private void internalAugmentStyles(final JSIDMNShape drgShape, final StylingSet stylingSet) {
final JSIStyle jsiStyle = drgShape.getStyle();
if (Objects.isNull(jsiStyle)) {
return;
}
final JSIStyle drgStyle = getUnwrappedJSIStyle(jsiStyle);
final JSIDMNStyle dmnStyleOfDrgShape = isJSIDMNStyle(drgStyle) ? getJSIDmnStyle(drgStyle) : null;
if (Objects.nonNull(dmnStyleOfDrgShape)) {
if (Objects.nonNull(dmnStyleOfDrgShape.getFillColor())) {
stylingSet.setBgColour(new BgColour(ColorUtils.wbFromDMN(dmnStyleOfDrgShape.getFillColor())));
}
if (Objects.nonNull(dmnStyleOfDrgShape.getStrokeColor())) {
stylingSet.setBorderColour(new BorderColour(ColorUtils.wbFromDMN(dmnStyleOfDrgShape.getStrokeColor())));
}
}
final StylingSet fontStylingSet = new StylingSet();
if (Objects.nonNull(dmnStyleOfDrgShape)) {
mergeFontStylingSet(fontStylingSet, FontStylingSetPropertyConverter.wbFromDMN(dmnStyleOfDrgShape));
}
if (Objects.nonNull(drgShape.getDMNLabel())) {
final JSIDMNShape jsiLabel = Js.uncheckedCast(drgShape.getDMNLabel());
final JSIStyle jsiLabelStyle = jsiLabel.getStyle();
final Object jsiLabelSharedStyle = Js.uncheckedCast(jsiLabel.getSharedStyle());
if (Objects.nonNull(jsiLabelSharedStyle) && JSIDMNStyle.instanceOf(jsiLabelSharedStyle)) {
mergeFontStylingSet(fontStylingSet, FontStylingSetPropertyConverter.wbFromDMN((Js.uncheckedCast(jsiLabelSharedStyle))));
}
if (Objects.nonNull(jsiLabelStyle) && isJSIDMNStyle(jsiLabelStyle)) {
mergeFontStylingSet(fontStylingSet, FontStylingSetPropertyConverter.wbFromDMN(Js.uncheckedCast(jsiLabelStyle)));
}
}
mergeFontStylingSet(stylingSet, fontStylingSet);
}
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 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;
}
Aggregations