protected String backgroundOf(View view, Element element) { return view.getViewSet().getConfiguration().getStyles().findElementStyle(element).getBackground(); }
protected String plantumlType(View view, Element element) { Shape shape = view.getViewSet().getConfiguration().getStyles().findElementStyle(element).getShape(); switch(shape) { case Box: return element instanceof Component ? "component" : "rectangle"; case Person: return "actor"; case Cylinder: return "database"; case Folder: return "folder"; case Ellipse: case Circle: return "storage"; default: return "rectangle"; } }
protected String plantumlSequenceType(View view, Element element) { Shape shape = view.getViewSet().getConfiguration().getStyles().findElementStyle(element).getShape(); switch(shape) { case Box: return "participant"; case Person: return "actor"; case Cylinder: return "database"; case Folder: return "collections"; case Ellipse: case Circle: return "entity"; default: return "participant"; } }
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(); } }
contextView.addAllPeople(); Styles styles = views.getConfiguration().getStyles(); styles.addElementStyle(Tags.PERSON).shape(Shape.Person);
@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 { Workspace workspace = new Workspace("Corporate Branding", "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.PERSON).shape(Shape.Person); StructurizrDocumentationTemplate template = new StructurizrDocumentationTemplate(workspace); template.addContextSection(softwareSystem, Format.Markdown, "Here is some context about the software system...\n\n"); Branding branding = views.getConfiguration().getBranding(); branding.setLogo(ImageUtils.getImageAsDataUri(new File("./docs/images/structurizr-logo.png"))); 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("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); }
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");
public static void main(String[] args) throws Exception { Workspace workspace = new Workspace("Documentation - Automatic", "An empty software architecture document using the Structurizr template."); Model model = workspace.getModel(); ViewSet views = workspace.getViews(); Person user = model.addPerson("User", "A user of my software system."); SoftwareSystem softwareSystem = model.addSoftwareSystem("Software System", "My software system."); user.uses(softwareSystem, "Uses"); 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.PERSON).shape(Shape.Person); // this directory includes a mix of Markdown and AsciiDoc files File documentationRoot = new File("./structurizr-examples/src/com/structurizr/example/documentation/automatic"); AutomaticDocumentationTemplate template = new AutomaticDocumentationTemplate(workspace); template.addSections(softwareSystem, documentationRoot); 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("HTTP-based health checks example", "An example of how to use the HTTP-based health checks feature"); Model model = workspace.getModel(); ViewSet views = workspace.getViews(); SoftwareSystem structurizr = model.addSoftwareSystem("Structurizr", "A publishing platform for software architecture diagrams and documentation based upon the C4 model."); Container webApplication = structurizr.addContainer("structurizr.com", "Provides all of the server-side functionality of Structurizr, serving static and dynamic content to users.", "Java and Spring MVC"); Container database = structurizr.addContainer("Database", "Stores information about users, workspaces, etc.", "Relational Database Schema"); database.addTags(DATABASE_TAG); webApplication.uses(database, "Reads from and writes to", "JDBC"); DeploymentNode amazonWebServices = model.addDeploymentNode("Amazon Web Services", "", "us-east-1"); DeploymentNode pivotalWebServices = amazonWebServices.addDeploymentNode("Pivotal Web Services", "Platform as a Service provider.", "Cloud Foundry"); ContainerInstance liveWebApplication = pivotalWebServices.addDeploymentNode("www.structurizr.com", "An open source Java EE web server.", "Apache Tomcat") .add(webApplication); ContainerInstance liveDatabaseInstance = amazonWebServices.addDeploymentNode("Amazon RDS", "Database as a Service provider.", "MySQL") .add(database); // add health checks to the container instances, which return a simple HTTP 200 to say everything is okay liveWebApplication.addHealthCheck("Web Application is running", "https://www.structurizr.com/health"); liveDatabaseInstance.addHealthCheck("Database is accessible from Web Application", "https://www.structurizr.com/health/database"); // the pass/fail status from the health checks is used to supplement any deployment views that include the container instances that have health checks defined DeploymentView deploymentView = views.createDeploymentView(structurizr, "Deployment", "A deployment diagram showing the live environment."); deploymentView.setEnvironment("Live"); deploymentView.addAllDeploymentNodes(); views.getConfiguration().getStyles().addElementStyle(Tags.ELEMENT).color("#ffffff"); views.getConfiguration().getStyles().addElementStyle(DATABASE_TAG).shape(Shape.Cylinder); 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("Styling Relationships", "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."); Container webApplication = softwareSystem.addContainer("Web Application", "My web application.", "Java and Spring MVC"); Container database = softwareSystem.addContainer("Database", "My database.", "Relational database schema"); user.uses(webApplication, "Uses", "HTTPS"); webApplication.uses(database, "Reads from and writes to", "JDBC"); ViewSet views = workspace.getViews(); ContainerView containerView = views.createContainerView(softwareSystem, "containers", "An example of a container diagram."); containerView.addAllElements(); Styles styles = workspace.getViews().getConfiguration().getStyles(); // example 1 // styles.addRelationshipStyle(Tags.RELATIONSHIP).color("#ff0000"); // example 2 // model.getRelationships().stream().filter(r -> "HTTPS".equals(r.getTechnology())).forEach(r -> r.addTags("HTTPS")); // model.getRelationships().stream().filter(r -> "JDBC".equals(r.getTechnology())).forEach(r -> r.addTags("JDBC")); // styles.addRelationshipStyle("HTTPS").color("#ff0000"); // styles.addRelationshipStyle("JDBC").color("#0000ff"); StructurizrClient structurizrClient = new StructurizrClient(API_KEY, API_SECRET); structurizrClient.putWorkspace(WORKSPACE_ID, workspace); }
containerView.addAllElements(); Styles styles = workspace.getViews().getConfiguration().getStyles();
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); }
componentView.addAllComponents(); views.getConfiguration().getStyles().add(new ElementStyle(Tags.ELEMENT, 600, 450, "#dddddd", "#000000", 30)); views.getConfiguration().getStyles().add(new ElementStyle("Internal", null, null, "#041F37", "#ffffff", null)); 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));
adrToolsImporter.importArchitectureDecisionRecords(adrTools); Styles styles = views.getConfiguration().getStyles(); styles.addElementStyle(Tags.ELEMENT).shape(Shape.RoundedBox).color("#ffffff"); styles.addElementStyle(Tags.SOFTWARE_SYSTEM).background("#18ADAD").color("#ffffff");
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); }
componentView.addAllElements(); Styles styles = views.getConfiguration().getStyles(); styles.addElementStyle(Tags.ELEMENT).color("#ffffff"); styles.addElementStyle(Tags.SOFTWARE_SYSTEM).background("#1168bd");
view.setPaperSize(PaperSize.A5_Landscape); Styles styles = views.getConfiguration().getStyles();