use of org.kie.workbench.common.dmn.api.property.styling.StylingSet 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.workbench.common.dmn.api.property.styling.StylingSet in project kie-wb-common by kiegroup.
the class KnowledgeSourceTest method testDifferentStylingSet.
@Test
public void testDifferentStylingSet() {
final KnowledgeSource modelOne = new KnowledgeSource(new Id("123"), new Description(), new Name(), new KnowledgeSourceType(), new LocationURI(), new StylingSet(), new GeneralRectangleDimensionsSet());
final KnowledgeSource modelTwo = new KnowledgeSource(new Id("123"), new Description(), new Name(), new KnowledgeSourceType(), new LocationURI(), new StylingSet(), new GeneralRectangleDimensionsSet());
assertEquals(modelOne, modelTwo);
modelOne.getStylingSet().setFontSize(new FontSize(10.0));
modelTwo.getStylingSet().setFontSize(new FontSize(11.0));
assertNotEquals(modelOne, modelTwo);
}
use of org.kie.workbench.common.dmn.api.property.styling.StylingSet in project kie-wb-common by kiegroup.
the class InputDataTest method testDifferentStylingSet.
@Test
public void testDifferentStylingSet() {
final InputData modelOne = new InputData(new Id("123"), new Description(), new Name(), new InformationItemPrimary(new Id("346"), new Name(), new QName()), new StylingSet(), new GeneralRectangleDimensionsSet());
final InputData modelTwo = new InputData(new Id("123"), new Description(), new Name(), new InformationItemPrimary(new Id("346"), new Name(), new QName()), new StylingSet(), new GeneralRectangleDimensionsSet());
assertEquals(modelOne, modelTwo);
modelOne.getStylingSet().setFontSize(new FontSize(10.0));
modelTwo.getStylingSet().setFontSize(new FontSize(11.0));
assertNotEquals(modelOne, modelTwo);
}
use of org.kie.workbench.common.dmn.api.property.styling.StylingSet in project kie-wb-common by kiegroup.
the class TextAnnotationTest method testDifferentStylingSet.
@Test
public void testDifferentStylingSet() {
final TextAnnotation modelOne = new TextAnnotation(new Id("123"), new Description(), new Text(), new TextFormat(), new StylingSet(), new GeneralRectangleDimensionsSet());
final TextAnnotation modelTwo = new TextAnnotation(new Id("123"), new Description(), new Text(), new TextFormat(), new StylingSet(), new GeneralRectangleDimensionsSet());
assertEquals(modelOne, modelTwo);
modelOne.getStylingSet().setFontSize(new FontSize(10.0));
modelTwo.getStylingSet().setFontSize(new FontSize(11.0));
assertNotEquals(modelOne, modelTwo);
}
use of org.kie.workbench.common.dmn.api.property.styling.StylingSet in project kie-wb-common by kiegroup.
the class StunnerConverterTest method testDecision.
@Test
public void testDecision() {
final StylingSet decisionStylingSet = mock(StylingSet.class);
final Decision decision = spy(new Decision());
when(decision.getStylingSet()).thenReturn(decisionStylingSet);
final JSITDecision jsitDecision = mock(JSITDecision.class);
when(jsitDecision.getTYPE_NAME()).thenReturn(JSITDecision.TYPE);
final JSIStyle style = mock(JSIStyle.class);
final JSIDMNShape shape = mock(JSIDMNShape.class);
final JSIDMNStyle dmnStyleOfDrgShape = mock(JSIDMNStyle.class);
when(shape.getStyle()).thenReturn(style);
doReturn(style).when(converter).getUnwrappedJSIStyle(style);
doReturn(true).when(converter).isJSIDMNStyle(style);
doReturn(dmnStyleOfDrgShape).when(converter).getJSIDmnStyle(style);
final NodeEntry nodeEntry = mock(NodeEntry.class);
when(nodeEntry.getDmnElement()).thenReturn(jsitDecision);
when(nodeEntry.getId()).thenReturn("_id");
when(nodeEntry.getDmnShape()).thenReturn(shape);
final Element graphElement = mock(Element.class);
final Node graphNode = mock(Node.class);
final View content = mock(View.class);
when(factoryManager.newElement(anyString(), anyString())).thenReturn(graphElement);
when(graphElement.asNode()).thenReturn(graphNode);
when(graphNode.getContent()).thenReturn(content);
when(content.getDefinition()).thenReturn(decision);
final JSIColor randomColor = mock(JSIColor.class);
when(randomColor.getRed()).thenReturn(12);
when(randomColor.getGreen()).thenReturn(34);
when(randomColor.getBlue()).thenReturn(56);
when(dmnStyleOfDrgShape.getFontColor()).thenReturn(randomColor);
when(dmnStyleOfDrgShape.getStrokeColor()).thenReturn(randomColor);
when(dmnStyleOfDrgShape.getFillColor()).thenReturn(randomColor);
when(dmnStyleOfDrgShape.getFontSize()).thenReturn(11d);
converter.make(nodeEntry);
verify(decisionStylingSet).setFontSize(fontSizeArgumentCaptor.capture());
Assertions.assertThat(fontSizeArgumentCaptor.getValue().getValue()).isEqualTo(11d);
verify(decisionStylingSet).setBorderColour(borderColourArgumentCaptor.capture());
Assertions.assertThat(borderColourArgumentCaptor.getValue().getValue()).isEqualTo("#0c2238");
verify(decisionStylingSet).setBgColour(bgColourArgumentCaptor.capture());
Assertions.assertThat(bgColourArgumentCaptor.getValue().getValue()).isEqualTo("#0c2238");
verify(decisionStylingSet).setFontColour(fontColourArgumentCaptor.capture());
Assertions.assertThat(fontColourArgumentCaptor.getValue().getValue()).isEqualTo("#0c2238");
}
Aggregations