|
35 | 35 | import java.util.stream.Collectors; |
36 | 36 | import java.util.stream.Stream; |
37 | 37 |
|
38 | | -import com.structurizr.export.plantuml.AbstractPlantUMLExporter; |
39 | 38 | import org.springframework.lang.Nullable; |
40 | 39 | import org.springframework.modulith.core.ApplicationModule; |
41 | 40 | import org.springframework.modulith.core.ApplicationModuleDependency; |
|
51 | 50 |
|
52 | 51 | import com.structurizr.Workspace; |
53 | 52 | import com.structurizr.export.IndentingWriter; |
| 53 | +import com.structurizr.export.plantuml.AbstractPlantUMLExporter; |
54 | 54 | import com.structurizr.export.plantuml.C4PlantUMLExporter; |
55 | 55 | import com.structurizr.export.plantuml.StructurizrPlantUMLExporter; |
56 | 56 | import com.structurizr.model.Component; |
|
72 | 72 | * |
73 | 73 | * @author Oliver Drotbohm |
74 | 74 | * @author Cora Iberkleid |
| 75 | + * @author Alexander Miller |
75 | 76 | */ |
76 | 77 | public class Documenter { |
77 | 78 |
|
@@ -575,19 +576,13 @@ private String render(ComponentView view, DiagramOptions options) { |
575 | 576 | default: |
576 | 577 |
|
577 | 578 | var plantUmlExporter = new CustomizedPlantUmlExporter(); |
578 | | - addSkinParamsFromOptions(plantUmlExporter, options); |
579 | 579 | plantUmlExporter.addSkinParam("componentStyle", "uml1"); |
| 580 | + addSkinParamsFromOptions(plantUmlExporter, options); |
580 | 581 |
|
581 | 582 | return plantUmlExporter.export(view).getDefinition(); |
582 | 583 | } |
583 | 584 | } |
584 | 585 |
|
585 | | - private void addSkinParamsFromOptions(AbstractPlantUMLExporter exporter, DiagramOptions options) { |
586 | | - for (var skinParamEntry : options.skinParams.entrySet()) { |
587 | | - exporter.addSkinParam(skinParamEntry.getKey(), skinParamEntry.getValue()); |
588 | | - } |
589 | | - } |
590 | | - |
591 | 586 | private String createPlantUml(DiagramOptions options) { |
592 | 587 |
|
593 | 588 | ComponentView componentView = createComponentView(options); |
@@ -625,6 +620,10 @@ private Path recreateFile(String name) { |
625 | 620 | } |
626 | 621 | } |
627 | 622 |
|
| 623 | + private void addSkinParamsFromOptions(AbstractPlantUMLExporter exporter, DiagramOptions options) { |
| 624 | + options.skinParams.forEach(exporter::addSkinParam); |
| 625 | + } |
| 626 | + |
628 | 627 | private static Component applyBackgroundColor(ApplicationModule module, |
629 | 628 | Map<ApplicationModule, Component> components, |
630 | 629 | DiagramOptions options, |
@@ -733,7 +732,7 @@ public static class DiagramOptions { |
733 | 732 | Assert.notNull(defaultDisplayName, "Default display name must not be null!"); |
734 | 733 | Assert.notNull(style, "DiagramStyle must not be null!"); |
735 | 734 | Assert.notNull(elementsWithoutRelationships, "ElementsWithoutRelationships must not be null!"); |
736 | | - Assert.notNull(skinParams, "SkinParams must not be null!"); |
| 735 | + Assert.notNull(skinParams, "Skin parameters must not be null!"); |
737 | 736 |
|
738 | 737 | this.dependencyTypes = dependencyTypes; |
739 | 738 | this.dependencyDepth = dependencyDepth; |
@@ -833,14 +832,23 @@ public DiagramOptions withElementsWithoutRelationships(ElementsWithoutRelationsh |
833 | 832 | } |
834 | 833 |
|
835 | 834 | /** |
836 | | - * Configuration setting to add arbitrary skin parameters to the created diagrams. |
| 835 | + * Configuration setting to add arbitrary skin parameters to the created diagrams. Applies to both the UML and C4 |
| 836 | + * {@link DiagramStyle styles}. |
837 | 837 | * |
838 | | - * Applies to both the UML and C4 {@link DiagramStyle styles}. |
| 838 | + * @param name must not be {@literal null} or empty. |
| 839 | + * @param value can be {@literal null}. |
| 840 | + * @return will never be {@literal null}. |
| 841 | + * @since 1.2.7, 1.3.1 |
839 | 842 | */ |
840 | | - public DiagramOptions withSkinParam(String name, String value) { |
841 | | - skinParams.put(name, value); |
| 843 | + public DiagramOptions withSkinParam(String name, @Nullable String value) { |
| 844 | + |
| 845 | + Assert.hasText(name, "Name must not be null or empty!"); |
| 846 | + |
| 847 | + var newSkinParams = new LinkedHashMap<>(skinParams); |
| 848 | + newSkinParams.put(name, value); |
| 849 | + |
842 | 850 | return new DiagramOptions(dependencyTypes, dependencyDepth, exclusions, componentFilter, targetOnly, |
843 | | - targetFileName, colorSelector, defaultDisplayName, style, elementsWithoutRelationships, skinParams); |
| 851 | + targetFileName, colorSelector, defaultDisplayName, style, elementsWithoutRelationships, newSkinParams); |
844 | 852 | } |
845 | 853 |
|
846 | 854 | /** |
|
0 commit comments