@Test(expected = IllegalArgumentException.class) public void test_background_ThrowsAnException_WhenAnInvalidHexColorCodeIsSpecified() { ElementStyle style = new ElementStyle(); style.background("white"); }
@Test public void test_background_SetsTheBackgroundProperty_WhenAValidHexColorCodeIsSpecified() { ElementStyle style = new ElementStyle(); style.background("#ffffff"); assertEquals("#ffffff", style.getBackground()); style.background("#FFFFFF"); assertEquals("#ffffff", style.getBackground()); style.background("#123456"); assertEquals("#123456", style.getBackground()); }
public ElementStyle findElementStyle(Element element) { ElementStyle style = new ElementStyle("").background("#dddddd").color("#000000").shape(Shape.Box); if (element != null) { for (String tag : element.getTagsAsSet()) { ElementStyle elementStyle = findElementStyle(tag); if (elementStyle != null) { if (elementStyle.getBackground() != null && elementStyle.getBackground().trim().length() > 0) { style.setBackground(elementStyle.getBackground()); } if (elementStyle.getColor() != null && elementStyle.getColor().trim().length() > 0) { style.setColor(elementStyle.getColor()); } if (elementStyle.getShape() != null) { style.setShape(elementStyle.getShape()); } } } } return style; }
public static void main(String[] args) throws Exception { Workspace workspace = new Workspace("Getting Started", "This is a model of my software system."); Model model = workspace.getModel(); Person user = model.addPerson("User", "A user of my software system."); SoftwareSystem softwareSystem = model.addSoftwareSystem("Software System", "My software system."); user.uses(softwareSystem, "Uses"); ViewSet views = workspace.getViews(); SystemContextView contextView = views.createSystemContextView(softwareSystem, "SystemContext", "An example of a System Context diagram."); contextView.addAllSoftwareSystems(); contextView.addAllPeople(); Styles styles = views.getConfiguration().getStyles(); styles.addElementStyle(Tags.SOFTWARE_SYSTEM).background("#1168bd").color("#ffffff"); styles.addElementStyle(Tags.PERSON).background("#08427b").color("#ffffff").shape(Shape.Person); PlantUMLWriter plantUMLWriter = new PlantUMLWriter(); // if you're using dark background colours, you might need to explicitly set the foreground colour using skin params // e.g. rectangleFontColor, rectangleFontColor<<Software System>>, etc plantUMLWriter.addSkinParam("rectangleFontColor", "#ffffff"); plantUMLWriter.addSkinParam("rectangleStereotypeFontColor", "#ffffff"); // write to a specific writer StringWriter stringWriter = new StringWriter(); plantUMLWriter.write(workspace, stringWriter); System.out.println(stringWriter.toString()); // or just output directly to stdout // plantUMLWriter.toStdOut(workspace); }
styles.addElementStyle("Spring PetClinic").background("#6CB33E").color("#ffffff"); styles.addElementStyle(Tags.PERSON).background("#519823").color("#ffffff").shape(Shape.Person); styles.addElementStyle(Tags.CONTAINER).background("#91D366").color("#ffffff"); styles.addElementStyle("Database").shape(Shape.Cylinder); styles.addElementStyle("Spring MVC Controller").background("#D4F3C0").color("#000000"); styles.addElementStyle("Spring Service").background("#6CB33E").color("#000000"); styles.addElementStyle("Spring Repository").background("#95D46C").color("#000000");
@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()); }
public static void main(String[] args) throws Exception { // all software architecture models belong to a workspace Workspace workspace = new Workspace("Getting Started", "This is a model of my software system."); Model model = workspace.getModel(); // create a model to describe a user using a software system Person user = model.addPerson("User", "A user of my software system."); SoftwareSystem softwareSystem = model.addSoftwareSystem("Software System", "My software system."); user.uses(softwareSystem, "Uses"); // create a system context diagram showing people and software systems ViewSet views = workspace.getViews(); SystemContextView contextView = views.createSystemContextView(softwareSystem, "SystemContext", "An example of a System Context diagram."); contextView.addAllSoftwareSystems(); contextView.addAllPeople(); // add some styling to the diagram elements Styles styles = views.getConfiguration().getStyles(); styles.addElementStyle(Tags.SOFTWARE_SYSTEM).background("#1168bd").color("#ffffff"); styles.addElementStyle(Tags.PERSON).background("#08427b").color("#ffffff").shape(Shape.Person); // upload to structurizr.com (you'll need your own workspace ID, API key and API secret) StructurizrClient structurizrClient = new StructurizrClient(API_KEY, API_SECRET); structurizrClient.putWorkspace(WORKSPACE_ID, workspace); }
public static void main(String[] args) throws Exception { Workspace workspace = new Workspace("Client-side encrypted workspace", "This is a client-side encrypted workspace. The passphrase is 'password'."); Model model = workspace.getModel(); Person user = model.addPerson("User", "A user of my software system."); SoftwareSystem softwareSystem = model.addSoftwareSystem("Software System", "My software system."); user.uses(softwareSystem, "Uses"); ViewSet views = workspace.getViews(); SystemContextView contextView = views.createSystemContextView(softwareSystem, "SystemContext", "An example of a System Context diagram."); contextView.addAllSoftwareSystems(); contextView.addAllPeople(); Styles styles = views.getConfiguration().getStyles(); styles.addElementStyle(Tags.SOFTWARE_SYSTEM).background("#d34407").color("#ffffff"); styles.addElementStyle(Tags.PERSON).background("#f86628").color("#ffffff").shape(Shape.Person); StructurizrClient structurizrClient = new StructurizrClient(API_KEY, API_SECRET); structurizrClient.setEncryptionStrategy(new AesEncryptionStrategy("password")); structurizrClient.putWorkspace(WORKSPACE_ID, workspace); }
styles.addElementStyle(Tags.SOFTWARE_SYSTEM).background("#1168bd"); styles.addElementStyle(Tags.CONTAINER).background("#438dd5"); styles.addElementStyle(Tags.COMPONENT).background("#85bbf0").color("#000000"); styles.addElementStyle(Tags.PERSON).background("#08427b").shape(Shape.Person); styles.addElementStyle(DATABASE_TAG).shape(Shape.Cylinder);
styles.addElementStyle("Spring PetClinic").background("#6CB33E").color("#ffffff"); styles.addElementStyle(Tags.PERSON).background("#519823").color("#ffffff").shape(Shape.Person); styles.addElementStyle(Tags.CONTAINER).background("#91D366").color("#ffffff"); styles.addElementStyle("Database").shape(Shape.Cylinder); styles.addElementStyle("Spring MVC Controller").background("#D4F3C0").color("#000000"); styles.addElementStyle("Spring Service").background("#6CB33E").color("#000000"); styles.addElementStyle("Spring Repository").background("#95D46C").color("#000000"); styles.addElementStyle("Failover").opacity(25); styles.addRelationshipStyle("Failover").opacity(25).position(70);
user.uses(softwareSystem, "Uses"); workspace.getViews().createSystemContextView(softwareSystem, "thekey", "").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");
styles.addElementStyle(EXTERNAL_TAG).background("#EC5381").border(Border.Dashed); styles.addElementStyle(INTERNAL_TAG).background("#B60037");
styles.addElementStyle(Tags.SOFTWARE_SYSTEM).background("#18ADAD").color("#ffffff"); styles.addElementStyle(Tags.PERSON).shape(Shape.Person).background("#008282").color("#ffffff"); styles.addElementStyle(Tags.CONTAINER).background("#6DBFBF"); styles.addElementStyle(FILE_SYSTEM_TAG).shape(Shape.Folder);
public static void main(String[] args) throws Exception { Workspace workspace = new Workspace("Filtered Views", "An example of using filtered views."); Model model = workspace.getModel(); Person user = model.addPerson("User", "A description of the user."); SoftwareSystem softwareSystemA = model.addSoftwareSystem("Software System A", "A description of software system A."); SoftwareSystem softwareSystemB = model.addSoftwareSystem("Software System B", "A description of software system B."); softwareSystemB.addTags(FUTURE_STATE); user.uses(softwareSystemA, "Uses for tasks 1 and 2").addTags(CURRENT_STATE); user.uses(softwareSystemA, "Uses for task 1").addTags(FUTURE_STATE); user.uses(softwareSystemB, "Uses for task 2").addTags(FUTURE_STATE); ViewSet views = workspace.getViews(); SystemLandscapeView systemLandscapeView = views.createSystemLandscapeView("SystemLandscape", "An example System Landscape diagram."); systemLandscapeView.addAllElements(); views.createFilteredView(systemLandscapeView, "CurrentState", "The current system landscape.", FilterMode.Exclude, FUTURE_STATE); views.createFilteredView(systemLandscapeView, "FutureState", "The future state system landscape after Software System B is live.", FilterMode.Exclude, CURRENT_STATE); Styles styles = views.getConfiguration().getStyles(); styles.addElementStyle(Tags.ELEMENT).color("#ffffff"); styles.addElementStyle(Tags.SOFTWARE_SYSTEM).background("#91a437").shape(Shape.RoundedBox); styles.addElementStyle(Tags.PERSON).background("#6a7b15").shape(Shape.Person); StructurizrClient structurizrClient = new StructurizrClient(API_KEY, API_SECRET); structurizrClient.putWorkspace(WORKSPACE_ID, workspace); }
styles.addElementStyle("Risk System").background("#550000").color("#ffffff"); styles.addElementStyle(Tags.SOFTWARE_SYSTEM).width(650).height(400).background("#801515").shape(Shape.RoundedBox); styles.addElementStyle(Tags.PERSON).width(550).background("#d46a6a").shape(Shape.Person);
@Test public void test_findElementStyle_ReturnsTheCorrectStyle_WhenStylesAreDefined() { SoftwareSystem element = model.addSoftwareSystem("Name", "Description"); element.addTags("Some Tag"); styles.addElementStyle(Tags.SOFTWARE_SYSTEM).background("#ff0000").color("#ffffff"); styles.addElementStyle("Some Tag").color("#0000ff").shape(Shape.RoundedBox); ElementStyle style = styles.findElementStyle(element); assertEquals("#ff0000", style.getBackground()); assertEquals("#0000ff", style.getColor()); assertEquals(Shape.RoundedBox, style.getShape()); }
styles.addElementStyle(Tags.PERSON).background("#ffbf00").shape(Shape.Person); styles.addElementStyle(Tags.CONTAINER).background("#facc2E"); styles.addElementStyle(MESSAGE_BUS_TAG).width(1600).shape(Shape.Pipe); styles.addElementStyle(MICROSERVICE_TAG).shape(Shape.Hexagon); styles.addElementStyle(DATASTORE_TAG).background("#f5da81").shape(Shape.Cylinder); styles.addRelationshipStyle(Tags.RELATIONSHIP).routing(Routing.Orthogonal);
styles.addElementStyle(Tags.SOFTWARE_SYSTEM).background("#1168bd"); styles.addElementStyle(Tags.CONTAINER).background("#438dd5"); styles.addElementStyle(Tags.COMPONENT).background("#85bbf0").color("#000000"); styles.addElementStyle(Tags.PERSON).background("#08427b").shape(Shape.Person).fontSize(22); styles.addElementStyle(EXISTING_SYSTEM_TAG).background("#999999"); styles.addElementStyle(BANK_STAFF_TAG).background("#999999"); styles.addElementStyle(WEB_BROWSER_TAG).shape(Shape.WebBrowser); styles.addElementStyle(MOBILE_APP_TAG).shape(Shape.MobileDeviceLandscape);
styles.addElementStyle(Tags.ELEMENT).color("#ffffff").background("#438dd5").fontSize(34).width(650).height(400); styles.addElementStyle("Box").shape(Shape.Box); styles.addElementStyle("RoundedBox").shape(Shape.RoundedBox);