Search in sources :

Example 1 with Height

use of org.kie.workbench.common.dmn.api.property.dimensions.Height 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());
    }
}
Also used : DMNShape(org.kie.dmn.model.api.dmndi.DMNShape) Edge(org.kie.workbench.common.stunner.core.graph.Edge) PointUtils.yOfBound(org.kie.workbench.common.dmn.backend.definition.v1_1.dd.PointUtils.yOfBound) PointUtils.xOfBound(org.kie.workbench.common.dmn.backend.definition.v1_1.dd.PointUtils.xOfBound) DoubleConsumer(java.util.function.DoubleConsumer) Bounds(org.kie.dmn.model.api.dmndi.Bounds) Map(java.util.Map) NamedElement(org.kie.workbench.common.dmn.api.definition.model.NamedElement) FactoryManager(org.kie.workbench.common.stunner.core.api.FactoryManager) Diagram(org.kie.workbench.common.stunner.core.diagram.Diagram) HasComponentWidths(org.kie.workbench.common.dmn.api.definition.HasComponentWidths) Height(org.kie.workbench.common.dmn.api.property.dimensions.Height) Point2D(org.kie.workbench.common.stunner.core.graph.content.view.Point2D) BusinessKnowledgeModel(org.kie.workbench.common.dmn.api.definition.model.BusinessKnowledgeModel) Set(java.util.Set) BusinessKnowledgeModelConverter(org.kie.workbench.common.dmn.backend.definition.v1_1.BusinessKnowledgeModelConverter) Child(org.kie.workbench.common.stunner.core.graph.content.relationship.Child) ItemDefinition(org.kie.workbench.common.dmn.api.definition.model.ItemDefinition) PointUtils.heightOfShape(org.kie.workbench.common.dmn.backend.definition.v1_1.dd.PointUtils.heightOfShape) Stream(java.util.stream.Stream) PointUtils(org.kie.workbench.common.dmn.backend.definition.v1_1.dd.PointUtils) QName(javax.xml.namespace.QName) PointUtils.widthOfShape(org.kie.workbench.common.dmn.backend.definition.v1_1.dd.PointUtils.widthOfShape) DMNMarshaller(org.kie.dmn.api.marshalling.DMNMarshaller) PointUtils.yOfShape(org.kie.workbench.common.dmn.backend.definition.v1_1.dd.PointUtils.yOfShape) DMNDefinitionSet(org.kie.workbench.common.dmn.api.DMNDefinitionSet) DMNStyle(org.kie.dmn.model.api.dmndi.DMNStyle) Point(org.kie.dmn.model.api.dmndi.Point) Connection(org.kie.workbench.common.stunner.core.graph.content.view.Connection) Color(org.kie.dmn.model.api.dmndi.Color) ItemDefinitionPropertyConverter(org.kie.workbench.common.dmn.backend.definition.v1_1.ItemDefinitionPropertyConverter) DiagramMetadataMarshaller(org.kie.workbench.common.stunner.core.definition.service.DiagramMetadataMarshaller) ArrayList(java.util.ArrayList) FontSetPropertyConverter(org.kie.workbench.common.dmn.backend.definition.v1_1.dd.FontSetPropertyConverter) Id(org.kie.workbench.common.dmn.api.property.dmn.Id) PointUtils.upperLeftBound(org.kie.workbench.common.dmn.backend.definition.v1_1.dd.PointUtils.upperLeftBound) BiConsumer(java.util.function.BiConsumer) StreamSupport(java.util.stream.StreamSupport) BindableAdapterUtils(org.kie.workbench.common.stunner.core.definition.adapter.binding.BindableAdapterUtils) IOException(java.io.IOException) InputData(org.kie.workbench.common.dmn.api.definition.model.InputData) InputStreamReader(java.io.InputStreamReader) InputDataConverter(org.kie.workbench.common.dmn.backend.definition.v1_1.InputDataConverter) Association(org.kie.workbench.common.dmn.api.definition.model.Association) DecisionService(org.kie.workbench.common.dmn.api.definition.model.DecisionService) KnowledgeSourceConverter(org.kie.workbench.common.dmn.backend.definition.v1_1.KnowledgeSourceConverter) Graph(org.kie.workbench.common.stunner.core.graph.Graph) MagnetConnection(org.kie.workbench.common.stunner.core.graph.content.view.MagnetConnection) TextAnnotation(org.kie.workbench.common.dmn.api.definition.model.TextAnnotation) Definitions(org.kie.workbench.common.dmn.api.definition.model.Definitions) DecisionConverter(org.kie.workbench.common.dmn.backend.definition.v1_1.DecisionConverter) DefinitionUtils(org.kie.workbench.common.stunner.core.util.DefinitionUtils) DMNDecisionServiceDividerLine(org.kie.dmn.model.api.dmndi.DMNDecisionServiceDividerLine) DMNEdge(org.kie.dmn.model.api.dmndi.DMNEdge) UUID(org.kie.workbench.common.stunner.core.util.UUID) BorderColour(org.kie.workbench.common.dmn.api.property.styling.BorderColour) EdgeImpl(org.kie.workbench.common.stunner.core.graph.impl.EdgeImpl) TextAnnotationConverter(org.kie.workbench.common.dmn.backend.definition.v1_1.TextAnnotationConverter) DMNElement(org.kie.workbench.common.dmn.api.definition.model.DMNElement) Collectors.toMap(java.util.stream.Collectors.toMap) PointUtils.lowerRightBound(org.kie.workbench.common.dmn.backend.definition.v1_1.dd.PointUtils.lowerRightBound) InformationRequirement(org.kie.workbench.common.dmn.api.definition.model.InformationRequirement) DiagramElement(org.kie.dmn.model.v1_2.dmndi.DiagramElement) Collections.emptyList(java.util.Collections.emptyList) DiagramMarshaller(org.kie.workbench.common.stunner.core.definition.service.DiagramMarshaller) Import(org.kie.dmn.model.api.Import) DMNDiagram(org.kie.workbench.common.dmn.api.definition.model.DMNDiagram) Collectors(java.util.stream.Collectors) Metadata(org.kie.workbench.common.stunner.core.diagram.Metadata) Objects(java.util.Objects) DRGElement(org.kie.workbench.common.dmn.api.definition.model.DRGElement) List(java.util.List) DMNShape(org.kie.dmn.model.api.dmndi.DMNShape) ComponentWidths(org.kie.workbench.common.dmn.backend.definition.v1_1.dd.ComponentWidths) BgColour(org.kie.workbench.common.dmn.api.property.styling.BgColour) DMNDI(org.kie.dmn.model.v1_2.dmndi.DMNDI) Entry(java.util.Map.Entry) Optional(java.util.Optional) ApplicationScoped(javax.enterprise.context.ApplicationScoped) Node(org.kie.workbench.common.stunner.core.graph.Node) PointUtils.xOfShape(org.kie.workbench.common.dmn.backend.definition.v1_1.dd.PointUtils.xOfShape) PMMLDocumentMetadata(org.kie.workbench.common.dmn.api.editors.included.PMMLDocumentMetadata) Width(org.kie.workbench.common.dmn.api.property.dimensions.Width) ControlPoint(org.kie.workbench.common.stunner.core.graph.content.view.ControlPoint) RectangleDimensionsSet(org.kie.workbench.common.dmn.api.property.dimensions.RectangleDimensionsSet) DefinitionsConverter(org.kie.workbench.common.dmn.backend.definition.v1_1.DefinitionsConverter) HashMap(java.util.HashMap) View(org.kie.workbench.common.stunner.core.graph.content.view.View) ColorUtils(org.kie.workbench.common.dmn.backend.definition.v1_1.dd.ColorUtils) HashSet(java.util.HashSet) Inject(javax.inject.Inject) ComponentsWidthsExtension(org.kie.workbench.common.dmn.backend.definition.v1_1.dd.ComponentsWidthsExtension) Bound(org.kie.workbench.common.stunner.core.graph.content.Bound) BindableAdapterUtils.getDefinitionId(org.kie.workbench.common.stunner.core.definition.adapter.binding.BindableAdapterUtils.getDefinitionId) KnowledgeRequirement(org.kie.workbench.common.dmn.api.definition.model.KnowledgeRequirement) Description(org.kie.workbench.common.dmn.api.property.dmn.Description) DMNViewDefinition(org.kie.workbench.common.dmn.api.definition.DMNViewDefinition) SimpleEntry(java.util.AbstractMap.SimpleEntry) DecisionServiceDividerLineY(org.kie.workbench.common.dmn.api.property.dmn.DecisionServiceDividerLineY) StylingSet(org.kie.workbench.common.dmn.api.property.styling.StylingSet) XMLEncoderDiagramMetadataMarshaller(org.kie.workbench.common.stunner.core.backend.service.XMLEncoderDiagramMetadataMarshaller) AssociationConverter(org.kie.workbench.common.dmn.backend.definition.v1_1.AssociationConverter) DMNMarshallerImportsHelperStandalone(org.kie.workbench.common.dmn.backend.common.DMNMarshallerImportsHelperStandalone) DecisionServiceConverter(org.kie.workbench.common.dmn.backend.definition.v1_1.DecisionServiceConverter) ViewConnector(org.kie.workbench.common.stunner.core.graph.content.view.ViewConnector) AuthorityRequirement(org.kie.workbench.common.dmn.api.definition.model.AuthorityRequirement) Consumer(java.util.function.Consumer) DMNModelInstrumentedBase(org.kie.workbench.common.dmn.api.definition.model.DMNModelInstrumentedBase) KnowledgeSource(org.kie.workbench.common.dmn.api.definition.model.KnowledgeSource) Decision(org.kie.workbench.common.dmn.api.definition.model.Decision) DiscreteConnection(org.kie.workbench.common.stunner.core.graph.content.view.DiscreteConnection) InputStream(java.io.InputStream) BgColour(org.kie.workbench.common.dmn.api.property.styling.BgColour) StylingSet(org.kie.workbench.common.dmn.api.property.styling.StylingSet) Height(org.kie.workbench.common.dmn.api.property.dimensions.Height) Width(org.kie.workbench.common.dmn.api.property.dimensions.Width) DMNStyle(org.kie.dmn.model.api.dmndi.DMNStyle) BorderColour(org.kie.workbench.common.dmn.api.property.styling.BorderColour)

