Search in sources :

Example 1 with PlantUMLWriter

use of com.structurizr.io.plantuml.PlantUMLWriter in project tutorials by eugenp.

the class StructurizrSimple method exportToPlantUml.

private static void exportToPlantUml(View view) throws WorkspaceWriterException {
    StringWriter stringWriter = new StringWriter();
    PlantUMLWriter plantUMLWriter = new PlantUMLWriter();
    plantUMLWriter.write(view, stringWriter);
    System.out.println(stringWriter.toString());
}
Also used : StringWriter(java.io.StringWriter) PlantUMLWriter(com.structurizr.io.plantuml.PlantUMLWriter)

Example 2 with PlantUMLWriter

use of com.structurizr.io.plantuml.PlantUMLWriter in project cia by Hack23.

the class AppPublicSystemDocumentation method printPlantUml.

/**
 * Prints the plant uml.
 *
 * @param workspace
 *            the workspace
 * @throws WorkspaceWriterException
 *             the workspace writer exception
 * @throws IOException
 *             Signals that an I/O exception has occurred.
 * @throws InterruptedException
 *             the interrupted exception
 */
private static void printPlantUml(final Workspace workspace) throws WorkspaceWriterException, IOException, InterruptedException {
    final StringWriter stringWriter = new StringWriter();
    final PlantUMLWriter plantUMLWriter = new BasicPlantUMLWriter();
    // plantUMLWriter.setSizeLimit(16384);
    plantUMLWriter.write(workspace, stringWriter);
    String allPlantUmlsString = stringWriter.toString();
    final String systemUml2 = allPlantUmlsString.substring(allPlantUmlsString.lastIndexOf("@startuml"), allPlantUmlsString.lastIndexOf("@enduml") + "@enduml".length());
    allPlantUmlsString = allPlantUmlsString.replace(systemUml2, "");
    writePlantUml("Citizen-Intelligence-Agency-System-System-Deployment", systemUml2);
    final String componentUml = allPlantUmlsString.substring(allPlantUmlsString.lastIndexOf("@startuml"), allPlantUmlsString.lastIndexOf("@enduml") + "@enduml".length());
    allPlantUmlsString = allPlantUmlsString.replace(componentUml, "");
    writePlantUml("Citizen-Intelligence-Agency-System-Web-Application-Components", componentUml);
    final String containersUml = allPlantUmlsString.substring(allPlantUmlsString.lastIndexOf("@startuml"), allPlantUmlsString.lastIndexOf("@enduml") + "@enduml".length());
    allPlantUmlsString = allPlantUmlsString.replace(containersUml, "");
    writePlantUml("Citizen-Intelligence-Agency-System-Containers", containersUml);
    final String systemUml = allPlantUmlsString.substring(allPlantUmlsString.lastIndexOf("@startuml"), allPlantUmlsString.lastIndexOf("@enduml") + "@enduml".length());
    allPlantUmlsString = allPlantUmlsString.replace(systemUml, "");
    writePlantUml("Citizen-Intelligence-Agency-System-System-Context", systemUml);
    final String enterpriseUml = allPlantUmlsString.substring(allPlantUmlsString.lastIndexOf("@startuml"), allPlantUmlsString.lastIndexOf("@enduml") + "@enduml".length());
    allPlantUmlsString = allPlantUmlsString.replace(enterpriseUml, "");
    writePlantUml("Enterprise-Context-for-Hack23", enterpriseUml);
}
Also used : StringWriter(java.io.StringWriter) BasicPlantUMLWriter(com.structurizr.io.plantuml.BasicPlantUMLWriter) BasicPlantUMLWriter(com.structurizr.io.plantuml.BasicPlantUMLWriter) PlantUMLWriter(com.structurizr.io.plantuml.PlantUMLWriter)

Example 3 with PlantUMLWriter

use of com.structurizr.io.plantuml.PlantUMLWriter in project agile-architecture-documentation-system by Riduidel.

the class GraphEmitter method writeAllViews.

