public RelationshipStyle findRelationshipStyle(Relationship relationship) { RelationshipStyle style = new RelationshipStyle("").color("#707070"); if (relationship != null) { for (String tag : relationship.getTagsAsSet()) { RelationshipStyle relationshipStyle = findRelationshipStyle(tag); if (relationshipStyle != null) { if (relationshipStyle.getColor() != null && relationshipStyle.getColor().trim().length() > 0) { style.setColor(relationshipStyle.getColor()); } } } } return style; }
public RelationshipStyle opacity(int opacity) { setOpacity(opacity); return this; }
public RelationshipStyle position(int position) { setPosition(position); return this; }
public RelationshipStyle addRelationshipStyle(String tag) { RelationshipStyle relationshipStyle = null; if (tag != null) { relationshipStyle = new RelationshipStyle(); relationshipStyle.setTag(tag); add(relationshipStyle); } return relationshipStyle; }
@Test(expected = IllegalArgumentException.class) public void test_setColor_ThrowsAnException_WhenAnInvalidHexColorCodeIsSpecified() { RelationshipStyle style = new RelationshipStyle(); style.setColor("white"); }
styles.addElementStyle(Tags.PERSON).width(550).background("#d46a6a").shape(Shape.Person); styles.addRelationshipStyle(Tags.RELATIONSHIP).thickness(4).dashed(false).fontSize(32).width(400); styles.addRelationshipStyle(Tags.SYNCHRONOUS).dashed(false); styles.addRelationshipStyle(Tags.ASYNCHRONOUS).dashed(true); styles.addRelationshipStyle(TAG_ALERT).color("#ff0000"); styles.addRelationshipStyle("Future State").opacity(30).dashed(true);
@Test public void test_color_SetsTheColorProperty_WhenAValidHexColorCodeIsSpecified() { RelationshipStyle style = new RelationshipStyle(); style.color("#ffffff"); assertEquals("#ffffff", style.getColor()); style.color("#FFFFFF"); assertEquals("#ffffff", style.getColor()); style.color("#123456"); assertEquals("#123456", style.getColor()); }
@Test public void test_setColor_SetsTheColorProperty_WhenAValidHexColorCodeIsSpecified() { RelationshipStyle style = new RelationshipStyle(); style.setColor("#ffffff"); assertEquals("#ffffff", style.getColor()); style.setColor("#FFFFFF"); assertEquals("#ffffff", style.getColor()); style.setColor("#123456"); assertEquals("#123456", style.getColor()); }
@Test public void test_findRelationshipStyle_ReturnsTheCorrectStyle_WhenStylesAreDefined() { SoftwareSystem element = model.addSoftwareSystem("Name", "Description"); Relationship relationship = element.uses(element, "Uses"); relationship.addTags("Some Tag"); styles.addRelationshipStyle(Tags.RELATIONSHIP).color("#ff0000"); styles.addRelationshipStyle("Some Tag").color("#0000ff"); RelationshipStyle style = styles.findRelationshipStyle(relationship); assertEquals("#0000ff", style.getColor()); }
@Test(expected = IllegalArgumentException.class) public void test_color_ThrowsAnException_WhenAnInvalidHexColorCodeIsSpecified() { RelationshipStyle style = new RelationshipStyle(); style.color("white"); }
@Test public void test_setPosition_SetsPosition_WhenANumberBetweenZeroAndOneHundredIsSpecified() { relationshipStyle.setPosition(0); assertEquals(new Integer(0), relationshipStyle.getPosition()); relationshipStyle.setPosition(1); assertEquals(new Integer(1), relationshipStyle.getPosition()); relationshipStyle.setPosition(50); assertEquals(new Integer(50), relationshipStyle.getPosition()); relationshipStyle.setPosition(99); assertEquals(new Integer(99), relationshipStyle.getPosition()); relationshipStyle.setPosition(100); assertEquals(new Integer(100), relationshipStyle.getPosition()); }
protected void writeRelationship(View view, Relationship relationship, Writer writer) { try { String stereotypeAndDescription = (hasValue(relationship.getTechnology()) ? "<<" + relationship.getTechnology() + ">>\\n" : "") + (hasValue(relationship.getDescription()) ? relationship.getDescription() : ""); writer.write( format("%s .[%s].> %s %s", idOf(relationship.getSource()), view.getViewSet().getConfiguration().getStyles().findRelationshipStyle(relationship).getColor(), idOf(relationship.getDestination()), hasValue(stereotypeAndDescription) ? ": " + stereotypeAndDescription : "" ) ); writer.write(System.lineSeparator()); } catch (IOException e) { e.printStackTrace(); } }
@Test public void test_setOpacity() { RelationshipStyle style = new RelationshipStyle(); assertNull(style.getOpacity()); style.setOpacity(-1); assertEquals(0, style.getOpacity().intValue()); style.setOpacity(0); assertEquals(0, style.getOpacity().intValue()); style.setOpacity(50); assertEquals(50, style.getOpacity().intValue()); style.setOpacity(100); assertEquals(100, style.getOpacity().intValue()); style.setOpacity(101); assertEquals(100, style.getOpacity().intValue()); }
@Test public void test_writeView_IncludesStyling_WhenStylesAreAdded() throws Exception { workspace = new Workspace("", ""); SoftwareSystem softwareSystem = workspace.getModel().addSoftwareSystem("My software system", ""); Person user = workspace.getModel().addPerson("A user", ""); user.uses(softwareSystem, "Uses"); workspace.getViews().createSystemContextView(softwareSystem, "key", "").addAllElements(); workspace.getViews().getConfiguration().getStyles().addElementStyle(Tags.SOFTWARE_SYSTEM).background("#ff0000"); workspace.getViews().getConfiguration().getStyles().addElementStyle(Tags.PERSON).background("#00ff00"); workspace.getViews().getConfiguration().getStyles().addRelationshipStyle(Tags.RELATIONSHIP).color("#0000ff"); plantUMLWriter.write(workspace, stringWriter); assertEquals("@startuml(id=key)" + System.lineSeparator() + "scale max 1999x1999" + System.lineSeparator() + "title My software system - System Context" + System.lineSeparator() + "" + System.lineSeparator() + "skinparam {" + System.lineSeparator() + " shadowing false" + System.lineSeparator() + " arrowColor #707070" + System.lineSeparator() + " actorBorderColor #707070" + System.lineSeparator() + " componentBorderColor #707070" + System.lineSeparator() + " rectangleBorderColor #707070" + System.lineSeparator() + " noteBackgroundColor #ffffff" + System.lineSeparator() + " noteBorderColor #707070" + System.lineSeparator() + "}" + System.lineSeparator() + "rectangle \"A user\" <<Person>> as 2 #00ff00" + System.lineSeparator() + "rectangle \"My software system\" <<Software System>> as 1 #ff0000" + System.lineSeparator() + "2 .[#0000ff].> 1 : Uses" + System.lineSeparator() + "@enduml" + System.lineSeparator(), stringWriter.toString()); }
@Test public void test_opacity() { RelationshipStyle style = new RelationshipStyle(); assertNull(style.getOpacity()); style.opacity(-1); assertEquals(0, style.getOpacity().intValue()); style.opacity(0); assertEquals(0, style.getOpacity().intValue()); style.opacity(50); assertEquals(50, style.getOpacity().intValue()); style.opacity(100); assertEquals(100, style.getOpacity().intValue()); style.opacity(101); assertEquals(100, style.getOpacity().intValue()); }
public RelationshipStyle(String tag, Integer thickness, String color, Boolean dashed, Routing routing, Integer fontSize, Integer width, Integer position) { this.tag = tag; this.thickness = thickness; setColor(color); this.dashed = dashed; this.routing = routing; this.fontSize = fontSize; this.width = width; this.position = position; }
views.getConfiguration().getStyles().add(new RelationshipStyle(Tags.RELATIONSHIP, 4, "#dddddd", true, Routing.Direct, 25, 300, null)); views.getConfiguration().getStyles().add(new RelationshipStyle("JDBC", 4, "#ff0000", true, Routing.Direct, 25, 300, null));
@Test public void test_setPosition_SetsPositionToNull_WhenNullIsSpecified() { relationshipStyle.setPosition(null); assertNull(relationshipStyle.getPosition()); }
format("%s -[%s]> %s : %s. %s", idOf(relationship.getRelationship().getSource()), view.getViewSet().getConfiguration().getStyles().findRelationshipStyle(relationship.getRelationship()).getColor(), idOf(relationship.getRelationship().getDestination()), relationship.getOrder(),