Example 2 with Height

use of org.kie.workbench.common.dmn.api.property.dimensions.Height in project kie-wb-common by kiegroup.

the class StunnerConverter method internalAugment.

private void internalAugment(final JSIDMNShape drgShape, final Bound ulBound, final RectangleDimensionsSet dimensionsSet, final Bound lrBound, final StylingSet stylingSet, final Consumer<Double> decisionServiceDividerLineYSetter) {
    if (Objects.nonNull(ulBound)) {
        ulBound.setX(xOfShape(drgShape));
        ulBound.setY(yOfShape(drgShape));
    }
    dimensionsSet.setWidth(new Width(widthOfShape(drgShape)));
    dimensionsSet.setHeight(new Height(heightOfShape(drgShape)));
    if (Objects.nonNull(lrBound)) {
        lrBound.setX(xOfShape(drgShape) + widthOfShape(drgShape));
        lrBound.setY(yOfShape(drgShape) + heightOfShape(drgShape));
    }
    internalAugmentStyles(drgShape, stylingSet);
    if (Objects.nonNull(drgShape.getDMNDecisionServiceDividerLine())) {
        final JSIDMNDecisionServiceDividerLine divider = Js.uncheckedCast(drgShape.getDMNDecisionServiceDividerLine());
        final List<JSIPoint> dividerPoints = divider.getWaypoint();
        final JSIPoint dividerY = Js.uncheckedCast(dividerPoints.get(0));
        decisionServiceDividerLineYSetter.accept(dividerY.getY());
    }
}
Also used : JSIDMNDecisionServiceDividerLine(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmndi12.JSIDMNDecisionServiceDividerLine) JSIPoint(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dc.JSIPoint) Height(org.kie.workbench.common.dmn.api.property.dimensions.Height) Width(org.kie.workbench.common.dmn.api.property.dimensions.Width)

