Skip to content

Commit bb2428a

Browse files
*PlantUML exporters: replaces skinparams with styles + adds support for dark mode exports.
1 parent b40cdfe commit bb2428a

File tree

103 files changed

+8143
-6635
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

103 files changed

+8143
-6635
lines changed

changelog.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
- structurizr-dsl: Constants and variables are inherited when extending a DSL workspace.
1919
- structurizr-dsl: DSL source is only stored in the JSON workspace when the DSL is deemed as "portable" (i.e. no files, plugins, scripts).
2020
- structurizr-export: Removes support for deprecated enterprise and location concepts.
21+
- structurizr-export: PlantUML exporters - replaces skinparams with styles.
22+
- structurizr-export: PlantUML exporters - adds support for dark mode exports.
2123
- structurizr-import: Adds support for `plantuml.inline`, `mermaid.inline`, `kroki.inline`, and `image.inline` properties to inline the resulting PNG/SVG file into the workspace.
2224
- structurizr-inspection: Adds a way to disable inspections via a workspace property named `structurizr.inspection` (`false` to disable).
2325
- structurizr-inspection: Default inspector adds a summary of error/warning/info/ignore counts as workspace properties.

structurizr-autolayout/src/test/java/com/structurizr/autolayout/graphviz/DOTExporterTests.java

Lines changed: 186 additions & 171 deletions
Large diffs are not rendered by default.

structurizr-autolayout/src/test/java/com/structurizr/autolayout/graphviz/GraphvizAutomaticLayoutTests.java

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import com.structurizr.view.AutomaticLayout;
99
import com.structurizr.view.Shape;
1010
import com.structurizr.view.SystemContextView;
11+
import com.structurizr.view.SystemLandscapeView;
1112
import org.junit.jupiter.api.Test;
1213

1314
import java.io.File;
@@ -22,36 +23,36 @@ public void apply_Workspace() throws Exception {
2223
File tempDir = Files.createTempDirectory("graphviz").toFile();
2324
GraphvizAutomaticLayout graphviz = new GraphvizAutomaticLayout(tempDir);
2425

25-
Workspace workspace = new Workspace("Name", "");
26-
Person user = workspace.getModel().addPerson("User");
27-
SoftwareSystem softwareSystem = workspace.getModel().addSoftwareSystem("Software System");
28-
user.uses(softwareSystem, "Uses");
26+
Workspace workspace = new Workspace("Name");
27+
SoftwareSystem a = workspace.getModel().addSoftwareSystem("A");
28+
SoftwareSystem b = workspace.getModel().addSoftwareSystem("B");
29+
a.uses(b, "Uses");
2930

30-
SystemContextView view = workspace.getViews().createSystemContextView(softwareSystem, "SystemContext", "");
31+
SystemLandscapeView view = workspace.getViews().createSystemLandscapeView("key");
3132
view.addAllElements();
3233

3334
workspace.getViews().getConfiguration().getStyles().addElementStyle(Tags.PERSON).shape(Shape.Person);
3435

35-
assertEquals(0, view.getElementView(user).getX());
36-
assertEquals(0, view.getElementView(user).getY());
37-
assertEquals(0, view.getElementView(softwareSystem).getX());
38-
assertEquals(0, view.getElementView(softwareSystem).getY());
36+
assertEquals(0, view.getElementView(a).getX());
37+
assertEquals(0, view.getElementView(a).getY());
38+
assertEquals(0, view.getElementView(b).getX());
39+
assertEquals(0, view.getElementView(b).getY());
3940

4041
graphviz.apply(workspace);
4142

4243
// no change - the view doesn't have automatic layout configured
43-
assertEquals(0, view.getElementView(user).getX());
44-
assertEquals(0, view.getElementView(user).getY());
45-
assertEquals(0, view.getElementView(softwareSystem).getX());
46-
assertEquals(0, view.getElementView(softwareSystem).getY());
44+
assertEquals(0, view.getElementView(a).getX());
45+
assertEquals(0, view.getElementView(a).getY());
46+
assertEquals(0, view.getElementView(b).getX());
47+
assertEquals(0, view.getElementView(b).getY());
4748

4849
view.enableAutomaticLayout(AutomaticLayout.RankDirection.TopBottom);
4950
graphviz.apply(workspace);
5051

51-
assertEquals(233, view.getElementView(user).getX());
52-
assertEquals(208, view.getElementView(user).getY());
53-
assertEquals(208, view.getElementView(softwareSystem).getX());
54-
assertEquals(908, view.getElementView(softwareSystem).getY());
52+
assertEquals(208, view.getElementView(a).getX());
53+
assertEquals(208, view.getElementView(a).getY());
54+
assertEquals(208, view.getElementView(b).getX());
55+
assertEquals(808, view.getElementView(b).getY());
5556
}
5657

5758
}

structurizr-core/src/main/java/com/structurizr/view/AbstractStyle.java

Lines changed: 52 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,43 @@
11
package com.structurizr.view;
22

33
import com.structurizr.PropertyHolder;
4+
import com.structurizr.util.StringUtils;
45

56
import java.util.Collections;
67
import java.util.HashMap;
78
import java.util.Map;
89

