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; }
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_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()); }
format("%s -[%s]> %s : %s. %s", idOf(relationship.getRelationship().getSource()), view.getViewSet().getConfiguration().getStyles().findRelationshipStyle(relationship.getRelationship()).getColor(), idOf(relationship.getRelationship().getDestination()), relationship.getOrder(),
@Test public void test_findRelationshipStyle_ReturnsTheDefaultStyle_WhenPassedNull() { RelationshipStyle style = styles.findRelationshipStyle(null); assertEquals("#707070", style.getColor()); }
@Test public void test_findRelationshipStyle_ReturnsTheDefaultStyle_WhenNoStylesAreDefined() { SoftwareSystem element = model.addSoftwareSystem("Name", "Description"); Relationship relationship = element.uses(element, "Uses"); RelationshipStyle style = styles.findRelationshipStyle(relationship); assertEquals("#707070", 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()); }