Skip to content
This repository was archived by the owner on Mar 28, 2026. It is now read-only.

Commit a143f19

Browse files
Ensures that style properties are included when finding a style for an element/relationship.
1 parent 4015cf7 commit a143f19

3 files changed

Lines changed: 12 additions & 2 deletions

File tree

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -414,6 +414,10 @@ void copyFrom(ElementStyle elementStyle) {
414414
if (elementStyle.getDescription() != null) {
415415
this.setDescription(elementStyle.getDescription());
416416
}
417+
418+
for (String name : elementStyle.getProperties().keySet()) {
419+
this.addProperty(name, elementStyle.getProperties().get(name));
420+
}
417421
}
418422

419423
}

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,10 @@ void copyFrom(RelationshipStyle relationshipStyle) {
240240
if (relationshipStyle.getOpacity() != null) {
241241
this.setOpacity(relationshipStyle.getOpacity());
242242
}
243+
244+
for (String name : relationshipStyle.getProperties().keySet()) {
245+
this.addProperty(name, relationshipStyle.getProperties().get(name));
246+
}
243247
}
244248

245249
}

structurizr-core/test/unit/com/structurizr/view/StylesTests.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ void findElementStyle_ReturnsTheCorrectStyleForAnElementInstance_WhenStylesAreDe
8080
SoftwareSystemInstance softwareSystemInstance = deploymentNode.add(softwareSystem);
8181

8282
styles.addElementStyle(Tags.SOFTWARE_SYSTEM).background("#ff0000").color("#ffffff");
83-
styles.addElementStyle("Some Tag").color("#0000ff").stroke("#00ff00").shape(Shape.RoundedBox).width(123).height(456);
83+
styles.addElementStyle("Some Tag").color("#0000ff").stroke("#00ff00").shape(Shape.RoundedBox).width(123).height(456).addProperty("name", "value");
8484

8585
ElementStyle style = styles.findElementStyle(softwareSystemInstance);
8686
assertEquals(Integer.valueOf(123), style.getWidth());
@@ -96,6 +96,7 @@ void findElementStyle_ReturnsTheCorrectStyleForAnElementInstance_WhenStylesAreDe
9696
assertEquals(Integer.valueOf(100), style.getOpacity());
9797
assertEquals(true, style.getMetadata());
9898
assertEquals(true, style.getDescription());
99+
assertEquals("value", style.getProperties().get("name"));
99100
}
100101

101102
@Test
@@ -161,7 +162,7 @@ void findRelationshipStyle_ReturnsTheCorrectStyle_WhenStylesAreDefined() {
161162
relationship.addTags("Some Tag");
162163

163164
styles.addRelationshipStyle(Tags.RELATIONSHIP).color("#ff0000");
164-
styles.addRelationshipStyle("Some Tag").color("#0000ff");
165+
styles.addRelationshipStyle("Some Tag").color("#0000ff").addProperty("name", "value");
165166

166167
RelationshipStyle style = styles.findRelationshipStyle(relationship);
167168
assertEquals(Integer.valueOf(2), style.getThickness());
@@ -172,6 +173,7 @@ void findRelationshipStyle_ReturnsTheCorrectStyle_WhenStylesAreDefined() {
172173
assertEquals(Integer.valueOf(200), style.getWidth());
173174
assertEquals(Integer.valueOf(50), style.getPosition());
174175
assertEquals(Integer.valueOf(100), style.getOpacity());
176+
assertEquals("value", style.getProperties().get("name"));
175177
}
176178

177179
@Test

0 commit comments

Comments
 (0)