private void writeAllViews(Workspace workspace) {
    Layout layout = C4PlantUMLWriter.Layout.valueOf(layoutMode);
    PlantUMLWriter plantUMLWriter = new C4PlantUMLWriter(layout, plantumlPencils);
    // Hints to have arrows more easily visible
    plantUMLWriter.addSkinParam("pathHoverColor", "GreenYellow");
    plantUMLWriter.addSkinParam("ArrowThickness", "3");
    plantUMLWriter.addSkinParam("svgLinkTarget", "_parent");
    destination.mkdirs();
    plantUMLWriter.toPlantUMLDiagrams(workspace).stream().parallel().forEach(diagram -> {
        // Incredibly enough, that's not a view!
        Path path = new File(destination, diagram.getKey() + ".plantuml").toPath();
        try {
            Files.write(path, diagram.getDefinition().getBytes(Charset.forName("UTF-8")));
            logger.info(String.format("Generated diagram %s in file %s", diagram.getKey(), path));
        } catch (IOException e) {
            throw new CantWriteDiagram(String.format("Can't write diagram %s in file %s", diagram.getKey(), path), e);
        }
    });
}
Also used : Path(java.nio.file.Path) Layout(com.structurizr.io.plantuml.C4PlantUMLWriter.Layout) PlantUMLWriter(com.structurizr.io.plantuml.PlantUMLWriter) C4PlantUMLWriter(com.structurizr.io.plantuml.C4PlantUMLWriter) C4PlantUMLWriter(com.structurizr.io.plantuml.C4PlantUMLWriter) IOException(java.io.IOException) File(java.io.File)

Example 4 with PlantUMLWriter

use of com.structurizr.io.plantuml.PlantUMLWriter in project cia by Hack23.

the class AwsPublicSystemDocumentation method printPlantUml.

/**
 * Prints the plant uml.
 *
 * @param workspace
 *            the workspace
 * @throws WorkspaceWriterException
 *             the workspace writer exception
 * @throws IOException
 *             Signals that an I/O exception has occurred.
 * @throws InterruptedException
 *             the interrupted exception
 */
private static void printPlantUml(final Workspace workspace) throws WorkspaceWriterException, IOException, InterruptedException {
    final StringWriter stringWriter = new StringWriter();
    final PlantUMLWriter plantUMLWriter = new BasicPlantUMLWriter();
    plantUMLWriter.write(workspace, stringWriter);
    final String allPlantUmlsString = stringWriter.toString();
    final String awsSystem = allPlantUmlsString.substring(allPlantUmlsString.lastIndexOf("@startuml"), allPlantUmlsString.lastIndexOf("@enduml") + "@enduml".length());
    writePlantUml("Citizen-Intelligence-Agency-Prod-Aws-Account-Structure", awsSystem);
}
Also used : StringWriter(java.io.StringWriter) BasicPlantUMLWriter(com.structurizr.io.plantuml.BasicPlantUMLWriter) BasicPlantUMLWriter(com.structurizr.io.plantuml.BasicPlantUMLWriter) PlantUMLWriter(com.structurizr.io.plantuml.PlantUMLWriter)

Example 5 with PlantUMLWriter

use of com.structurizr.io.plantuml.PlantUMLWriter in project moduliths by moduliths.

the class Documenter method render.

private String render(ComponentView view, Options options) {
    switch(options.style) {
        case C4:
            C4PlantUMLExporter exporter = new C4PlantUMLExporter();
            Diagram diagram = exporter.export(view);
            return diagram.getDefinition();
        case UML:
        default:
            Writer writer = new StringWriter();
            PlantUMLWriter umlWriter = new BasicPlantUMLWriter();
            umlWriter.addSkinParam("componentStyle", "uml1");
            umlWriter.write(view, writer);
            return writer.toString();
    }
}
Also used : C4PlantUMLExporter(com.structurizr.io.plantuml.C4PlantUMLExporter) StringWriter(java.io.StringWriter) BasicPlantUMLWriter(com.structurizr.io.plantuml.BasicPlantUMLWriter) BasicPlantUMLWriter(com.structurizr.io.plantuml.BasicPlantUMLWriter) PlantUMLWriter(com.structurizr.io.plantuml.PlantUMLWriter) BasicPlantUMLWriter(com.structurizr.io.plantuml.BasicPlantUMLWriter) Writer(java.io.Writer) StringWriter(java.io.StringWriter) FileWriter(java.io.FileWriter) PlantUMLWriter(com.structurizr.io.plantuml.PlantUMLWriter) Diagram(com.structurizr.io.Diagram)

Aggregations

PlantUMLWriter (com.structurizr.io.plantuml.PlantUMLWriter)5 StringWriter (java.io.StringWriter)4 BasicPlantUMLWriter (com.structurizr.io.plantuml.BasicPlantUMLWriter)3 Diagram (com.structurizr.io.Diagram)1 C4PlantUMLExporter (com.structurizr.io.plantuml.C4PlantUMLExporter)1 C4PlantUMLWriter (com.structurizr.io.plantuml.C4PlantUMLWriter)1 Layout (com.structurizr.io.plantuml.C4PlantUMLWriter.Layout)1 File (java.io.File)1 FileWriter (java.io.FileWriter)1 IOException (java.io.IOException)1 Writer (java.io.Writer)1 Path (java.nio.file.Path)1