9-
public abstract class AbstractStyle implements PropertyHolder {
10+
public abstract class AbstractStyle implements PropertyHolder, Comparable<AbstractStyle> {
1011

12+
private String tag;
1113
private ColorScheme colorScheme = null;
12-
1314
private Map<String, String> properties = new HashMap<>();
1415

16+
AbstractStyle() {
17+
}
18+
19+
AbstractStyle(String tag) {
20+
this.tag = tag;
21+
}
22+
23+
AbstractStyle(String tag, ColorScheme colorScheme) {
24+
this.tag = tag;
25+
this.colorScheme = colorScheme;
26+
}
27+
28+
/**
29+
* The tag to which this style applies.
30+
*
31+
* @return the tag, as a String
32+
*/
33+
public String getTag() {
34+
return tag;
35+
}
36+
37+
void setTag(String tag) {
38+
this.tag = tag;
39+
}
40+
1541
/**
1642
* Gets the color scheme of this style.
1743
*
@@ -46,11 +72,11 @@ public Map<String, String> getProperties() {
4672
* @param value the value of the property
4773
*/
4874
public void addProperty(String name, String value) {
49-
if (name == null || name.trim().length() == 0) {
75+
if (StringUtils.isNullOrEmpty(name)) {
5076
throw new IllegalArgumentException("A property name must be specified.");
5177
}
5278

53-
if (value == null || value.trim().length() == 0) {
79+
if (StringUtils.isNullOrEmpty(value)) {
5480
throw new IllegalArgumentException("A property value must be specified.");
5581
}
5682

@@ -63,4 +89,26 @@ void setProperties(Map<String, String> properties) {
6389
}
6490
}
6591

92+
@Override
93+
public String toString() {
94+
return this.tag + " (" + this.colorScheme + ")";
95+
}
96+
97+
@Override
98+
public int compareTo(AbstractStyle other) {
99+
if (this.colorScheme == null && other.colorScheme == null) {
100+
return this.tag.compareTo(other.tag);
101+
}
102+
103+
if (this.colorScheme == null) {
104+
return -1;
105+
}
106+
107+
if (other.colorScheme == null) {
108+
return 1;
109+
}
110+
111+
return (this.colorScheme + "/" + this.tag).compareTo(other.colorScheme + "/" + other.tag);
112+
}
113+
66114
}

structurizr-core/src/main/java/com/structurizr/view/ElementStyle.java

Lines changed: 9 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@ public final class ElementStyle extends AbstractStyle {
1212
public static final int DEFAULT_WIDTH = 450;
1313
public static final int DEFAULT_HEIGHT = 300;
1414

15-
private String tag;
16-
1715
@JsonInclude(value = JsonInclude.Include.NON_NULL)
1816
private Integer width;
1917

@@ -59,21 +57,21 @@ public final class ElementStyle extends AbstractStyle {
5957
ElementStyle() {
6058
}
6159

62-
ElementStyle(String tag) {
63-
this.tag = tag;
60+
public ElementStyle(String tag) {
61+
super(tag);
6462
}
6563

6664
ElementStyle(String tag, ColorScheme colorScheme) {
67-
this.tag = tag;
68-
setColorScheme(colorScheme);
65+
super(tag, colorScheme);
6966
}
7067

7168
public ElementStyle(String tag, Integer width, Integer height, String background, String color, Integer fontSize) {
7269
this(tag, width, height, background, color, fontSize, null);
7370
}
7471

7572
public ElementStyle(String tag, Integer width, Integer height, String background, String color, Integer fontSize, Shape shape) {
76-
this.tag = tag;
73+
super(tag);
74+
7775
this.width = width;
7876
this.height = height;
7977
setBackground(background);
@@ -82,19 +80,6 @@ public ElementStyle(String tag, Integer width, Integer height, String background
8280
this.shape = shape;
8381
}
8482

85-
/**
86-
* The tag to which this element style applies.
87-
*
88-
* @return the tag, as a String
89-
*/
90-
public String getTag() {
91-
return tag;
92-
}
93-
94-
public void setTag(String tag) {
95-
this.tag = tag;
96-
}
97-
9883
/**
9984
* Gets the width of the element, in pixels.
10085
*
@@ -443,6 +428,10 @@ void copyFrom(ElementStyle elementStyle) {
443428
this.setIcon(elementStyle.getIcon());
444429
}
445430

431+
if (elementStyle.getIconPosition() != null) {
432+
this.setIconPosition(elementStyle.getIconPosition());
433+
}
434+
446435
if (elementStyle.getBorder() != null) {
447436
this.setBorder(elementStyle.getBorder());
448437
}

structurizr-core/src/main/java/com/structurizr/view/RelationshipStyle.java

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,6 @@ public final class RelationshipStyle extends AbstractStyle {
88
private static final int START_OF_LINE = 0;
99
private static final int END_OF_LINE = 100;
1010

11-
/** the name of the tag to which this style applies */
12-
private String tag;
13-
1411
/** the thickness of the line, in pixels */
1512
@JsonInclude(value = JsonInclude.Include.NON_NULL)
1613
private Integer thickness;
@@ -54,21 +51,12 @@ public final class RelationshipStyle extends AbstractStyle {
5451
RelationshipStyle() {
5552
}
5653

57-
RelationshipStyle(String tag) {
58-
this.tag = tag;
54+
public RelationshipStyle(String tag) {
55+
super(tag);
5956
}
6057

6158
RelationshipStyle(String tag, ColorScheme colorScheme) {
62-
this.tag = tag;
63-
setColorScheme(colorScheme);
64-
}
65-
66-
public String getTag() {
67-
return tag;
68-
}
69-
70-
public void setTag(String tag) {
71-
this.tag = tag;
59+
super(tag, colorScheme);
7260
}
7361

7462
public Integer getThickness() {
@@ -253,6 +241,10 @@ void copyFrom(RelationshipStyle relationshipStyle) {
253241
this.setRouting(relationshipStyle.getRouting());
254242
}
255243

244+
if (relationshipStyle.getJump() != null) {
245+
this.setJump(relationshipStyle.getJump());
246+
}
247+
256248
if (relationshipStyle.getFontSize() != null) {
257249
this.setFontSize(relationshipStyle.getFontSize());
258250
}

0 commit comments

Comments
 (0)