Example 3 with Height

use of org.kie.workbench.common.dmn.api.property.dimensions.Height in project kie-wb-common by kiegroup.

the class DMNMarshaller method internalAugment.

private void internalAugment(Stream<DMNShape> drgShapeStream, Id id, Bound ul, RectangleDimensionsSet dimensionsSet, Bound lr, BackgroundSet bgset, Consumer<FontSet> fontSetSetter) {
    Optional<DMNShape> drgShapeOpt = drgShapeStream.filter(shape -> shape.getDmnElementRef().equals(id.getValue())).findFirst();
    if (!drgShapeOpt.isPresent()) {
        return;
    }
    DMNShape drgShape = drgShapeOpt.get();
    ((BoundImpl) ul).setX(drgShape.getBounds().getX());
    ((BoundImpl) ul).setY(drgShape.getBounds().getY());
    dimensionsSet.setWidth(new Width(drgShape.getBounds().getWidth()));
    dimensionsSet.setHeight(new Height(drgShape.getBounds().getHeight()));
    ((BoundImpl) lr).setX(drgShape.getBounds().getX() + drgShape.getBounds().getWidth());
    ((BoundImpl) lr).setY(drgShape.getBounds().getY() + drgShape.getBounds().getHeight());
    if (null != drgShape.getBgColor()) {
        bgset.setBgColour(new BgColour(ColorUtils.wbFromDMN(drgShape.getBgColor())));
    }
    if (null != drgShape.getBorderColor()) {
        bgset.setBorderColour(new BorderColour(ColorUtils.wbFromDMN(drgShape.getBorderColor())));
    }
    if (null != drgShape.getBorderSize()) {
        bgset.setBorderSize(new BorderSize(drgShape.getBorderSize().getValue()));
    }
    if (null != drgShape.getFontStyle()) {
        fontSetSetter.accept(FontSetPropertyConverter.wbFromDMN(drgShape.getFontStyle()));
    }
}
Also used : DMNShape(org.kie.workbench.common.dmn.backend.definition.v1_1.dd.DMNShape) Arrays(java.util.Arrays) DecisionConverter(org.kie.workbench.common.dmn.backend.definition.v1_1.DecisionConverter) Edge(org.kie.workbench.common.stunner.core.graph.Edge) KnowledgeSource(org.kie.workbench.common.dmn.api.definition.v1_1.KnowledgeSource) UUID(org.kie.workbench.common.stunner.core.util.UUID) EdgeImpl(org.kie.workbench.common.stunner.core.graph.impl.EdgeImpl) Definitions(org.kie.workbench.common.dmn.api.definition.v1_1.Definitions) TextAnnotationConverter(org.kie.workbench.common.dmn.backend.definition.v1_1.TextAnnotationConverter) Bounds(org.kie.workbench.common.dmn.backend.definition.v1_1.dd.org.omg.spec.CMMN_20151109_DC.Bounds) Map(java.util.Map) DMNDiagram(org.kie.workbench.common.dmn.api.definition.v1_1.DMNDiagram) ServerMarshalling(org.jboss.errai.marshalling.server.ServerMarshalling) BgColour(org.kie.workbench.common.dmn.api.property.background.BgColour) FactoryManager(org.kie.workbench.common.stunner.core.api.FactoryManager) Diagram(org.kie.workbench.common.stunner.core.diagram.Diagram) Height(org.kie.workbench.common.dmn.api.property.dimensions.Height) InputData(org.kie.workbench.common.dmn.api.definition.v1_1.InputData) DiagramMarshaller(org.kie.workbench.common.stunner.core.definition.service.DiagramMarshaller) BusinessKnowledgeModelConverter(org.kie.workbench.common.dmn.backend.definition.v1_1.BusinessKnowledgeModelConverter) Child(org.kie.workbench.common.stunner.core.graph.content.relationship.Child) FontSet(org.kie.workbench.common.dmn.api.property.font.FontSet) Collectors(java.util.stream.Collectors) BorderColour(org.kie.workbench.common.dmn.api.property.background.BorderColour) Metadata(org.kie.workbench.common.stunner.core.diagram.Metadata) BusinessKnowledgeModel(org.kie.workbench.common.dmn.api.definition.v1_1.BusinessKnowledgeModel) List(java.util.List) Stream(java.util.stream.Stream) DDExtensionsRegister(org.kie.workbench.common.dmn.backend.definition.v1_1.dd.DDExtensionsRegister) Entry(java.util.Map.Entry) DMNMarshallerFactory(org.kie.dmn.backend.marshalling.v1_1.DMNMarshallerFactory) Optional(java.util.Optional) DMNShape(org.kie.workbench.common.dmn.backend.definition.v1_1.dd.DMNShape) ApplicationScoped(javax.enterprise.context.ApplicationScoped) Decision(org.kie.workbench.common.dmn.api.definition.v1_1.Decision) Node(org.kie.workbench.common.stunner.core.graph.Node) Width(org.kie.workbench.common.dmn.api.property.dimensions.Width) DMNDefinitionSet(org.kie.workbench.common.dmn.api.DMNDefinitionSet) RectangleDimensionsSet(org.kie.workbench.common.dmn.api.property.dimensions.RectangleDimensionsSet) DefinitionsConverter(org.kie.workbench.common.dmn.backend.definition.v1_1.DefinitionsConverter) HashMap(java.util.HashMap) DiagramMetadataMarshaller(org.kie.workbench.common.stunner.core.definition.service.DiagramMetadataMarshaller) View(org.kie.workbench.common.stunner.core.graph.content.view.View) ColorUtils(org.kie.workbench.common.dmn.backend.definition.v1_1.dd.ColorUtils) Inject(javax.inject.Inject) Id(org.kie.workbench.common.dmn.api.property.dmn.Id) Bound(org.kie.workbench.common.stunner.core.graph.content.Bounds.Bound) DRGElement(org.kie.workbench.common.dmn.api.definition.v1_1.DRGElement) Description(org.kie.workbench.common.dmn.api.property.dmn.Description) StreamSupport(java.util.stream.StreamSupport) SimpleEntry(java.util.AbstractMap.SimpleEntry) BindableAdapterUtils(org.kie.workbench.common.stunner.core.definition.adapter.binding.BindableAdapterUtils) TextAnnotation(org.kie.workbench.common.dmn.api.definition.v1_1.TextAnnotation) XMLEncoderDiagramMetadataMarshaller(org.kie.workbench.common.stunner.core.backend.service.XMLEncoderDiagramMetadataMarshaller) BorderSize(org.kie.workbench.common.dmn.api.property.background.BorderSize) AssociationConverter(org.kie.workbench.common.dmn.backend.definition.v1_1.AssociationConverter) BoundImpl(org.kie.workbench.common.stunner.core.graph.content.view.BoundImpl) IOException(java.io.IOException) InputStreamReader(java.io.InputStreamReader) Association(org.kie.workbench.common.dmn.api.definition.v1_1.Association) BackgroundSet(org.kie.workbench.common.dmn.api.property.background.BackgroundSet) FontSetPropertyConverter(org.kie.workbench.common.dmn.backend.definition.v1_1.FontSetPropertyConverter) InputDataConverter(org.kie.workbench.common.dmn.backend.definition.v1_1.InputDataConverter) ViewConnector(org.kie.workbench.common.stunner.core.graph.content.view.ViewConnector) Consumer(java.util.function.Consumer) KnowledgeSourceConverter(org.kie.workbench.common.dmn.backend.definition.v1_1.KnowledgeSourceConverter) Graph(org.kie.workbench.common.stunner.core.graph.Graph) MagnetConnection(org.kie.workbench.common.stunner.core.graph.content.view.MagnetConnection) DMNElement(org.kie.workbench.common.dmn.api.definition.v1_1.DMNElement) InputStream(java.io.InputStream) BgColour(org.kie.workbench.common.dmn.api.property.background.BgColour) BoundImpl(org.kie.workbench.common.stunner.core.graph.content.view.BoundImpl) Height(org.kie.workbench.common.dmn.api.property.dimensions.Height) BorderSize(org.kie.workbench.common.dmn.api.property.background.BorderSize) Width(org.kie.workbench.common.dmn.api.property.dimensions.Width) BorderColour(org.kie.workbench.common.dmn.api.property.background.BorderColour)

Aggregations

Height (org.kie.workbench.common.dmn.api.property.dimensions.Height)3 Width (org.kie.workbench.common.dmn.api.property.dimensions.Width)3 IOException (java.io.IOException)2 InputStream (java.io.InputStream)2 InputStreamReader (java.io.InputStreamReader)2 SimpleEntry (java.util.AbstractMap.SimpleEntry)2 HashMap (java.util.HashMap)2 List (java.util.List)2 Map (java.util.Map)2 Entry (java.util.Map.Entry)2 Optional (java.util.Optional)2 Consumer (java.util.function.Consumer)2 Collectors (java.util.stream.Collectors)2 Stream (java.util.stream.Stream)2 StreamSupport (java.util.stream.StreamSupport)2 ApplicationScoped (javax.enterprise.context.ApplicationScoped)2 Inject (javax.inject.Inject)2 DMNDefinitionSet (org.kie.workbench.common.dmn.api.DMNDefinitionSet)2 ArrayList (java.util.ArrayList)1 Arrays (java.util.Arrays)1