use of org.kie.dmn.model.api.dmndi.DMNStyle in project kie-wb-common by kiegroup.
the class DMNMarshallerStandalone method internalAugment.
@SuppressWarnings("unchecked")
private void internalAugment(final Stream<DMNShape> drgShapeStream, final Id id, final Bound ulBound, final RectangleDimensionsSet dimensionsSet, final Bound lrBound, final StylingSet stylingSet, final DoubleConsumer decisionServiceDividerLineYSetter) {
final Optional<DMNShape> drgShapeOpt = drgShapeStream.filter(shape -> shape.getDmnElementRef().getLocalPart().endsWith(id.getValue())).findFirst();
if (!drgShapeOpt.isPresent()) {
return;
}
final DMNShape drgShape = drgShapeOpt.get();
if (ulBound != null) {
ulBound.setX(xOfShape(drgShape));
ulBound.setY(yOfShape(drgShape));
}
dimensionsSet.setWidth(new Width(widthOfShape(drgShape)));
dimensionsSet.setHeight(new Height(heightOfShape(drgShape)));
if (lrBound != null) {
lrBound.setX(xOfShape(drgShape) + widthOfShape(drgShape));
lrBound.setY(yOfShape(drgShape) + heightOfShape(drgShape));
}
final DMNStyle dmnStyleOfDrgShape = drgShape.getStyle() instanceof DMNStyle ? (DMNStyle) drgShape.getStyle() : null;
if (dmnStyleOfDrgShape != null) {
if (null != dmnStyleOfDrgShape.getFillColor()) {
stylingSet.setBgColour(new BgColour(ColorUtils.wbFromDMN(dmnStyleOfDrgShape.getFillColor())));
}
if (null != dmnStyleOfDrgShape.getStrokeColor()) {
stylingSet.setBorderColour(new BorderColour(ColorUtils.wbFromDMN(dmnStyleOfDrgShape.getStrokeColor())));
}
}
final StylingSet fontSet = new StylingSet();
if (dmnStyleOfDrgShape != null) {
mergeFontSet(fontSet, FontSetPropertyConverter.wbFromDMN(dmnStyleOfDrgShape));
}
if (drgShape.getDMNLabel() != null && drgShape.getDMNLabel().getSharedStyle() instanceof DMNStyle) {
mergeFontSet(fontSet, FontSetPropertyConverter.wbFromDMN((DMNStyle) drgShape.getDMNLabel().getSharedStyle()));
}
if (drgShape.getDMNLabel() != null && drgShape.getDMNLabel().getStyle() instanceof DMNStyle) {
mergeFontSet(fontSet, FontSetPropertyConverter.wbFromDMN((DMNStyle) drgShape.getDMNLabel().getStyle()));
}
mergeFontSet(stylingSet, fontSet);
if (drgShape.getDMNDecisionServiceDividerLine() != null) {
decisionServiceDividerLineYSetter.accept(drgShape.getDMNDecisionServiceDividerLine().getWaypoint().get(0).getY());
}
}
use of org.kie.dmn.model.api.dmndi.DMNStyle in project kie-wb-common by kiegroup.
the class DMNMarshallerStandalone method applyFontStyle.
private static void applyFontStyle(final StylingSet fontSet, final DMNShape result) {
if (!(result.getStyle() instanceof DMNStyle)) {
return;
}
final DMNStyle shapeStyle = (DMNStyle) result.getStyle();
final Color fontColor = ColorUtils.dmnFromWB(fontSet.getFontColour().getValue());
shapeStyle.setFontColor(fontColor);
if (null != fontSet.getFontFamily().getValue()) {
shapeStyle.setFontFamily(fontSet.getFontFamily().getValue());
}
if (null != fontSet.getFontSize().getValue()) {
shapeStyle.setFontSize(fontSet.getFontSize().getValue());
}
}
use of org.kie.dmn.model.api.dmndi.DMNStyle in project drools by kiegroup.
the class DMNStyleConverter method writeAttributes.
@Override
protected void writeAttributes(HierarchicalStreamWriter writer, Object parent) {
super.writeAttributes(writer, parent);
DMNStyle style = (DMNStyle) parent;
if (style.getFontFamily() != null) {
writer.addAttribute(FONT_FAMILY, style.getFontFamily());
}
if (style.getFontSize() != null) {
writer.addAttribute(FONT_SIZE, FormatUtils.manageDouble(style.getFontSize()));
}
if (style.isFontItalic() != null) {
writer.addAttribute(FONT_ITALIC, style.isFontItalic().toString());
}
if (style.isFontBold() != null) {
writer.addAttribute(FONT_BOLD, style.isFontBold().toString());
}
if (style.isFontUnderline() != null) {
writer.addAttribute(FONT_UNDERLINE, style.isFontUnderline().toString());
}
if (style.isFontStrikeThrough() != null) {
writer.addAttribute(FONT_STRIKE_THROUGH, style.isFontStrikeThrough().toString());
}
if (style.getLabelHorizontalAlignement() != null) {
writer.addAttribute(LABEL_HORIZONTAL_ALIGNMENT, style.getLabelHorizontalAlignement().toString());
}
if (style.getLabelVerticalAlignment() != null) {
writer.addAttribute(LABEL_VERTICAL_ALIGNMENT, style.getLabelVerticalAlignment().toString());
}
}
use of org.kie.dmn.model.api.dmndi.DMNStyle in project drools by kiegroup.
the class DMNDI method normalize.
@Override
public void normalize() {
if (dmnStyle == null || dmnDiagram == null) {
return;
}
Map<String, DMNStyle> styleById = dmnStyle.stream().collect(Collectors.toMap(DMNStyle::getId, Function.identity()));
for (DMNDiagram diagram : dmnDiagram) {
for (DiagramElement element : diagram.getDMNDiagramElement()) {
replaceSharedStyleIfStubbed(element, styleById);
if (element instanceof DMNShape) {
DMNShape dmnShape = (DMNShape) element;
replaceSharedStyleIfStubbed(dmnShape.getDMNLabel(), styleById);
}
}
}
}
use of org.kie.dmn.model.api.dmndi.DMNStyle in project drools by kiegroup.
the class DMNDI method normalize.
@Override
public void normalize() {
if (dmnStyle == null || dmnDiagram == null) {
return;
}
Map<String, DMNStyle> styleById = dmnStyle.stream().collect(Collectors.toMap(DMNStyle::getId, Function.identity()));
for (DMNDiagram diagram : dmnDiagram) {
for (DiagramElement element : diagram.getDMNDiagramElement()) {
replaceSharedStyleIfStubbed(element, styleById);
if (element instanceof DMNShape) {
DMNShape dmnShape = (DMNShape) element;
replaceSharedStyleIfStubbed(dmnShape.getDMNLabel(), styleById);
}
}
}
}
Aggregations