Skip to content

Commit a6e531f

Browse files
Adds support for icons to the Ilograph exporter (#332).
1 parent 2a8602d commit a6e531f

File tree

3 files changed

+23
-5
lines changed

3 files changed

+23
-5
lines changed

structurizr-export/src/main/java/com/structurizr/export/ilograph/IlographExporter.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
*/
1717
public class IlographExporter extends AbstractWorkspaceExporter {
1818

19+
public static final String ILOGRAPH_ICON = "ilograph.icon";
20+
1921
public WorkspaceExport export(Workspace workspace) {
2022
IndentingWriter writer = new IndentingWriter();
2123
writer.writeLine("resources:");
@@ -216,6 +218,15 @@ private void writeElement(IndentingWriter writer, Workspace workspace, Element e
216218
writer.writeLine(String.format("backgroundColor: \"%s\"", elementStyle.getBackground()));
217219
}
218220
writer.writeLine(String.format("color: \"%s\"", elementStyle.getColor()));
221+
222+
String icon = elementStyle.getProperties().get(ILOGRAPH_ICON);
223+
if (StringUtils.isNullOrEmpty(icon)) {
224+
icon = elementStyle.getIcon();
225+
}
226+
if (!StringUtils.isNullOrEmpty(icon)) {
227+
writer.writeLine(String.format("icon: \"%s\"", icon));
228+
}
229+
219230
writer.writeLine();
220231
writer.outdent();
221232
}

structurizr-export/src/test/java/com/structurizr/export/ilograph/54915.ilograph

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,27 +27,31 @@ resources:
2727
subtitle: "[Deployment Node]"
2828
backgroundColor: "#ffffff"
2929
color: "#232f3e"
30+
icon: "https://static.structurizr.com/themes/amazon-web-services-2020.04.30/[email protected]"
3031

3132
children:
3233
- id: "6"
3334
name: "US-East-1"
3435
subtitle: "[Deployment Node]"
3536
backgroundColor: "#ffffff"
3637
color: "#147eba"
38+
icon: "https://static.structurizr.com/themes/amazon-web-services-2020.04.30/[email protected]"
3739

3840
children:
3941
- id: "12"
4042
name: "Amazon RDS"
4143
subtitle: "[Deployment Node]"
4244
backgroundColor: "#ffffff"
4345
color: "#3b48cc"
46+
icon: "https://static.structurizr.com/themes/amazon-web-services-2020.04.30/[email protected]"
4447

4548
children:
4649
- id: "13"
4750
name: "MySQL"
4851
subtitle: "[Deployment Node]"
4952
backgroundColor: "#ffffff"
5053
color: "#3b48cc"
54+
icon: "https://static.structurizr.com/themes/amazon-web-services-2020.04.30/[email protected]"
5155

5256
children:
5357
- id: "14"
@@ -62,13 +66,15 @@ resources:
6266
subtitle: "[Deployment Node]"
6367
backgroundColor: "#ffffff"
6468
color: "#cc2264"
69+
icon: "https://static.structurizr.com/themes/amazon-web-services-2020.04.30/[email protected]"
6570

6671
children:
6772
- id: "10"
6873
name: "Amazon EC2"
6974
subtitle: "[Deployment Node]"
7075
backgroundColor: "#ffffff"
7176
color: "#d86613"
77+
icon: "https://static.structurizr.com/themes/amazon-web-services-2020.04.30/[email protected]"
7278

7379
children:
7480
- id: "11"
@@ -84,13 +90,15 @@ resources:
8490
description: "Highly available and scalable cloud DNS service."
8591
backgroundColor: "#ffffff"
8692
color: "#693cc5"
93+
icon: "AWS/Networking/Route-53.svg"
8794

8895
- id: "8"
8996
name: "Elastic Load Balancer"
9097
subtitle: "[Infrastructure Node]"
9198
description: "Automatically distributes incoming application traffic."
9299
backgroundColor: "#ffffff"
93100
color: "#693cc5"
101+
icon: "https://static.structurizr.com/themes/amazon-web-services-2020.04.30/[email protected]"
94102

95103
perspectives:
96104
- name: Static Structure

structurizr-export/src/test/java/com/structurizr/export/ilograph/IlographWriterTests.java renamed to structurizr-export/src/test/java/com/structurizr/export/ilograph/IlographExporterTests.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,18 @@
22

33
import com.structurizr.Workspace;
44
import com.structurizr.export.AbstractExporterTests;
5-
import com.structurizr.export.Diagram;
65
import com.structurizr.export.WorkspaceExport;
7-
import com.structurizr.export.dot.DOTExporter;
86
import com.structurizr.model.CustomElement;
97
import com.structurizr.model.Model;
108
import com.structurizr.util.WorkspaceUtils;
11-
import com.structurizr.view.CustomView;
129
import com.structurizr.view.ThemeUtils;
1310
import org.junit.jupiter.api.Test;
1411

1512
import java.io.File;
1613

17-
import static org.junit.jupiter.api.Assertions.*;
14+
import static org.junit.jupiter.api.Assertions.assertEquals;
1815

19-
public class IlographWriterTests extends AbstractExporterTests {
16+
public class IlographExporterTests extends AbstractExporterTests {
2017

2118
@Test
2219
public void test_BigBankPlcExample() throws Exception {
@@ -31,6 +28,8 @@ public void test_BigBankPlcExample() throws Exception {
3128
@Test
3229
public void test_AmazonWebServicesExample() throws Exception {
3330
Workspace workspace = WorkspaceUtils.loadWorkspaceFromJson(new File("./src/test/resources/structurizr-54915-workspace.json"));
31+
workspace.getViews().getConfiguration().getStyles().addElementStyle("Amazon Web Services - Route 53").addProperty(IlographExporter.ILOGRAPH_ICON, "AWS/Networking/Route-53.svg");
32+
3433
ThemeUtils.loadThemes(workspace);
3534
IlographExporter ilographExporter = new IlographExporter();
3635
WorkspaceExport export = ilographExporter.export(workspace);

0 commit comments

Comments
 (0)