protected String backgroundOf(View view, Element element) { return view.getViewSet().getConfiguration().getStyles().findElementStyle(element).getBackground(); }
@Test public void test_copyConfigurationFrom() { Configuration source = new Configuration(); source.setLastSavedView("someKey"); Configuration destination = new Configuration(); destination.copyConfigurationFrom(source); assertEquals("someKey", destination.getLastSavedView()); }
@Test public void test_defaultView_DoesNothing_WhenPassedNull() { Configuration configuration = new Configuration(); configuration.setDefaultView((View)null); assertNull(configuration.getDefaultView()); }
public void copyConfigurationFrom(Configuration configuration) { setLastSavedView(configuration.getLastSavedView()); }
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![](embed:SystemContext)"); 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); }
if (remoteWorkspace != null) { workspace.getViews().copyLayoutInformationFrom(remoteWorkspace.getViews()); workspace.getViews().getConfiguration().copyConfigurationFrom(remoteWorkspace.getViews().getConfiguration());
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"; } }
@Test public void test_defaultView() { SystemLandscapeView view = views.createSystemLandscapeView("key", "Description"); Configuration configuration = new Configuration(); configuration.setDefaultView(view); assertEquals("key", configuration.getDefaultView()); }
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(); } }
format("%s -[%s]> %s : %s. %s", idOf(relationship.getRelationship().getSource()), view.getViewSet().getConfiguration().getStyles().findRelationshipStyle(relationship.getRelationship()).getColor(), idOf(relationship.getRelationship().getDestination()), relationship.getOrder(),
contextView.addAllPeople(); Styles styles = views.getConfiguration().getStyles(); styles.addElementStyle(Tags.PERSON).shape(Shape.Person);
contextView.addAllPeople(); Styles styles = views.getConfiguration().getStyles(); styles.addElementStyle(Tags.PERSON).shape(Shape.Person);
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()); }
dynamicView.add(vetRepository, "select * from vets", relationalDatabase); Styles styles = views.getConfiguration().getStyles(); styles.addElementStyle("Spring PetClinic").background("#6CB33E").color("#ffffff"); styles.addElementStyle(Tags.PERSON).background("#519823").color("#ffffff").shape(Shape.Person);
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); }
Model model = workspace.getModel(); ViewSet views = workspace.getViews(); Styles styles = views.getConfiguration().getStyles();