|
34 | 34 | import java.util.stream.Collectors; |
35 | 35 | import java.util.stream.Stream; |
36 | 36 |
|
37 | | -import com.structurizr.export.plantuml.AbstractPlantUMLExporter; |
38 | 37 | import org.springframework.lang.Nullable; |
39 | 38 | import org.springframework.modulith.core.ApplicationModule; |
40 | 39 | import org.springframework.modulith.core.ApplicationModules; |
|
49 | 48 |
|
50 | 49 | import com.structurizr.Workspace; |
51 | 50 | import com.structurizr.export.IndentingWriter; |
| 51 | +import com.structurizr.export.plantuml.AbstractPlantUMLExporter; |
52 | 52 | import com.structurizr.export.plantuml.C4PlantUMLExporter; |
53 | 53 | import com.structurizr.export.plantuml.StructurizrPlantUMLExporter; |
54 | 54 | import com.structurizr.model.Component; |
|
71 | 71 | * @author Oliver Drotbohm |
72 | 72 | * @author Cora Iberkleid |
73 | 73 | * @author Tobias Haindl |
| 74 | + * @author Alexander Miller |
74 | 75 | */ |
75 | 76 | public class Documenter { |
76 | 77 |
|
@@ -563,19 +564,13 @@ private String render(ComponentView view, DiagramOptions options) { |
563 | 564 | default: |
564 | 565 |
|
565 | 566 | var plantUmlExporter = new CustomizedPlantUmlExporter(); |
566 | | - addSkinParamsFromOptions(plantUmlExporter, options); |
567 | 567 | plantUmlExporter.addSkinParam("componentStyle", "uml1"); |
| 568 | + addSkinParamsFromOptions(plantUmlExporter, options); |
568 | 569 |
|
569 | 570 | return plantUmlExporter.export(view).getDefinition(); |
570 | 571 | } |
571 | 572 | } |
572 | 573 |
|
573 | | - private void addSkinParamsFromOptions(AbstractPlantUMLExporter exporter, DiagramOptions options) { |
574 | | - for (var skinParamEntry : options.skinParams.entrySet()) { |
575 | | - exporter.addSkinParam(skinParamEntry.getKey(), skinParamEntry.getValue()); |
576 | | - } |
577 | | - } |
578 | | - |
579 | 574 | private String createPlantUml(DiagramOptions options) { |
580 | 575 |
|
581 | 576 | ComponentView componentView = createComponentView(options); |
@@ -609,6 +604,10 @@ private void potentiallyWipeOutputFolder() { |
609 | 604 | } |
610 | 605 | } |
611 | 606 |
|
| 607 | + private void addSkinParamsFromOptions(AbstractPlantUMLExporter exporter, DiagramOptions options) { |
| 608 | + options.skinParams.forEach(exporter::addSkinParam); |
| 609 | + } |
| 610 | + |
612 | 611 | private static Component applyBackgroundColor(ApplicationModule module, |
613 | 612 | Map<ApplicationModule, Component> components, |
614 | 613 | DiagramOptions options, |
@@ -708,7 +707,7 @@ public static class DiagramOptions { |
708 | 707 | Assert.notNull(defaultDisplayName, "Default display name must not be null!"); |
709 | 708 | Assert.notNull(style, "DiagramStyle must not be null!"); |
710 | 709 | Assert.notNull(elementsWithoutRelationships, "ElementsWithoutRelationships must not be null!"); |
711 | | - Assert.notNull(skinParams, "SkinParams must not be null!"); |
| 710 | + Assert.notNull(skinParams, "Skin parameters must not be null!"); |
712 | 711 |
|
713 | 712 | this.dependencyTypes = dependencyTypes; |
714 | 713 | this.dependencyDepth = dependencyDepth; |
@@ -808,14 +807,23 @@ public DiagramOptions withElementsWithoutRelationships(ElementsWithoutRelationsh |
808 | 807 | } |
809 | 808 |
|
810 | 809 | /** |
811 | | - * Configuration setting to add arbitrary skin parameters to the created diagrams. |
| 810 | + * Configuration setting to add arbitrary skin parameters to the created diagrams. Applies to both the UML and C4 |
| 811 | + * {@link DiagramStyle styles}. |
812 | 812 | * |
813 | | - * Applies to both the UML and C4 {@link DiagramStyle styles}. |
| 813 | + * @param name must not be {@literal null} or empty. |
| 814 | + * @param value can be {@literal null}. |
| 815 | + * @return will never be {@literal null}. |
| 816 | + * @since 1.2.7, 1.3.1 |
814 | 817 | */ |
815 | | - public DiagramOptions withSkinParam(String name, String value) { |
816 | | - skinParams.put(name, value); |
| 818 | + public DiagramOptions withSkinParam(String name, @Nullable String value) { |
| 819 | + |
| 820 | + Assert.hasText(name, "Name must not be null or empty!"); |
| 821 | + |
| 822 | + var newSkinParams = new LinkedHashMap<>(skinParams); |
| 823 | + newSkinParams.put(name, value); |
| 824 | + |
817 | 825 | return new DiagramOptions(dependencyTypes, dependencyDepth, exclusions, componentFilter, targetOnly, |
818 | | - targetFileName, colorSelector, defaultDisplayName, style, elementsWithoutRelationships, skinParams); |
| 826 | + targetFileName, colorSelector, defaultDisplayName, style, elementsWithoutRelationships, newSkinParams); |
819 | 827 | } |
820 | 828 |
|
821 | 829 | /** |
|
0 commit comments