Search in sources :

Example 6 with DMNStyle

use of org.kie.dmn.model.api.dmndi.DMNStyle in project drools by kiegroup.

the class DMNDI method replaceSharedStyleIfStubbed.

private void replaceSharedStyleIfStubbed(DiagramElement element, Map<String, DMNStyle> styleById) {
    if (element.getSharedStyle() instanceof IDREFStubStyle) {
        DMNStyle locatedStyle = styleById.get(element.getSharedStyle().getId());
        element.setSharedStyle(locatedStyle);
    }
}
Also used : IDREFStubStyle(org.kie.dmn.model.v1_2.dmndi.Style.IDREFStubStyle) DMNStyle(org.kie.dmn.model.api.dmndi.DMNStyle)

Example 7 with DMNStyle

use of org.kie.dmn.model.api.dmndi.DMNStyle in project drools by kiegroup.

the class DMNStyleConverter method writeChildren.

@Override
protected void writeChildren(HierarchicalStreamWriter writer, MarshallingContext context, Object parent) {
    super.writeChildren(writer, context, parent);
    DMNStyle style = (DMNStyle) parent;
    if (style.getFillColor() != null) {
        writeChildrenNode(writer, context, style.getFillColor(), FILL_COLOR);
    }
    if (style.getStrokeColor() != null) {
        writeChildrenNode(writer, context, style.getStrokeColor(), STROKE_COLOR);
    }
    if (style.getFontColor() != null) {
        writeChildrenNode(writer, context, style.getFontColor(), FONT_COLOR);
    }
}
Also used : DMNStyle(org.kie.dmn.model.api.dmndi.DMNStyle)

Example 8 with DMNStyle

use of org.kie.dmn.model.api.dmndi.DMNStyle in project drools by kiegroup.

the class DMNStyleConverter method assignAttributes.

@Override
protected void assignAttributes(HierarchicalStreamReader reader, Object parent) {
    super.assignAttributes(reader, parent);
    DMNStyle style = (DMNStyle) parent;
    String fontFamily = reader.getAttribute(FONT_FAMILY);
    String fontSize = reader.getAttribute(FONT_SIZE);
    String fontItalic = reader.getAttribute(FONT_ITALIC);
    String fontBold = reader.getAttribute(FONT_BOLD);
    String fontUnderline = reader.getAttribute(FONT_UNDERLINE);
    String fontStrikeThrough = reader.getAttribute(FONT_STRIKE_THROUGH);
    String labelHorizontalAlignement = reader.getAttribute(LABEL_HORIZONTAL_ALIGNMENT);
    String labelVerticalAlignment = reader.getAttribute(LABEL_VERTICAL_ALIGNMENT);
    if (fontFamily != null) {
        style.setFontFamily(fontFamily);
    }
    if (fontSize != null) {
        style.setFontSize(Double.valueOf(fontSize));
    }
    if (fontItalic != null) {
        style.setFontItalic(Boolean.valueOf(fontItalic));
    }
    if (fontBold != null) {
        style.setFontBold(Boolean.valueOf(fontBold));
    }
    if (fontUnderline != null) {
        style.setFontUnderline(Boolean.valueOf(fontUnderline));
    }
    if (fontStrikeThrough != null) {
        style.setFontStrikeThrough(Boolean.valueOf(fontStrikeThrough));
    }
    if (labelHorizontalAlignement != null) {
        style.setLabelHorizontalAlignement(AlignmentKind.valueOf(labelHorizontalAlignement));
    }
    if (labelVerticalAlignment != null) {
        style.setLabelVerticalAlignment(AlignmentKind.valueOf(labelVerticalAlignment));
    }
}
Also used : DMNStyle(org.kie.dmn.model.api.dmndi.DMNStyle)

Example 9 with DMNStyle

use of org.kie.dmn.model.api.dmndi.DMNStyle in project drools by kiegroup.

the class DMNDIConverter method writeChildren.

@Override
protected void writeChildren(HierarchicalStreamWriter writer, MarshallingContext context, Object parent) {
    super.writeChildren(writer, context, parent);
    DMNDI list = (DMNDI) parent;
    for (DMNDiagram e : list.getDMNDiagram()) {
        writeChildrenNode(writer, context, e, DMN_DIAGRAM);
    }
    for (DMNStyle e : list.getDMNStyle()) {
        writeChildrenNode(writer, context, e, DMN_STYLE);
    }
}
Also used : DMNDiagram(org.kie.dmn.model.api.dmndi.DMNDiagram) DMNDI(org.kie.dmn.model.api.dmndi.DMNDI) DMNStyle(org.kie.dmn.model.api.dmndi.DMNStyle)

Example 10 with DMNStyle

use of org.kie.dmn.model.api.dmndi.DMNStyle in project drools by kiegroup.

the class UnmarshalMarshalTest method test_FontSize_sharedStyle.

@Test
public void test_FontSize_sharedStyle() throws Exception {
    testRoundTripV12("org/kie/dmn/backend/marshalling/v1_2/", "test-FontSize-sharedStyle.dmn");
    Definitions definitions = MARSHALLER.unmarshal(new InputStreamReader(this.getClass().getResourceAsStream("test-FontSize-sharedStyle.dmn")));
    DMNShape shape0 = (DMNShape) definitions.getDMNDI().getDMNDiagram().get(0).getDMNDiagramElement().get(0);
    DMNStyle shape0sharedStyle = (DMNStyle) shape0.getDMNLabel().getSharedStyle();
    assertEquals("LS_4d396200-362f-4939-830d-32d2b4c87042_0", shape0sharedStyle.getId());
    assertEquals(21d, shape0sharedStyle.getFontSize(), 0.0d);
}
Also used : DMNShape(org.kie.dmn.model.api.dmndi.DMNShape) InputStreamReader(java.io.InputStreamReader) Definitions(org.kie.dmn.model.api.Definitions) DMNStyle(org.kie.dmn.model.api.dmndi.DMNStyle) Test(org.junit.Test)

Aggregations

DMNStyle (org.kie.dmn.model.api.dmndi.DMNStyle)15 DMNDiagram (org.kie.dmn.model.api.dmndi.DMNDiagram)4 InputStreamReader (java.io.InputStreamReader)2 Color (org.kie.dmn.model.api.dmndi.Color)2 DMNDI (org.kie.dmn.model.api.dmndi.DMNDI)2 DMNShape (org.kie.dmn.model.api.dmndi.DMNShape)2 DiagramElement (org.kie.dmn.model.api.dmndi.DiagramElement)2 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 SimpleEntry (java.util.AbstractMap.SimpleEntry)1 ArrayList (java.util.ArrayList)1 Collections.emptyList (java.util.Collections.emptyList)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 List (java.util.List)1 Map (java.util.Map)1 Entry (java.util.Map.Entry)1 Objects (java.util.Objects)1 Optional (java.util.Optional)1 Set (java.util.Set)1