Skip to content

Commit 155da59

Browse files
structurizr-export: Adds the addSkinParam() method back to the PlantUML exporters.
1 parent 493710f commit 155da59

File tree

7 files changed

+130
-3
lines changed

7 files changed

+130
-3
lines changed

changelog.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
## v5.0.3 (21st November 2025)
4+
5+
- structurizr-export: Adds the `addSkinParam()` method back to the PlantUML exporters.
6+
37
## v5.0.2 (9th November 2025)
48

59
- structurizr-client: Adds a `getWorkspaceAsJson()` to `WorkspaceApiClient`.

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ signing.secretKeyRingFile=/some/path
55
ossrhUsername=username
66
ossrhPassword=password
77

8-
version=5.0.2
8+
version=5.0.3

structurizr-export/src/main/java/com/structurizr/export/plantuml/AbstractPlantUMLExporter.java

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@
1414
import javax.imageio.ImageIO;
1515
import java.awt.image.BufferedImage;
1616
import java.net.URL;
17+
import java.util.LinkedHashMap;
18+
import java.util.Map;
19+
20+
import static java.lang.String.format;
1721

1822
public abstract class AbstractPlantUMLExporter extends AbstractDiagramExporter {
1923

@@ -27,6 +31,20 @@ public abstract class AbstractPlantUMLExporter extends AbstractDiagramExporter {
2731
public static final String DIAGRAM_TITLE_TAG = "Diagram:Title";
2832
public static final String DIAGRAM_DESCRIPTION_TAG = "Diagram:Description";
2933

34+
private final Map<String, String> skinParams = new LinkedHashMap<>();
35+
36+
protected Map<String, String> getSkinParams() {
37+
return skinParams;
38+
}
39+
40+
public void addSkinParam(String name, String value) {
41+
skinParams.put(name, value);
42+
}
43+
44+
public void clearSkinParams() {
45+
skinParams.clear();
46+
}
47+
3048
public AbstractPlantUMLExporter() {
3149
this(ColorScheme.Light);
3250
}
@@ -208,6 +226,21 @@ protected void writeHeader(ModelView view, IndentingWriter writer) {
208226
writer.writeLine("set separator none");
209227
}
210228

229+
protected void writeSkinParams(IndentingWriter writer) {
230+
if (!skinParams.isEmpty()) {
231+
writer.writeLine();
232+
writer.writeLine("skinparam {");
233+
writer.indent();
234+
for (final String name : skinParams.keySet()) {
235+
writer.writeLine(format("%s %s", name, skinParams.get(name)));
236+
}
237+
writer.outdent();
238+
writer.writeLine("}");
239+
}
240+
241+
writer.writeLine();
242+
}
243+
211244
protected void writeIncludes(ModelView view, IndentingWriter writer) {
212245
String commaSeparatedIncludes = getViewOrViewSetProperty(view, PLANTUML_INCLUDES_PROPERTY, "");
213246
if (!StringUtils.isNullOrEmpty(commaSeparatedIncludes)) {

structurizr-export/src/main/java/com/structurizr/export/plantuml/C4PlantUMLExporter.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,8 @@ protected void writeHeader(ModelView view, IndentingWriter writer) {
7676
}
7777
}
7878

79-
writer.writeLine();
79+
writeSkinParams(writer);
80+
8081
writer.writeLine("<style>");
8182
writer.indent();
8283

structurizr-export/src/main/java/com/structurizr/export/plantuml/StructurizrPlantUMLExporter.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,8 @@ protected void writeHeader(ModelView view, IndentingWriter writer) {
6060
}
6161

6262
writer.writeLine("hide stereotype");
63-
writer.writeLine();
63+
64+
writeSkinParams(writer);
6465

6566
writer.writeLine("<style></style>");
6667
writer.writeLine();

structurizr-export/src/test/java/com/structurizr/export/plantuml/C4PlantUMLDiagramExporterTests.java

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1755,4 +1755,44 @@ public void elementWithUrl() {
17551755
@enduml""", diagram.getDefinition());
17561756
}
17571757

1758+
@Test
1759+
void skinparams() {
1760+
Workspace workspace = new Workspace("Name", "Description");
1761+
workspace.getModel().addSoftwareSystem("A");
1762+
1763+
SystemLandscapeView view = workspace.getViews().createSystemLandscapeView("key");
1764+
view.addAllElements();
1765+
1766+
C4PlantUMLExporter exporter = new C4PlantUMLExporter();
1767+
exporter.addSkinParam("linetype", "ortho");
1768+
Diagram diagram = exporter.export(view);
1769+
1770+
assertEquals("""
1771+
@startuml
1772+
title <size:24>System Landscape View</size>
1773+
1774+
set separator none
1775+
top to bottom direction
1776+
1777+
skinparam {
1778+
linetype ortho
1779+
}
1780+
1781+
<style>
1782+
root {
1783+
BackgroundColor: #ffffff
1784+
FontColor: #444444
1785+
}
1786+
</style>
1787+
1788+
!include <C4/C4>
1789+
!include <C4/C4_Context>
1790+
1791+
System(A, "A", $descr="", $tags="", $link="")
1792+
1793+
SHOW_LEGEND(true)
1794+
hide stereotypes
1795+
@enduml""", diagram.getDefinition());
1796+
}
1797+
17581798
}

structurizr-export/src/test/java/com/structurizr/export/plantuml/StructurizrPlantUMLDiagramExporterTests.java

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4216,4 +4216,52 @@ public void amazonWebServicesExample_Dark() throws Exception {
42164216
@enduml""", diagram.getLegend().getDefinition());
42174217
}
42184218

4219+
@Test
4220+
void skinparams() {
4221+
Workspace workspace = new Workspace("Name", "Description");
4222+
workspace.getModel().addSoftwareSystem("A");
4223+
4224+
SystemLandscapeView view = workspace.getViews().createSystemLandscapeView("key");
4225+
view.addAllElements();
4226+
4227+
StructurizrPlantUMLExporter exporter = new StructurizrPlantUMLExporter();
4228+
exporter.addSkinParam("linetype", "ortho");
4229+
Diagram diagram = exporter.export(view);
4230+
4231+
assertEquals("""
4232+
@startuml
4233+
title <size:24>System Landscape View</size>
4234+
4235+
set separator none
4236+
top to bottom direction
4237+
hide stereotype
4238+
4239+
skinparam {
4240+
linetype ortho
4241+
}
4242+
4243+
<style>
4244+
root {
4245+
BackgroundColor: #ffffff;
4246+
FontColor: #444444;
4247+
}
4248+
// Element
4249+
.Element-RWxlbWVudA== {
4250+
BackgroundColor: #ffffff;
4251+
LineColor: #444444;
4252+
LineStyle: 0;
4253+
LineThickness: 2;
4254+
FontColor: #444444;
4255+
FontSize: 24;
4256+
HorizontalAlignment: center;
4257+
Shadowing: 0;
4258+
MaximumWidth: 450;
4259+
}
4260+
</style>
4261+
4262+
rectangle "==A\\n<size:16>[Software System]</size>" <<Element-RWxlbWVudA==>> as A
4263+
4264+
@enduml""", diagram.getDefinition());
4265+
}
4266+
42194267
}

0 commit comments

Comments
 (0)