Skip to content

Commit

Permalink
Renamed borderColor to stroke.
Browse files Browse the repository at this point in the history
  • Loading branch information
simonbrowndotje committed Nov 20, 2019
1 parent f5a0c35 commit 25eba12
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 47 deletions.
50 changes: 25 additions & 25 deletions structurizr-core/src/com/structurizr/view/ElementStyle.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ public final class ElementStyle {
@JsonInclude(value = JsonInclude.Include.NON_NULL)
private String background;

@JsonInclude(value = JsonInclude.Include.NON_NULL)
private String stroke;

@JsonInclude(value = JsonInclude.Include.NON_NULL)
private String color;

Expand All @@ -37,9 +40,6 @@ public final class ElementStyle {
@JsonInclude(value = JsonInclude.Include.NON_NULL)
private Border border;

@JsonInclude(value = JsonInclude.Include.NON_NULL)
private String borderColor;

@JsonInclude(value = JsonInclude.Include.NON_NULL)
private Integer opacity;

Expand Down Expand Up @@ -141,6 +141,28 @@ public ElementStyle background(String background) {
return this;
}

/**
* Gets the stroke colour of the element, as a HTML RGB hex string (e.g. #123456).
*
* @return the stroke colour as a String, or null if not specified
*/
public String getStroke() {
return stroke;
}

public void setStroke(String color) {
if (Color.isHexColorCode(color)) {
this.stroke = color.toLowerCase();
} else {
throw new IllegalArgumentException(color + " is not a valid hex colour code.");
}
}

public ElementStyle stroke(String color) {
setStroke(color);
return this;
}

/**
* Gets the foreground (text) colour of the element, as a HTML RGB hex string (e.g. #123456).
*
Expand Down Expand Up @@ -241,28 +263,6 @@ public ElementStyle border(Border border) {
return this;
}

/**
* Gets the border colour of the element, as a HTML RGB hex string (e.g. #123456).
*
* @return the border colour as a String, or null if not specified
*/
public String getBorderColor() {
return borderColor;
}

public void setBorderColor(String color) {
if (Color.isHexColorCode(color)) {
this.borderColor = color.toLowerCase();
} else {
throw new IllegalArgumentException(color + " is not a valid hex colour code.");
}
}

public ElementStyle borderColor(String color) {
setBorderColor(color);
return this;
}

/**
* Gets the opacity used when rendering the element.
*
Expand Down
4 changes: 2 additions & 2 deletions structurizr-core/src/com/structurizr/view/Styles.java
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,8 @@ public ElementStyle findElementStyle(Element element) {
style.setColor(elementStyle.getColor());
}

if (!StringUtils.isNullOrEmpty(elementStyle.getBorderColor())) {
style.setBorderColor(elementStyle.getBorderColor());
if (!StringUtils.isNullOrEmpty(elementStyle.getStroke())) {
style.setStroke(elementStyle.getStroke());
}

if (elementStyle.getShape() != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,41 +167,41 @@ public void test_setIcon_DoesNothing_WhenAnEmptyUrlIsSpecified() {
}

@Test
public void test_setBorderColor_SetsTheBorderColorProperty_WhenAValidHexColorCodeIsSpecified() {
public void test_setStroke_SetsTheStrokeProperty_WhenAValidHexColorCodeIsSpecified() {
ElementStyle style = new ElementStyle();
style.setBorderColor("#ffffff");
assertEquals("#ffffff", style.getBorderColor());
style.setStroke("#ffffff");
assertEquals("#ffffff", style.getStroke());

style.setBorderColor("#FFFFFF");
assertEquals("#ffffff", style.getBorderColor());
style.setStroke("#FFFFFF");
assertEquals("#ffffff", style.getStroke());

style.setBorderColor("#123456");
assertEquals("#123456", style.getBorderColor());
style.setStroke("#123456");
assertEquals("#123456", style.getStroke());
}

@Test
public void test_borderColor_SetsTheBorderColorProperty_WhenAValidHexColorCodeIsSpecified() {
public void test_Stroke_SetsTheStrokeProperty_WhenAValidHexColorCodeIsSpecified() {
ElementStyle style = new ElementStyle();
style.borderColor("#ffffff");
assertEquals("#ffffff", style.getBorderColor());
style.stroke("#ffffff");
assertEquals("#ffffff", style.getStroke());

style.borderColor("#FFFFFF");
assertEquals("#ffffff", style.getBorderColor());
style.stroke("#FFFFFF");
assertEquals("#ffffff", style.getStroke());

style.borderColor("#123456");
assertEquals("#123456", style.getBorderColor());
style.stroke("#123456");
assertEquals("#123456", style.getStroke());
}

@Test(expected = IllegalArgumentException.class)
public void test_setBorderColor_ThrowsAnException_WhenAnInvalidHexColorCodeIsSpecified() {
public void test_setStroke_ThrowsAnException_WhenAnInvalidHexColorCodeIsSpecified() {
ElementStyle style = new ElementStyle();
style.setBorderColor("white");
style.setStroke("white");
}

@Test(expected = IllegalArgumentException.class)
public void test_borderColor_ThrowsAnException_WhenAnInvalidHexColorCodeIsSpecified() {
public void test_Stroke_ThrowsAnException_WhenAnInvalidHexColorCodeIsSpecified() {
ElementStyle style = new ElementStyle();
style.borderColor("white");
style.stroke("white");
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@ public void test_findElementStyle_ReturnsTheCorrectStyle_WhenStylesAreDefined()
element.addTags("Some Tag");

styles.addElementStyle(Tags.SOFTWARE_SYSTEM).background("#ff0000").color("#ffffff");
styles.addElementStyle("Some Tag").color("#0000ff").borderColor("#00ff00").shape(Shape.RoundedBox);
styles.addElementStyle("Some Tag").color("#0000ff").stroke("#00ff00").shape(Shape.RoundedBox);

ElementStyle style = styles.findElementStyle(element);
assertEquals("#ff0000", style.getBackground());
assertEquals("#0000ff", style.getColor());
assertEquals("#00ff00", style.getBorderColor());
assertEquals("#00ff00", style.getStroke());
assertEquals(Shape.RoundedBox, style.getShape());
}

Expand Down

0 comments on commit 25eba12

Please sign in to comment.