From 9823c6bd06aed3bacae2f14dac09fac9ee4d0208 Mon Sep 17 00:00:00 2001 From: Romain Lespinasse Date: Wed, 2 Aug 2023 17:23:24 +0200 Subject: [PATCH] resolves #1604 upgrade C4 PlantUML definition files to 2.7.0 (#1605) --- .../io/kroki/server/service/Plantuml.java | 4 + server/src/main/resources/c4.puml | 759 +++++++++++++----- server/src/main/resources/c4_component.puml | 64 +- server/src/main/resources/c4_container.puml | 84 +- server/src/main/resources/c4_context.puml | 304 +++++-- server/src/main/resources/c4_deployment.puml | 75 +- server/src/main/resources/c4_dynamic.puml | 222 +++-- server/src/main/resources/c4_sequence.puml | 387 +++++++++ 8 files changed, 1375 insertions(+), 524 deletions(-) create mode 100644 server/src/main/resources/c4_sequence.puml diff --git a/server/src/main/java/io/kroki/server/service/Plantuml.java b/server/src/main/java/io/kroki/server/service/Plantuml.java index 98b3f476e..68d742b11 100644 --- a/server/src/main/java/io/kroki/server/service/Plantuml.java +++ b/server/src/main/java/io/kroki/server/service/Plantuml.java @@ -90,6 +90,8 @@ public class Plantuml implements DiagramService { private static final String c4Deployment = c4Container + read("c4_deployment.puml"); // dynamic includes component private static final String c4Dynamic = c4Component + read("c4_dynamic.puml"); + // sequence includes component + private static final String c4Sequence = c4Component + read("c4_sequence.puml"); private final SourceDecoder sourceDecoder; private final List includeWhitelist; private static final List STDLIB = Arrays.asList( @@ -292,6 +294,8 @@ private static void ignoreInclude(String line, StringBuilder sb, SafeMode safeMo sb.append(c4Deployment).append("\n"); } else if (include.toLowerCase().contains("c4_dynamic.puml")) { sb.append(c4Dynamic).append("\n"); + } else if (include.toLowerCase().contains("c4_sequence.puml")) { + sb.append(c4Sequence).append("\n"); } else if (safeMode.value < SafeMode.SECURE.value) { if (!include.startsWith("<") // includes starting with < must only come from stdlib && !include.startsWith("/") && !include.startsWith("\\") // no absolute paths, diff --git a/server/src/main/resources/c4.puml b/server/src/main/resources/c4.puml index b9203e3de..6d4426d91 100644 --- a/server/src/main/resources/c4.puml +++ b/server/src/main/resources/c4.puml @@ -1,10 +1,12 @@ ' C4-PlantUML -' https://github.com/plantuml-stdlib/C4-PlantUML/tree/v2.4.0 +' https://github.com/plantuml-stdlib/C4-PlantUML/tree/v2.7.0 'Version ' ################################## !function C4Version() - !return "2.4.0" + ' 2 spaces and ' are used as unique marker, that the release scripts makes the correct version update + !$c4Version = "2.7.0" + !return $c4Version !end function !procedure C4VersionDetails() @@ -16,41 +18,83 @@ rectangle C4VersionDetailsArea <> [ ' Colors ' ################################## +!$ELEMENT_FONT_COLOR ?= "#FFFFFF" -!global $ELEMENT_FONT_COLOR = "#FFFFFF" +!$ARROW_COLOR ?= "#666666" +!$ARROW_FONT_COLOR ?= $ARROW_COLOR -!global $ARROW_COLOR = "#666666" +!$BOUNDARY_COLOR ?= "#444444" +!$BOUNDARY_BG_COLOR ?= "transparent" +!$BOUNDARY_BORDER_STYLE ?= "dashed" -!global $BOUNDARY_COLOR = "#444444" -!global $BOUNDARY_BG_COLOR = "transparent" - -!global $LEGEND_FONT_COLOR = "#FFFFFF" -!global $LEGEND_TITLE_COLOR = "#000000" +!$LEGEND_TITLE_COLOR ?= "#000000" +!$LEGEND_FONT_COLOR ?= "#FFFFFF" +!$LEGEND_BG_COLOR ?= "transparent" +!$LEGEND_BORDER_COLOR ?= "transparent" ' %darken(darkkhaki,50), #khaki -!global $LEGEND_DARK_COLOR = "#66622E" -!global $LEGEND_LIGHT_COLOR = "#khaki" +!$LEGEND_DARK_COLOR ?= "#66622E" +!$LEGEND_LIGHT_COLOR ?= "#khaki" + +!$SKETCH_BG_COLOR ?= "#EEEBDC" +!$SKETCH_FONT_COLOR ?= "" +!$SKETCH_WARNING_COLOR ?= "red" +!$SKETCH_FONT_NAME ?= "Comic Sans MS" ' Labels ' ################################## -!global $LEGEND_SHADOW_TEXT = "(shadow) " -!global $LEGEND_NO_SHADOW_TEXT = "(no shadow) " -!global $LEGEND_NO_FONT_BG_TEXT = "(no text, no back color) " -!global $LEGEND_NO_FONT_TEXT = "(no text color) " -!global $LEGEND_NO_BG_TEXT = "(no back color) " -!global $LEGEND_NO_LINE_TEXT = "(no line color) " -!global $LEGEND_ROUNDED_BOX = "(rounded box) " -!global $LEGEND_EIGHT_SIDED = "(eight sided) " -!global $LEGEND_DOTTED_LINE = "(dotted) " -!global $LEGEND_DASHED_LINE = "(dashed) " -!global $LEGEND_BOLD_LINE = "(bold) " +!$LEGEND_SHADOW_TEXT ?= "shadow" +!$LEGEND_NO_SHADOW_TEXT ?= "no shadow" +!$LEGEND_NO_FONT_BG_TEXT ?= "last text and back color" +!$LEGEND_NO_FONT_TEXT ?= "last text color" +!$LEGEND_NO_BG_TEXT ?= "last back color" +!$LEGEND_NO_LINE_TEXT ?= "last line color" +!$LEGEND_ROUNDED_BOX ?= "rounded box" +!$LEGEND_EIGHT_SIDED ?= "eight sided" +!$LEGEND_DOTTED_LINE ?= "dotted" +!$LEGEND_DASHED_LINE ?= "dashed" +!$LEGEND_BOLD_LINE ?= "bold" +!$LEGEND_BOUNDARY ?= "boundary" +!$LEGEND_DASHED_BOUNDARY ?= "dashed" +' ignore transparent atm, that the legend is smaller +'$LEGEND_DASHED_TRANSPARENT_BOUNDARY ?= "dashed, transparent" +!$LEGEND_DASHED_TRANSPARENT_BOUNDARY ?= "dashed" + +!$SKETCH_FOOTER_WARNING ?= "Warning:" +!$SKETCH_FOOTER_TEXT ?= "Created for discussion, needs to be validated" ' Styling ' ################################## -!global $TECHN_FONT_SIZE = 12 -!global $ROUNDED_BOX_SIZE = 25 -!global $EIGHT_SIDED_SIZE = 18 +!$STEREOTYPE_FONT_SIZE ?= 12 +!global $TRANSPARENT_STEREOTYPE_FONT_SIZE = $STEREOTYPE_FONT_SIZE/2 +!$TECHN_FONT_SIZE ?= 12 + +!$ARROW_FONT_SIZE ?= 12 + +!$LEGEND_DETAILS_SMALL_SIZE ?= 10 +!$LEGEND_DETAILS_NORMAL_SIZE ?= 14 +!global $LEGEND_DETAILS_SIZE = $LEGEND_DETAILS_SMALL_SIZE + +' element symbols typically 4 times too big in legend +!$LEGEND_IMAGE_SIZE_FACTOR ?= 0.25 + +!$ROUNDED_BOX_SIZE ?= 25 +!$EIGHT_SIDED_SIZE ?= 18 + +' Default element wrap width (of an element) +!$DEFAULT_WRAP_WIDTH ?= 200 +' Maximum size in pixels, of a message (in a sequence diagram?) +!$MAX_MESSAGE_SIZE ?= 150 +' PlantUML supports no DETERMINISTIC/automatic line breaks of "PlantUML line" (C4 Relationships) +' therefore Rel...() implements an automatic line break based on spaces (like in all other objects). +' If a $type contains \n then these are used (and no automatic space based line breaks are done) +' $REL_TECHN_MAX_CHAR_WIDTH defines the automatic line break position +!$REL_TECHN_MAX_CHAR_WIDTH ?= 35 +!$REL_DESCR_MAX_CHAR_WIDTH ?= 32 + +' internal +' ################################## !global $ROUNDED_BOX = "roundedBox" !global $EIGHT_SIDED = "eightSided" @@ -59,70 +103,68 @@ rectangle C4VersionDetailsArea <> [ !global $DASHED_LINE = "dashed" !global $BOLD_LINE = "bold" +!global $LEGEND_DETAILS_NONE = "none" +!global $LEGEND_DETAILS_NORMAL = "normal" +!global $LEGEND_DETAILS_SMALL = "small" + skinparam defaultTextAlignment center -skinparam wrapWidth 200 -skinparam maxMessageSize 150 +skinparam wrapWidth $DEFAULT_WRAP_WIDTH +skinparam maxMessageSize $MAX_MESSAGE_SIZE -skinparam LegendBorderColor transparent -skinparam LegendBackgroundColor transparent skinparam LegendFontColor $LEGEND_FONT_COLOR +skinparam LegendBackgroundColor $LEGEND_BG_COLOR +skinparam LegendBorderColor $LEGEND_BORDER_COLOR -skinparam shadowing<> false -' #00000000 is transparent skinparam rectangle<> { - backgroundcolor #00000000 - bordercolor #00000000 + backgroundcolor $LEGEND_BG_COLOR + bordercolor $LEGEND_BORDER_COLOR } skinparam rectangle { - StereotypeFontSize 12 - shadowing false + StereotypeFontSize $STEREOTYPE_FONT_SIZE } skinparam database { - StereotypeFontSize 12 - shadowing false + StereotypeFontSize $STEREOTYPE_FONT_SIZE } skinparam queue { - StereotypeFontSize 12 - shadowing false + StereotypeFontSize $STEREOTYPE_FONT_SIZE +} + +skinparam participant { + StereotypeFontSize $STEREOTYPE_FONT_SIZE } skinparam arrow { Color $ARROW_COLOR - FontColor $ARROW_COLOR - FontSize 12 + FontColor $ARROW_FONT_COLOR + FontSize $ARROW_FONT_SIZE } -skinparam actor { - StereotypeFontSize 12 - shadowing false - style awesome +skinparam person { + StereotypeFontSize $STEREOTYPE_FONT_SIZE } -skinparam person { - StereotypeFontSize 12 - shadowing false +skinparam actor { + StereotypeFontSize $STEREOTYPE_FONT_SIZE + style awesome } ' Some boundary skinparams have to be set as package skinparams too (PlantUML uses internal packages) -skinparam package { - StereotypeFontSize 6 +' UpdateBoundaryStyle() called in boundary section below +skinparam rectangle<> { + StereotypeFontSize $TRANSPARENT_STEREOTYPE_FONT_SIZE StereotypeFontColor $BOUNDARY_BG_COLOR - FontStyle plain - BackgroundColor $BOUNDARY_BG_COLOR + BorderStyle $BOUNDARY_BORDER_STYLE } -skinparam rectangle<> { - Shadowing false - StereotypeFontSize 6 +skinparam package { + StereotypeFontSize $TRANSPARENT_STEREOTYPE_FONT_SIZE StereotypeFontColor $BOUNDARY_BG_COLOR - FontColor $BOUNDARY_COLOR - BorderColor $BOUNDARY_COLOR + FontStyle plain BackgroundColor $BOUNDARY_BG_COLOR - BorderStyle dashed } ' Legend and Tags @@ -255,10 +297,28 @@ skinparam rectangle<> { !return $arg !endfunction +' if $value is empty try to load it via variable, optional can it store the calculated value +!function $restoreEmpty($elementType, $property, $value, $store) + !$var = "$" + $elementType + "Restore" + $property + !if ($value == "") + !$value = %get_variable_value($var) + !elseif ($store) + %set_variable_value($var, $value) + !endif + !return $value +!endfunction + +' clear the restore property +!function $clearRestore($elementType, $property) + !$var = "$" + $elementType + "Restore" + $property + %set_variable_value($var, "") + !return "" +!endfunction + !function $elementTagSkinparams($element, $tagStereo, $bgColor, $fontColor, $borderColor, $shadowing, $shape) !$elementSkin = "skinparam " + $element + "<<" + $tagStereo + ">> {" + %newline() !if ($fontColor != "") - !if ($tagStereo != "boundary") + !if (%strpos($tagStereo, "boundary") < 0) !$elementSkin = $elementSkin + " StereotypeFontColor " + $fontColor + %newline() !endif !$elementSkin = $elementSkin + " FontColor " + $fontColor + %newline() @@ -294,12 +354,16 @@ skinparam rectangle<> { !$tagSkin = $elementTagSkinparams("rectangle", $tagStereo, $bgColor, $fontColor, $borderColor, $shadowing, $shape) !$tagSkin = $tagSkin + $elementTagSkinparams("database", $tagStereo, $bgColor, $fontColor, $borderColor, $shadowing, "") !$tagSkin = $tagSkin + $elementTagSkinparams("queue", $tagStereo, $bgColor, $fontColor, $borderColor, $shadowing, "") + ' plantuml.jar bug - actor have to be after person + !$tagSkin = $tagSkin + $elementTagSkinparams("person", $tagStereo, $bgColor, $fontColor, $borderColor, $shadowing, "") ' actor has style awesome, therefore $fontColor is ignored and text uses $bgColor too !$tagSkin = $tagSkin + $elementTagSkinparams("actor", $tagStereo, $bgColor, $bgColor, $borderColor, $shadowing, "") - !$tagSkin = $tagSkin + $elementTagSkinparams("person", $tagStereo, $bgColor, $fontColor, $borderColor, $shadowing, "") - !if ($tagStereo == "boundary" && $bgColor != "") - !$tagSkin = $tagSkin + "skinparam package<>StereotypeFontColor " + $bgColor + %newline() - !$tagSkin = $tagSkin + "skinparam rectangle<>StereotypeFontColor " + $bgColor + %newline() + ' sequence requires participant + !$tagSkin = $tagSkin + $elementTagSkinparams("participant", $tagStereo, $bgColor, $fontColor, $borderColor, $shadowing, "") + !$tagSkin = $tagSkin + $elementTagSkinparams("sequencebox", $tagStereo, $bgColor, $fontColor, $borderColor, $shadowing, "") + !if (%strpos($tagStereo, "boundary") >= 0 && $bgColor != "") + !$tagSkin = $tagSkin + "skinparam package<<" + $tagStereo + ">>StereotypeFontColor " + $bgColor + %newline() + !$tagSkin = $tagSkin + "skinparam rectangle<<" + $tagStereo + ">>StereotypeFontColor " + $bgColor + %newline() !endif $tagSkin !endprocedure @@ -312,19 +376,24 @@ $tagSkin !return $c !endfunction -!unquoted procedure $defineRelSkinparams($tagStereo, $textColor, $lineColor, $lineStyle) +!unquoted procedure $defineRelSkinparams($tagStereo, $textColor, $lineColor, $lineStyle, $lineThickness) !$elementSkin = "skinparam arrow<<" + $tagStereo + ">> {" + %newline() - !$elementSkin = $elementSkin + " Color " - !if ($lineColor != "") - !$elementSkin = $elementSkin + $colorWithoutHash($lineColor) - !endif - !if ($textColor != "") - !$elementSkin = $elementSkin + ";text:" + $colorWithoutHash($textColor) + !if ($lineColor != "") || ($textColor != "") || ($lineStyle != "") + !$elementSkin = $elementSkin + " Color " + !if ($lineColor != "") + !$elementSkin = $elementSkin + $colorWithoutHash($lineColor) + !endif + !if ($textColor != "") + !$elementSkin = $elementSkin + ";text:" + $colorWithoutHash($textColor) + !endif + !if ($lineStyle != "") + !$elementSkin = $elementSkin + ";line." + $lineStyle + !endif + !$elementSkin = $elementSkin + %newline() !endif - !if ($lineStyle != "") - !$elementSkin = $elementSkin + ";line." + $lineStyle + !if ($lineThickness != "") + !$elementSkin = $elementSkin + " thickness " + $lineThickness + %newline() !endif - !$elementSkin = $elementSkin + %newline() !$elementSkin = $elementSkin + "}" + %newline() $elementSkin !endprocedure @@ -421,9 +490,9 @@ $elementSkin ' ,scale= ... has to be first (...,color=black,scale=0.25... is invalid too) !if (%strpos($sprite, "=") < 0) !if (%substr($sprite, 0, 4) == "img:") - !$smallSprite = $sprite + "{scale=0.25}" + !$smallSprite = $sprite + "{scale=" + $LEGEND_IMAGE_SIZE_FACTOR + "}" !else - !$smallSprite = $sprite + ",scale=0.25" + !$smallSprite = $sprite + ",scale=" + $LEGEND_IMAGE_SIZE_FACTOR !endif !else !$smallSprite = $sprite @@ -443,7 +512,7 @@ $elementSkin !return $formatted !endfunction -!function $tagLegendEntry($tagStereo, $bgColor, $fontColor, $borderColor, $shadowing, $shape, $legendText, $legendSprite) +!function $setTagLegendVariables($tagStereo, $bgColor, $fontColor, $borderColor, $shadowing, $shape, $legendText, $legendSprite) !$bg = $bgColor !$fo = $fontColor !$bo = $borderColor @@ -484,6 +553,7 @@ $elementSkin !endif !$tagEntry = "|" + !$tagDetails = "(" !$tagEntry = $tagEntry + "<" + $colorWithHash($bg) +">" ' ..white rectangle !$tagEntry = $tagEntry + " " @@ -492,45 +562,89 @@ $elementSkin !$tagEntry = $tagEntry + $getSprite($legendSprite) + " " !endif !if ($legendText == "") - !$tagEntry = $tagEntry + " " + $tagStereo + " " + !if ($tagStereo == "boundary") + ' #00000000 is transparent + !if ($bgColor == "#00000000" || %lower($bgColor) == "transparent") + !$tagEntry = $tagEntry + " " + $LEGEND_BOUNDARY + " " + !$tagDetails = $tagDetails + $LEGEND_DASHED_TRANSPARENT_BOUNDARY + ", " + !else + !$tagEntry = $tagEntry + " " + $LEGEND_BOUNDARY + " " + !$tagDetails = $tagDetails + $LEGEND_DASHED_BOUNDARY + ", " + !endif + !elseif (%strpos($tagStereo, "boundary") >= 0) + ' if contains/ends with _boundary remove _boundary and add "boundary (dashed)" + !$pos = %strpos($tagStereo, "_boundary") + !if ($pos > 0) + !$tagEntry = $tagEntry + " " + %substr($tagStereo, 0 ,$pos) + !if ($bgColor == "#00000000" || %lower($bgColor) == "transparent") + !$tagEntry = $tagEntry + " " + $LEGEND_BOUNDARY + " " + !$tagDetails = $tagDetails + $LEGEND_DASHED_TRANSPARENT_BOUNDARY + ", " + !else + !$tagEntry = $tagEntry + " " + $LEGEND_BOUNDARY + " " + !$tagDetails = $tagDetails + $LEGEND_DASHED_BOUNDARY + ", " + !endif + !endif + !else + !$tagEntry = $tagEntry + " " + $tagStereo + " " + !endif !if ($shadowing == "true") - !$tagEntry = $tagEntry + $LEGEND_SHADOW_TEXT + !$tagDetails = $tagDetails + $LEGEND_SHADOW_TEXT + ", " !endif !if ($shadowing == "false") - !$tagEntry = $tagEntry + $LEGEND_NO_SHADOW_TEXT + !$tagDetails = $tagDetails + $LEGEND_NO_SHADOW_TEXT + ", " !endif !if ($shape == $ROUNDED_BOX) - !$tagEntry = $tagEntry + $LEGEND_ROUNDED_BOX + !$tagDetails = $tagDetails + $LEGEND_ROUNDED_BOX + ", " !endif !if ($shape == $EIGHT_SIDED) - !$tagEntry = $tagEntry + $LEGEND_EIGHT_SIDED + !$tagDetails = $tagDetails + $LEGEND_EIGHT_SIDED + ", " !endif !if ($fontColor == "" && $bgColor == "") - !$tagEntry = $tagEntry + $LEGEND_NO_FONT_BG_TEXT + !$tagDetails = $tagDetails + $LEGEND_NO_FONT_BG_TEXT + ", " !else !if ($fontColor == "") - !$tagEntry = $tagEntry + $LEGEND_NO_FONT_TEXT + !$tagDetails = $tagDetails + $LEGEND_NO_FONT_TEXT + ", " !endif !if ($bgColor == "") - !$tagEntry = $tagEntry + $LEGEND_NO_BG_TEXT + !$tagDetails = $tagDetails + $LEGEND_NO_BG_TEXT + ", " !endif !endif + !if ($tagDetails=="(" || $tagDetails=="(, ") + !$tagDetails = "" + !else + !$tagDetails = %substr($tagDetails, 0, %strlen($tagDetails)-2) + !$tagDetails = $tagDetails + ")" + !endif !else - !$tagEntry = $tagEntry + " " + $legendText + " " + !$brPos = %strpos($legendText, "\n") + !if ($brPos > 0) + !$tagEntry = $tagEntry + %substr($legendText, 0, $brPos) + " " + !$details = %substr($legendText, $brPos + 2) + !if ($details=="") + !$tagDetails = "" + !else + !$tagDetails = $tagDetails + $details + ")" + !endif + !else + !$tagEntry = $tagEntry + " " + $legendText + " " + !$tagDetails = "" + !endif !endif - !$tagEntry = $tagEntry + " " - !$tagEntry = $tagEntry + "|" + !$tagDetails = $tagDetails + " " + !$tagDetails = $tagDetails + "|" +%set_variable_value("$" + $tagStereo + "LegendEntry", $tagEntry) +%set_variable_value("$" + $tagStereo + "LegendDetails", $tagDetails) !return $tagEntry !endfunction -!function $tagRelLegendEntry($tagStereo, $textColor, $lineColor, $lineStyle, $legendText, $legendSprite) +!function $setTagRelLegendVariables($tagStereo, $textColor, $lineColor, $lineStyle, $legendText, $legendSprite, $lineThickness) !$tc = $textColor !$lc = $lineColor !if ($tc == "") !if ($PlantUMLSupportsDynamicLegendColor) - !$tc = $flatLegend($ARROW_COLOR) + !$tc = $flatLegend($ARROW_FONT_COLOR) !else !$tc = $LEGEND_DARK_COLOR !endif @@ -544,6 +658,7 @@ $elementSkin !endif !$tagEntry = "|" + !$tagDetails = "(" ' ..white line !$tagEntry = $tagEntry + " " !$tagEntry = $tagEntry + "" @@ -553,49 +668,67 @@ $elementSkin !if ($legendText == "") !$tagEntry = $tagEntry + " " + $tagStereo + " " !if ($textColor == "") - !$tagEntry = $tagEntry + $LEGEND_NO_FONT_TEXT + !$tagDetails = $tagDetails + $LEGEND_NO_FONT_TEXT + ", " !endif !if ($lineColor == "") - !$tagEntry = $tagEntry + $LEGEND_NO_LINE_TEXT + !$tagDetails = $tagDetails + $LEGEND_NO_LINE_TEXT + ", " !endif !if ($lineStyle != "") !if ($lineStyle == $DOTTED_LINE) - !$tagEntry = $tagEntry + $LEGEND_DOTTED_LINE + !$tagDetails = $tagDetails + $LEGEND_DOTTED_LINE + ", " !elseif ($lineStyle == $DASHED_LINE) - !$tagEntry = $tagEntry + $LEGEND_DASHED_LINE + !$tagDetails = $tagDetails + $LEGEND_DASHED_LINE + ", " !elseif ($lineStyle == $BOLD_LINE) - !$tagEntry = $tagEntry + $LEGEND_BOLD_LINE + !$tagDetails = $tagDetails + $LEGEND_BOLD_LINE + ", " !else - !$tagEntry = $tagEntry + "(" + $lineStyle + ") " + !$tagDetails = $tagDetails + $lineStyle + ", " !endif !endif + !if ($lineThickness != "") + !$tagDetails = $tagDetails + "thickness " + $lineThickness + ") " + !endif + !if ($tagDetails=="(") + !$tagDetails = "" + !else + !$tagDetails = %substr($tagDetails, 0, %strlen($tagDetails)-2) + !$tagDetails = $tagDetails + ")" + !endif !else - !$tagEntry = $tagEntry + " " + $legendText + " " + !$brPos = %strpos($legendText, "\n") + !if ($brPos > 0) + !$tagEntry = $tagEntry + " " + %substr($legendText, 0, $brPos) + " " + !$details = %substr($legendText, $brPos + 2) + !if ($details=="") + !$tagDetails = "" + !else + !$tagDetails = $tagDetails + $details + ")" + !endif + !else + !$tagEntry = $tagEntry + " " + $legendText + " " + !$tagDetails = "" + !endif !endif - !$tagEntry = $tagEntry + " " - !$tagEntry = $tagEntry + "|" + !$tagDetails = $tagDetails + " " + !$tagDetails = $tagDetails + "|" +%set_variable_value("$" + $tagStereo + "_LineLegendEntry", $tagEntry) +%set_variable_value("$" + $tagStereo + "_LineLegendDetails", $tagDetails) !return $tagEntry !endfunction -!global $LEGEND_DOTTED_LINE = "(dotted) " -!global $LEGEND_DASHED_LINE = "(dashed) " -!global $LEGEND_BOLD_LINE = "(bold) " - !unquoted procedure $addTagToLegend($tagStereo, $bgColor="", $fontColor="", $borderColor="", $shadowing="", $shape="", $legendText="", $legendSprite="") '' if a combined element tag is defined (e.g. "v1.0&v1.1") then it is typically a merged color, '' like a new $fontColor="#fdae61" therefore it should be added to the legend '' and the & combined tags will be not removed ' !if (%strpos($tagStereo, "&") < 0) - !$tagEntry = $tagLegendEntry($tagStereo, $bgColor, $fontColor, $borderColor, $shadowing, $shape, $legendText, $legendSprite) -%set_variable_value("$" + $tagStereo + "LegendEntry", $tagEntry) + !$dummyAlreadyVariables = $setTagLegendVariables($tagStereo, $bgColor, $fontColor, $borderColor, $shadowing, $shape, $legendText, $legendSprite) !$tagCustomLegend = $tagCustomLegend + $tagStereo + "\n" !$tagMask = $tagLegendMask( $bgColor, $fontColor, $borderColor, $shadowing, $shape, $sprite) %set_variable_value("$" + $tagStereo + "LegendMask", $tagMask) ' !endif !endprocedure -!unquoted procedure $addRelTagToLegend($tagStereo, $textColor="", $lineColor="", $lineStyle="", $legendText="", $legendSprite="") +!unquoted procedure $addRelTagToLegend($tagStereo, $textColor="", $lineColor="", $lineStyle="", $legendText="", $legendSprite="", $lineThickness="") '' Arrows have a bug with stereotype/skinparams and cannot combine text colors of one stereotype '' and the line color of another stereotype. Therefore the text color of one tag and the line color '' of another tag have to be combined via a "workaround" tag ("v1.0&v1.1"). @@ -603,9 +736,8 @@ $elementSkin '' be an inconsistency between the element tags and the rel tags and therefore '' & combined workaround tags are not removed too (and in unlikely cases the color itself could be changed) ' !if (%strpos($tagStereo, "&") < 0) - !$tagEntry = $tagRelLegendEntry($tagStereo, $textColor, $lineColor, $lineStyle, $legendText, $legendSprite) -%set_variable_value("$" + $tagStereo + "_LineLegendEntry", $tagEntry) - !$tagCustomLegend = $tagCustomLegend + $tagStereo + "_Line\n" + !$dummyAlreadyVariables = $setTagRelLegendVariables($tagStereo, $textColor, $lineColor, $lineStyle, $legendText, $legendSprite, $lineThickness) + !$tagCustomLegend = $tagCustomLegend + $tagStereo + "_Line\n" ' !endif !endprocedure @@ -616,13 +748,23 @@ $elementSkin !$allDefined = %substr($allDefined, $brPos+2) !$brPos = %strpos($allDefined, "\n") !if (%variable_exists("$" + $tagStereo + "Legend")) -%get_variable_value("$" + $tagStereo + "LegendEntry") + ' is part of legendDetails + !$part1 = %get_variable_value("$" + $tagStereo + "LegendEntry") + !$partSize = "" + !$part2 = %get_variable_value("$" + $tagStereo + "LegendDetails") + !$line = $part1 + $partSize + $part2 +$line !endif !endwhile !if (%strlen($allDefined) > 0) !$tagStereo = $allDefined !if (%variable_exists("$" + $tagStereo + "Legend")) -%get_variable_value("$" + $tagStereo + "LegendEntry") + ' is part of legendDetails + !$part1 = %get_variable_value("$" + $tagStereo + "LegendEntry") + !$partSize = "" + !$part2 = %get_variable_value("$" + $tagStereo + "LegendDetails") + !$line = $part1 + $partSize + $part2 +$line !endif !endif !endprocedure @@ -662,9 +804,24 @@ $defineSkinparams($tagStereo, $bgColor, $fontColor, $borderColor, $shadowing, $s $addTagToLegend($tagStereo, $bgColor, $fontColor, $borderColor, $shadowing, $shape, $legendText, $legendSprite) !endprocedure +!unquoted procedure $addElementTagInclReuse($elementName, $tagStereo, $bgColor="", $fontColor="", $borderColor="", $shadowing="", $shape="", $sprite="", $techn="", $legendText="", $legendSprite="") + !$bgColor=$restoreEmpty($elementName, "bgColor", $bgColor, %false()) + !$fontColor=$restoreEmpty($elementName, "fontColor", $fontColor, %false()) + !$borderColor=$restoreEmpty($elementName, "borderColor", $borderColor, %false()) + !$shadowing=$restoreEmpty($elementName, "shadowing", $shadowing, %false()) + !$shape=$restoreEmpty($elementName, "shape", $shape, %false()) + !$sprite=$restoreEmpty($elementName, "sprite", $sprite, %false()) + !$techn=$restoreEmpty($elementName, "techn", $techn, %false()) + ' new style should has its own legend text + ' !$legendText=$restoreEmpty($elementName, "legendText", $legendText, %false()) + !$legendSprite=$restoreEmpty($elementName, "legendSprite", $legendSprite, %false()) + + AddElementTag($tagStereo, $bgColor, $fontColor, $borderColor, $shadowing, $shape, $sprite, $techn, $legendText, $legendSprite) +!endprocedure + ' used by new defined rel tags -!unquoted procedure AddRelTag($tagStereo, $textColor="", $lineColor="", $lineStyle = "", $sprite="", $techn="", $legendText="", $legendSprite="") -$defineRelSkinparams($tagStereo, $textColor, $lineColor, $lineStyle) +!unquoted procedure AddRelTag($tagStereo, $textColor="", $lineColor="", $lineStyle="", $sprite="", $techn="", $legendText="", $legendSprite="", $lineThickness="") +$defineRelSkinparams($tagStereo, $textColor, $lineColor, $lineStyle, $lineThickness) !if ($sprite != "") %set_variable_value("$" + $tagStereo + "RelTagSprite", $sprite) !if ($legendSprite == "") @@ -675,11 +832,20 @@ $defineRelSkinparams($tagStereo, $textColor, $lineColor, $lineStyle) !if ($techn != "") %set_variable_value("$" + $tagStereo + "RelTagTechn", $techn) !endif -$addRelTagToLegend($tagStereo, $textColor, $lineColor, $lineStyle, $legendText, $legendSprite) +$addRelTagToLegend($tagStereo, $textColor, $lineColor, $lineStyle, $legendText, $legendSprite, $lineThickness) !endprocedure ' update the style of existing elements like person, ... !unquoted procedure UpdateElementStyle($elementName, $bgColor="", $fontColor="", $borderColor="", $shadowing="", $shape="", $sprite="", $techn="", $legendText="", $legendSprite="") +!$bgColor=$restoreEmpty($elementName, "bgColor", $bgColor, %true()) +!$fontColor=$restoreEmpty($elementName, "fontColor", $fontColor, %true()) +!$borderColor=$restoreEmpty($elementName, "borderColor", $borderColor, %true()) +!$shadowing=$restoreEmpty($elementName, "shadowing", $shadowing, %true()) +!$shape=$restoreEmpty($elementName, "shape", $shape, %true()) +!$sprite=$restoreEmpty($elementName, "sprite", $sprite, %true()) +!$techn=$restoreEmpty($elementName, "techn", $techn, %true()) +!$legendText=$restoreEmpty($elementName, "legendText", $legendText, %true()) +!$legendSprite=$restoreEmpty($elementName, "legendSprite", $legendSprite, %true()) $defineSkinparams($elementName, $bgColor, $fontColor, $borderColor, $shadowing, $shape) !if ($sprite != "") %set_variable_value("$" + $elementName + "ElementTagSprite", $sprite) @@ -690,8 +856,7 @@ $defineSkinparams($elementName, $bgColor, $fontColor, $borderColor, $shadowing, !if ($techn != "") %set_variable_value("$" + $elementName + "ElementTagTechn", $techn) !endif - !$tagEntry = $tagLegendEntry($elementName, $bgColor, $fontColor, $borderColor, $shadowing, $shape, $legendText, $legendSprite) -%set_variable_value("$" + $elementName + "LegendEntry", $tagEntry) + !$dummyAlreadyVariables = $setTagLegendVariables($elementName, $bgColor, $fontColor, $borderColor, $shadowing, $shape, $legendText, $legendSprite) ' default tags sets at least bgColor and fontColor !$tagMask = $tagLegendMask("CHANGED", "CHANGED", $borderColor, $shadowing, $shape, $sprite) %set_variable_value("$" + $elementName + "LegendMask", $tagMask) @@ -730,79 +895,101 @@ $elementSkin ' Line breaks ' ################################## -' PlantUML supports no DETERMINISTIC/automatic line breaks of "PlantUML line" (C4 Relationships) -' therefore Rel...() implements an automatic line break based on spaces (like in all other objects). -' If a $type contains \n then these are used (and no automatic space based line breaks are done) -' $REL_TECHN_MAX_CHAR_WIDTH defines the automatic line break position -!global $REL_TECHN_MAX_CHAR_WIDTH = 35 -!global $REL_DESCR_MAX_CHAR_WIDTH = 32 - -!unquoted function $breakDescr($descr, $widthStr) +!unquoted function $breakText($text, $usedNewLine, $widthStr="-1") !$width = %intval($widthStr) !$multiLine = "" -!if (%strpos($descr, "\n") >= 0) +!if (%strpos($text, "\n") >= 0) + !while (%strpos($text, "\n") >= 0) + !$brPos = %strpos($text, "\n") + !if ($brPos > 0) + !$multiLine = $multiLine + %substr($text, 0, $brPos) + $usedNewLine + !else + ' non breaking change that newLine breaks with formats can be used with \n\n + !$multiLine = $multiLine + "" + $usedNewLine + !endif + !$text = %substr($text, $brPos+2) + !if (%strlen($text) == 0) + !$text = "" + !endif + !endwhile !else - !while (%strlen($descr) > $width) + !while ($width>0 && %strlen($text) > $width) !$brPos = $width - !while ($brPos > 0 && %substr($descr, $brPos, 1) != ' ') + !while ($brPos > 0 && %substr($text, $brPos, 1) != ' ') !$brPos = $brPos - 1 !endwhile !if ($brPos < 1) - !$brPos = %strpos($descr, " ") + !$brPos = %strpos($text, " ") !else !endif !if ($brPos > 0) - !$multiLine = $multiLine + %substr($descr, 0, $brPos) + "\n" - !$descr = %substr($descr, $brPos + 1) + !$multiLine = $multiLine + %substr($text, 0, $brPos) + $usedNewLine + !$text = %substr($text, $brPos + 1) !else - !$multiLine = $multiLine+ $descr - !$descr = "" + !$multiLine = $multiLine+ $text + !$text = "" !endif !endwhile !endif -!if (%strlen($descr) > 0) - !$multiLine = $multiLine + $descr +!if (%strlen($text) > 0) + !$multiLine = $multiLine + $text !endif !return $multiLine !endfunction +!unquoted function $breakLabel($text) +!$usedNewLine = "\n== " +!$multiLine = $breakText($text, $usedNewLine) +!return $multiLine +!endfunction + +!unquoted function $breakDescr($text, $widthStr) + !$usedNewLine = "\n" + !return $breakText($text, $usedNewLine, $widthStr) +!endfunction + ' $breakTechn() supports //...//; $breakNode() in C4_Deployment supports no //....// -!unquoted function $breakTechn($techn, $widthStr) -!$width = %intval($widthStr) -!$multiLine = "" -!if (%strpos($techn, "\n") >= 0) - !while (%strpos($techn, "\n") >= 0) - !$brPos = %strpos($techn, "\n") - !$multiLine = $multiLine + %substr($techn, 0, $brPos) + '//\n//' - !$techn = %substr($techn, $brPos+2) - !endwhile -!else - !while (%strlen($techn) > $width) - !$brPos = $width - !while ($brPos > 0 && %substr($techn, $brPos, 1) != ' ') - !$brPos = $brPos - 1 - !endwhile +!unquoted function $breakTechn($text, $widthStr) + !$usedNewLine = '//\n//' + !return $breakText($text, $usedNewLine, $widthStr) +!endfunction - !if ($brPos < 1) - !$brPos = %strpos($techn, " ") - !else - !endif +' Element base layout +' ################################## - !if ($brPos > 0) - !$multiLine = $multiLine + %substr($techn, 0, $brPos) + '//\n//' - !$techn = %substr($techn, $brPos + 1) - !else - !$multiLine = $multiLine+ $techn - !$techn = "" +!function $getElementBase($label, $techn, $descr, $sprite) + !$element = "" + !if ($sprite != "") + !$element = $element + $getSprite($sprite) + !if ($label != "") + !$element = $element + '\n' !endif - !endwhile -!endif -!if (%strlen($techn) > 0) - !$multiLine = $multiLine + $techn -!endif -!return $multiLine + !endif + !if ($label != "") + !$element = $element + '== ' + $breakLabel($label) + !else + !$element = $element + '.' + !endif + !if ($techn != "") + !$element = $element + '\n//[' + $breakTechn($techn, '-1') + ']//' + !endif + !if ($descr != "") + !$element = $element + '\n\n' + $descr + !endif + !return $element +!endfunction + +!function $getElementLine($umlShape, $elementType, $alias, $label, $techn, $descr, $sprite, $tags, $link) + !$sprite=$toElementArg($sprite, $tags, "ElementTagSprite", $elementType) + !$techn=$toElementArg($techn, $tags, "ElementTagTechn", $elementType) + !$baseProp = $getElementBase($label, $techn, $descr, $sprite) + $getProps() + !$stereo = $toStereos($elementType,$tags) + !$calcLink = $getLink($link) + + !$line = $umlShape + " " + %chr(34) + $baseProp + %chr(34) +" " + $stereo + " as " + $alias + $calcLink + !return $line !endfunction ' Element properties @@ -871,22 +1058,34 @@ SetPropertyHeader("Property","Value") ' Layout ' ################################## +!function $getLegendDetailsSize($detailsFormat) + !if $detailsFormat == $LEGEND_DETAILS_NONE + !$size = 0 + !elseif $detailsFormat == $LEGEND_DETAILS_SMALL + !$size = $LEGEND_DETAILS_SMALL_SIZE + !else + !$size = $LEGEND_DETAILS_NORMAL_SIZE + !endif + !return $size +!endfunction + !procedure $getHideStereotype($hideStereotype) !if ($hideStereotype == "true") hide stereotype !endif !endprocedure -!procedure $getLegendTable() -<#00000000,#00000000>|**Legend** | +!procedure $getLegendTable($detailsFormat) +!global $LEGEND_DETAILS_SIZE = $getLegendDetailsSize($detailsFormat) +<$colorWithHash(transparent),$colorWithHash(transparent)>|**Legend** | $showActiveLegendEntries($tagDefaultLegend) $showActiveLegendEntries($tagCustomLegend) !endprocedure -!procedure $getLegendArea($areaAlias, $hideStereotype) +!procedure $getLegendArea($areaAlias, $hideStereotype, $details) $getHideStereotype($hideStereotype) rectangle $areaAlias<> [ -$getLegendTable() +$getLegendTable($details) ] !endprocedure @@ -894,11 +1093,59 @@ $getLegendTable() hide stereotype !endprocedure +!unquoted procedure SET_SKETCH_STYLE($bgColor="_dont_change_", $fontColor="_dont_change_", $warningColor="_dont_change_", $fontName="_dont_change_", $footerWarning="_dont_change_", $footerText="_dont_change_") +!if $bgColor != "_dont_change_" + !global $SKETCH_BG_COLOR = $bgColor +!endif +!if $fontColor != "_dont_change_" + !global $SKETCH_FONT_COLOR = $fontColor +!endif +!if $warningColor != "_dont_change_" + !global $SKETCH_WARNING_COLOR = $warningColor +!endif +!if $fontName != "_dont_change_" + !global $SKETCH_FONT_NAME = $fontName +!endif +!if $footerWarning != "_dont_change_" + !global $SKETCH_FOOTER_WARNING = $footerWarning +!endif +!if $footerText != "_dont_change_" + !global $SKETCH_FOOTER_TEXT = $footerText +!endif +!endprocedure + !procedure LAYOUT_AS_SKETCH() -skinparam backgroundColor #EEEBDC -skinparam handwritten true -skinparam defaultFontName "Comic Sans MS" -center footer Warning: Created for discussion, needs to be validated + skinparam handwritten true +!if $SKETCH_BG_COLOR > "" + skinparam backgroundColor $SKETCH_BG_COLOR +!endif +!if $SKETCH_FONT_COLOR > "" + skinparam footer { + FontColor $SKETCH_FONT_COLOR + } + !if $ARROW_COLOR == "#666666" + !global $ARROW_COLOR = $SKETCH_FONT_COLOR + !global $ARROW_FONT_COLOR = $SKETCH_FONT_COLOR + skinparam arrow { + Color $ARROW_COLOR + FontColor $ARROW_FONT_COLOR + } + !endif + !if $BOUNDARY_COLOR == "#444444" + !global $BOUNDARY_COLOR = $SKETCH_FONT_COLOR + skinparam rectangle<> { + FontColor $BOUNDARY_COLOR + BorderColor $BOUNDARY_COLOR + } + !endif +!endif +!if $SKETCH_FONT_NAMES > "" + skinparam defaultFontName $SKETCH_FONT_NAME +!endif +!if $SKETCH_FOOTER_WARNING > "" || $SKETCH_FOOTER_TEXT > "" + !$line = "footer "+ $SKETCH_FOOTER_WARNING + " " + $SKETCH_FOOTER_TEXT + $line +!endif !endprocedure !global $fix_direction=%false() @@ -950,11 +1197,24 @@ left to right direction left to right direction !endprocedure +' legend details can displayed as Normal(), Small(), None() +!function None() +!return $LEGEND_DETAILS_NONE +!endfunction + +!function Normal() +!return $LEGEND_DETAILS_NORMAL +!endfunction + +!function Small() +!return $LEGEND_DETAILS_SMALL +!endfunction + ' has to be last call in diagram -!unquoted procedure SHOW_LEGEND($hideStereotype="true") +!unquoted procedure SHOW_LEGEND($hideStereotype="true", $details=Small()) $getHideStereotype($hideStereotype) legend right -$getLegendTable() +$getLegendTable($details) endlegend !endprocedure @@ -971,26 +1231,120 @@ SHOW_LEGEND($hideStereotype) !endfunction ' enables that legend can be located in drawing area of the diagram. It has to be last call in diagram followed by Lay_Distance() -!unquoted procedure SHOW_FLOATING_LEGEND($alias=LEGEND(), $hideStereotype="true") -$getLegendArea($alias, $hideStereotype) +!unquoted procedure SHOW_FLOATING_LEGEND($alias=LEGEND(), $hideStereotype="true", $details=Normal()) +$getLegendArea($alias, $hideStereotype, $details) !endprocedure ' Boundaries ' ################################## +!unquoted procedure UpdateBoundaryStyle($elementName="", $bgColor="", $fontColor="", $borderColor="", $shadowing="", $shape="", $type="", $legendText="") + !if ($elementName != "") + !$elementBoundary = $elementName + '_boundary' + UpdateElementStyle($elementBoundary, $bgColor, $fontColor, $borderColor, $shadowing, $shape, "", $type, $legendText, "") + !else + UpdateElementStyle("boundary", $bgColor, $fontColor, $borderColor, $shadowing, $shape, "", $type, $legendText, "") + ' simulate color inheritance + UpdateBoundaryStyle("enterprise", $bgColor, $fontColor, $borderColor, $shadowing, $shape, "Enterprise", "") + UpdateBoundaryStyle("system", $bgColor, $fontColor, $borderColor, $shadowing, $shape, "System", "") + UpdateBoundaryStyle("container", $bgColor, $fontColor, $borderColor, $shadowing, $shape, "Container", "") + !endif +!endprocedure + +!unquoted procedure AddBoundaryTag($tagStereo, $bgColor="", $fontColor="", $borderColor="", $shadowing="", $shape="", $type="", $legendText="") + !$tagBoundary = $tagStereo + '_boundary' + AddElementTag($tagBoundary, $bgColor, $fontColor, $borderColor, $shadowing, $shape, "", $type, $legendText, "") +!endprocedure + +' add _boundary to all tags that short tag version can be used +!unquoted function $addBoundaryPostfix($tags) + !if (%strlen($tags) == 0) + !return '' + !endif + !$boundaryTags = '' + !$brPos = %strpos($tags, "+") + !while ($brPos >= 0) + !$tag = %substr($tags, 0, $brPos) + !$boundaryTags = $boundaryTags + $tag + '_boundary+' + !$tags = %substr($tags, $brPos+1) + !$brPos = %strpos($tags, "+") + !endwhile + !if (%strlen($tags) > 0) + !$boundaryTags = $boundaryTags + $tags + '_boundary' + !endif + !return $boundaryTags +!endfunction + !function $getBoundary($label, $type) !if ($type == "") - !return '==' + $label + !return '== ' + $breakLabel($label) !endif !if (type != "") - !return '==' + $label + '\n[' + $type + ']' + !return '== ' + $breakLabel($label) + '\n[' + $type + ']' !endif !endfunction !unquoted procedure Boundary($alias, $label, $type="", $tags="", $link="") -rectangle "$getBoundary($label, $type)" $toStereos("boundary", $tags) as $alias $getLink($link) +!$boundaryTags = $addBoundaryPostfix($tags) +' nodes $type reuses $techn definition of $boundaryTags +!$type=$toElementArg($type, $boundaryTags, "ElementTagTechn", "boundary") +rectangle "$getBoundary($label, $type)" $toStereos("boundary", $boundaryTags) as $alias $getLink($link) +!endprocedure + +' Boundary Styling +UpdateBoundaryStyle("", $bgColor=$BOUNDARY_BG_COLOR, $fontColor=$BOUNDARY_COLOR, $borderColor=$BOUNDARY_COLOR) + +' Index +' ################################## + +' Dynamic/Sequence diagram supports (automatically) numbered interactions: +' preferred function calls +' (Uppercase) LastIndex(): return the last used index (function which can be used as argument) +' (Uppercase) Index($offset=1): returns current index and calculates next index (function which can be used as argument) +' (Uppercase) SetIndex($new_index): returns new set index and calculates next index (function which can be used as argument) + +' old procedures calls +' (lowercase) increment($offset=1): increase current index (procedure which has no direct output) +' (lowercase) setIndex($new_index): set the new index (procedure which has no direct output) + +!$lastIndex = 0 +!$index = 1 + +!procedure increment($offset=1) + !$lastIndex = $index + !$index = $index + $offset !endprocedure +!procedure setIndex($new_index) + !$lastIndex = $index + !$index = $new_index +!endprocedure + +!function Index($offset=1) + !$lastIndex = $index + !$index = $lastIndex + $offset + !return $lastIndex +!endfunction + +!function LastIndex() + !return $lastIndex +!endfunction + +!function SetIndex($new_index, $offset=1) + !$lastIndex = $new_index + !$index = $new_index + $offset + !return $lastIndex +!endfunction + +!unquoted function $getPrefix($index) + !if ($index == "") + !$pre = Index() + ": " + !else + !$pre = $index + ": " + !endif + !return $pre +!endfunction + ' Relationship ' ################################## @@ -1002,13 +1356,26 @@ rectangle "$getBoundary($label, $type)" $toStereos("boundary", $tags) as $alias !$rel = $rel + ' ' + $toStereos($tags) !endif !$rel = $rel + ' : ' + !if ($link != "") + !$rel = $rel + '**[[' + $link + ' ' + !endif !if ($sprite != "") - !$rel = $rel + $getSprite($sprite) + ' ' + !$rel = $rel + $getSprite($sprite) + !if ($label != "") + !$rel = $rel + ' ' + !endif !endif !if ($link != "") - !$rel = $rel + '**[[' + $link + ' ' + $label + ']]**' + !$usedNewLine = ']]**\n**[[' + $link + ' ' + ' if sprite and label is empty than the link url is shown (otherwise link cannot be activated at all) + !$rel = $rel + $breakText($label, $usedNewLine) + ']]**' !else - !$rel = $rel + '**' + $label + '**' + !if ($label != "") + !$usedNewLine = '**\n**' + !$rel = $rel + '**' + $breakText($label, $usedNewLine) + '**' + !else + !$rel = $rel + '.' + !endif !endif !if ($techn != "") ' line break is not deterministic, calculate it @@ -1018,14 +1385,19 @@ rectangle "$getBoundary($label, $type)" $toStereos("boundary", $tags) as $alias ' line break is not deterministic, calculate it !$rel = $rel + '\n\n' + $breakDescr($descr, $REL_DESCR_MAX_CHAR_WIDTH) !endif + !$prop = $getProps() + !if ($prop != "") + ' reuse table + !$rel = $rel + $prop + !endif !return $rel !endfunction !unquoted procedure Rel_($alias1, $alias2, $label, $direction) -$alias1 $direction $alias2 : **$label** +$getRel($direction, $alias1, $alias2, $label, "", "", "", "", "") !endprocedure !unquoted procedure Rel_($alias1, $alias2, $label, $techn, $direction) -$alias1 $direction $alias2 : **$label**\n//[$techn]// +$getRel($direction, $alias1, $alias2, $label, $techn, "", "", "", "") !endprocedure !unquoted procedure Rel($from, $to, $label, $techn="", $descr="", $sprite="", $tags="", $link="") @@ -1118,19 +1490,34 @@ $getRel($right("<<-","->>"), $from, $to, $label, $techn, $descr, $sprite, $tags, !unquoted procedure Lay_D($from, $to) $from -[hidden]D- $to !endprocedure +!unquoted procedure Lay_Down($from, $to) +$from -[hidden]D- $to +!endprocedure + !unquoted procedure Lay_U($from, $to) $from -[hidden]U- $to !endprocedure +!unquoted procedure Lay_Up($from, $to) +$from -[hidden]U- $to +!endprocedure + !unquoted procedure Lay_R($from, $to) $from -[hidden]R- $to !endprocedure +!unquoted procedure Lay_Right($from, $to) +$from -[hidden]R- $to +!endprocedure + !unquoted procedure Lay_L($from, $to) $from -[hidden]L- $to !endprocedure +!unquoted procedure Lay_Left($from, $to) +$from -[hidden]L- $to +!endprocedure ' PlantUML bug: lines which does "not match" with the orientation/direction of the diagram -' uses the same length therefore the method offers no direction at all. +' use the same length therefore the method offers no direction at all. ' If a direction is required the Lay_...() methods can be used !unquoted procedure Lay_Distance($from, $to, $distance="0") $from $getHiddenLine($distance) $to -!endprocedure +!endprocedure \ No newline at end of file diff --git a/server/src/main/resources/c4_component.puml b/server/src/main/resources/c4_component.puml index 9d291dc1f..49a491cde 100644 --- a/server/src/main/resources/c4_component.puml +++ b/server/src/main/resources/c4_component.puml @@ -6,31 +6,32 @@ ' Colors ' ################################## -!global $COMPONENT_FONT_COLOR = "#000000" +!$COMPONENT_FONT_COLOR ?= "#000000" +!$COMPONENT_BG_COLOR ?= "#85BBF0" +!$COMPONENT_BORDER_COLOR ?= "#78A8D8" -!global $COMPONENT_BG_COLOR = "#85BBF0" -!global $COMPONENT_BORDER_COLOR = "#78A8D8" -!global $EXTERNAL_COMPONENT_BG_COLOR = "#CCCCCC" -!global $EXTERNAL_COMPONENT_BORDER_COLOR = "#BFBFBF" +!$EXTERNAL_COMPONENT_FONT_COLOR ?= $COMPONENT_FONT_COLOR +!$EXTERNAL_COMPONENT_BG_COLOR ?= "#CCCCCC" +!$EXTERNAL_COMPONENT_BORDER_COLOR ?= "#BFBFBF" ' Styling ' ################################## UpdateElementStyle("component", $COMPONENT_BG_COLOR, $COMPONENT_FONT_COLOR, $COMPONENT_BORDER_COLOR) -UpdateElementStyle("external_component", $EXTERNAL_COMPONENT_BG_COLOR, $COMPONENT_FONT_COLOR, $EXTERNAL_COMPONENT_BORDER_COLOR) +UpdateElementStyle("external_component", $EXTERNAL_COMPONENT_BG_COLOR, $EXTERNAL_COMPONENT_FONT_COLOR, $EXTERNAL_COMPONENT_BORDER_COLOR) ' shortcuts with default colors -!unquoted procedure AddComponentTag($tagStereo, $bgColor=$COMPONENT_BG_COLOR, $fontColor=$ELEMENT_FONT_COLOR, $borderColor=$COMPONENT_BORDER_COLOR, $shadowing="", $shape="", $sprite="", $techn="", $legendText="", $legendSprite="") - AddElementTag($tagStereo, $bgColor, $fontColor, $borderColor, $shadowing, $shape, $sprite, $techn, $legendText, $legendSprite) +!unquoted procedure AddComponentTag($tagStereo, $bgColor="", $fontColor="", $borderColor="", $shadowing="", $shape="", $sprite="", $techn="", $legendText="", $legendSprite="") + $addElementTagInclReuse("component", $tagStereo, $bgColor, $fontColor, $borderColor, $shadowing, $shape, $sprite, $techn, $legendText, $legendSprite) !endprocedure -!unquoted procedure AddExternalComponentTag($tagStereo, $bgColor=$EXTERNAL_COMPONENT_BG_COLOR, $fontColor=$ELEMENT_FONT_COLOR, $borderColor=$EXTERNAL_COMPONENT_BORDER_COLOR, $shadowing="", $shape="", $sprite="", $techn="", $legendText="", $legendSprite="") - AddElementTag($tagStereo, $bgColor, $fontColor, $borderColor, $shadowing, $shape, $sprite, $techn, $legendText, $legendSprite) +!unquoted procedure AddExternalComponentTag($tagStereo, $bgColor="", $fontColor="", $borderColor="", $shadowing="", $shape="", $sprite="", $techn="", $legendText="", $legendSprite="") + $addElementTagInclReuse("external_component", $tagStereo, $bgColor, $fontColor, $borderColor, $shadowing, $shape, $sprite, $techn, $legendText, $legendSprite) !endprocedure ' Layout ' ################################## -SetDefaultLegendEntries("person\nsystem\ncontainer\ncomponent\nexternal_person\nexternal_system\nexternal_container\nexternal_component") +SetDefaultLegendEntries("person\nsystem\ncontainer\ncomponent\nexternal_person\nexternal_system\nexternal_container\nexternal_component\nenterprise_boundary\nsystem_boundary\ncontainer_boundary\nboundary") !procedure LAYOUT_WITH_LEGEND() hide stereotype @@ -50,53 +51,26 @@ endlegend ' Elements ' ################################## -!function $getComponent($label, $techn, $descr, $sprite) -!if ($descr == "") && ($sprite == "") -!return '=='+$label+'\n//['+$techn+']//' -!endif -!if ($descr == "") && ($sprite != "") -!return $getSprite($sprite)+'\n=='+$label+'\n//['+$techn+']//' -!endif -!if ($descr != "") && ($sprite == "") -!return '=='+$label+'\n//['+$techn+']//\n\n '+$descr -!endif -!if ($descr != "") && ($sprite != "") -!return $getSprite($sprite)+'\n=='+$label+'\n//['+$techn+']//\n\n '+$descr -!endif -!endfunction - !unquoted procedure Component($alias, $label, $techn="", $descr="", $sprite="", $tags="", $link="") -!$sprite=$toElementArg($sprite, $tags, "ElementTagSprite", "component") -!$techn=$toElementArg($techn, $tags, "ElementTagTechn", "component") -rectangle "$getComponent($label, $techn, $descr, $sprite)$getProps()" $toStereos("component",$tags) as $alias $getLink($link) + $getElementLine("rectangle", "component", $alias, $label, $techn, $descr, $sprite, $tags, $link) !endprocedure !unquoted procedure ComponentDb($alias, $label, $techn="", $descr="", $sprite="", $tags="", $link="") -!$sprite=$toElementArg($sprite, $tags, "ElementTagSprite", "component") -!$techn=$toElementArg($techn, $tags, "ElementTagTechn", "component") -database "$getComponent($label, $techn, $descr, $sprite)$getProps()" $toStereos("component",$tags) as $alias $getLink($link) + $getElementLine("database", "component", $alias, $label, $techn, $descr, $sprite, $tags, $link) !endprocedure !unquoted procedure ComponentQueue($alias, $label, $techn="", $descr="", $sprite="", $tags="", $link="") -!$sprite=$toElementArg($sprite, $tags, "ElementTagSprite", "component") -!$techn=$toElementArg($techn, $tags, "ElementTagTechn", "component") -queue "$getComponent($label, $techn, $descr, $sprite)$getProps()" $toStereos("component",$tags) as $alias $getLink($link) + $getElementLine("queue", "component", $alias, $label, $techn, $descr, $sprite, $tags, $link) !endprocedure !unquoted procedure Component_Ext($alias, $label, $techn="", $descr="", $sprite="", $tags="", $link="") -!$sprite=$toElementArg($sprite, $tags, "ElementTagSprite", "external_component") -!$techn=$toElementArg($techn, $tags, "ElementTagTechn", "external_component") -rectangle "$getComponent($label, $techn, $descr, $sprite)$getProps()" $toStereos("external_component",$tags) as $alias $getLink($link) + $getElementLine("rectangle", "external_component", $alias, $label, $techn, $descr, $sprite, $tags, $link) !endprocedure !unquoted procedure ComponentDb_Ext($alias, $label, $techn="", $descr="", $sprite="", $tags="", $link="") -!$sprite=$toElementArg($sprite, $tags, "ElementTagSprite", "external_component") -!$techn=$toElementArg($techn, $tags, "ElementTagTechn", "external_component") -database "$getComponent($label, $techn, $descr, $sprite)$getProps()" $toStereos("external_component",$tags) as $alias $getLink($link) + $getElementLine("database", "external_component", $alias, $label, $techn, $descr, $sprite, $tags, $link) !endprocedure !unquoted procedure ComponentQueue_Ext($alias, $label, $techn="", $descr="", $sprite="", $tags="", $link="") -!$sprite=$toElementArg($sprite, $tags, "ElementTagSprite", "external_component") -!$techn=$toElementArg($techn, $tags, "ElementTagTechn", "external_component") -queue "$getComponent($label, $techn, $descr, $sprite)$getProps()" $toStereos("external_component",$tags) as $alias $getLink($link) -!endprocedure + $getElementLine("queue", "external_component", $alias, $label, $techn, $descr, $sprite, $tags, $link) +!endprocedure \ No newline at end of file diff --git a/server/src/main/resources/c4_container.puml b/server/src/main/resources/c4_container.puml index 7c337aca3..3c13c6f70 100644 --- a/server/src/main/resources/c4_container.puml +++ b/server/src/main/resources/c4_container.puml @@ -6,28 +6,41 @@ ' Colors ' ################################## -!global $CONTAINER_BG_COLOR = "#438DD5" -!global $CONTAINER_BORDER_COLOR = "#3C7FC0" -!global $EXTERNAL_CONTAINER_BG_COLOR = "#B3B3B3" -!global $EXTERNAL_CONTAINER_BORDER_COLOR = "#A6A6A6" +!$CONTAINER_FONT_COLOR ?= $ELEMENT_FONT_COLOR +!$CONTAINER_BG_COLOR ?= "#438DD5" +!$CONTAINER_BORDER_COLOR ?= "#3C7FC0" + +!$CONTAINER_BOUNDARY_COLOR ?= $BOUNDARY_COLOR +!$CONTAINER_BOUNDARY_BG_COLOR ?= $BOUNDARY_BG_COLOR +!$CONTAINER_BOUNDARY_BORDER_STYLE ?= $BOUNDARY_BORDER_STYLE + +!$EXTERNAL_CONTAINER_FONT_COLOR ?= $ELEMENT_FONT_COLOR +!$EXTERNAL_CONTAINER_BG_COLOR ?= "#B3B3B3" +!$EXTERNAL_CONTAINER_BORDER_COLOR ?= "#A6A6A6" ' Styling ' ################################## -UpdateElementStyle("container", $CONTAINER_BG_COLOR, $ELEMENT_FONT_COLOR, $CONTAINER_BORDER_COLOR) -UpdateElementStyle("external_container", $EXTERNAL_CONTAINER_BG_COLOR, $ELEMENT_FONT_COLOR, $EXTERNAL_CONTAINER_BORDER_COLOR) +UpdateElementStyle("container", $CONTAINER_BG_COLOR, $CONTAINER_FONT_COLOR, $CONTAINER_BORDER_COLOR) +UpdateElementStyle("external_container", $EXTERNAL_CONTAINER_BG_COLOR, $EXTERNAL_CONTAINER_FONT_COLOR, $EXTERNAL_CONTAINER_BORDER_COLOR) + +UpdateBoundaryStyle("container", $bgColor=$CONTAINER_BOUNDARY_BG_COLOR, $fontColor=$CONTAINER_BOUNDARY_COLOR, $borderColor=$CONTAINER_BOUNDARY_COLOR, $type="Container") ' shortcuts with default colors -!unquoted procedure AddContainerTag($tagStereo, $bgColor=$CONTAINER_BG_COLOR, $fontColor=$ELEMENT_FONT_COLOR, $borderColor=$CONTAINER_BORDER_COLOR, $shadowing="", $shape="", $sprite="", $techn="", $legendText="", $legendSprite="") - AddElementTag($tagStereo, $bgColor, $fontColor, $borderColor, $shadowing, $shape, $sprite, $techn, $legendText, $legendSprite) +!unquoted procedure AddContainerTag($tagStereo, $bgColor="", $fontColor="", $borderColor="", $shadowing="", $shape="", $sprite="", $techn="", $legendText="", $legendSprite="") + $addElementTagInclReuse("container", $tagStereo, $bgColor, $fontColor, $borderColor, $shadowing, $shape, $sprite, $techn, $legendText, $legendSprite) !endprocedure -!unquoted procedure AddExternalContainerTag($tagStereo, $bgColor=$EXTERNAL_CONTAINER_BG_COLOR, $fontColor=$ELEMENT_FONT_COLOR, $borderColor=$EXTERNAL_CONTAINER_BORDER_COLOR, $shadowing="", $shape="", $sprite="", $techn="", $legendText="", $legendSprite="") - AddElementTag($tagStereo, $bgColor, $fontColor, $borderColor, $shadowing, $shape, $sprite, $techn, $legendText, $legendSprite) +!unquoted procedure AddExternalContainerTag($tagStereo, $bgColor="", $fontColor="", $borderColor="", $shadowing="", $shape="", $sprite="", $techn="", $legendText="", $legendSprite="") + $addElementTagInclReuse("external_container", $tagStereo, $bgColor, $fontColor, $borderColor, $shadowing, $shape, $sprite, $techn, $legendText, $legendSprite) +!endprocedure + +!unquoted procedure UpdateContainerBoundaryStyle($bgColor=$CONTAINER_BOUNDARY_BG_COLOR, $fontColor=$CONTAINER_BOUNDARY_COLOR, $borderColor=$CONTAINER_BOUNDARY_COLOR, $shadowing="", $shape="", $type="Container", $legendText="") + UpdateBoundaryStyle("container", $bgColor, $fontColor, $borderColor, $shadowing, $shape, $type, $legendText) !endprocedure ' Layout ' ################################## -SetDefaultLegendEntries("person\nsystem\ncontainer\nexternal_person\nexternal_system\nexternal_container") +SetDefaultLegendEntries("person\nsystem\ncontainer\nexternal_person\nexternal_system\nexternal_container\nenterprise_boundary\nsystem_boundary\ncontainer_boundary\nboundary") !procedure LAYOUT_WITH_LEGEND() hide stereotype @@ -45,60 +58,39 @@ endlegend ' Elements ' ################################## -!function $getContainer($label, $techn, $descr, $sprite) -!if ($descr == "") && ($sprite == "") -!return '=='+$label+'\n//['+$techn+']//' -!endif -!if ($descr == "") && ($sprite != "") -!return $getSprite($sprite)+'\n=='+$label+'\n//['+$techn+']//' -!endif -!if ($descr != "") && ($sprite == "") -!return '=='+$label+'\n//['+$techn+']//\n\n '+$descr -!endif -!if ($descr != "") && ($sprite != "") -!return $getSprite($sprite)+'\n=='+$label+'\n//['+$techn+']//\n\n '+$descr -!endif -!endfunction - !unquoted procedure Container($alias, $label, $techn="", $descr="", $sprite="", $tags="", $link="") -!$sprite=$toElementArg($sprite, $tags, "ElementTagSprite", "container") -!$techn=$toElementArg($techn, $tags, "ElementTagTechn", "container") -rectangle "$getContainer($label, $techn, $descr, $sprite)$getProps()" $toStereos("container", $tags) as $alias $getLink($link) + $getElementLine("rectangle", "container", $alias, $label, $techn, $descr, $sprite, $tags, $link) !endprocedure !unquoted procedure ContainerDb($alias, $label, $techn="", $descr="", $sprite="", $tags="", $link="") -!$sprite=$toElementArg($sprite, $tags, "ElementTagSprite", "container") -!$techn=$toElementArg($techn, $tags, "ElementTagTechn", "container") -database "$getContainer($label, $techn, $descr, $sprite)$getProps()" $toStereos("container", $tags) as $alias $getLink($link) + $getElementLine("database", "container", $alias, $label, $techn, $descr, $sprite, $tags, $link) !endprocedure !unquoted procedure ContainerQueue($alias, $label, $techn="", $descr="", $sprite="", $tags="", $link="") -!$sprite=$toElementArg($sprite, $tags, "ElementTagSprite", "container") -!$techn=$toElementArg($techn, $tags, "ElementTagTechn", "container") -queue "$getContainer($label, $techn, $descr, $sprite)$getProps()" $toStereos("container", $tags) as $alias $getLink($link) + $getElementLine("queue", "container", $alias, $label, $techn, $descr, $sprite, $tags, $link) !endprocedure !unquoted procedure Container_Ext($alias, $label, $techn="", $descr="", $sprite="", $tags="", $link="") -!$sprite=$toElementArg($sprite, $tags, "ElementTagSprite", "external_container") -!$techn=$toElementArg($techn, $tags, "ElementTagTechn", "external_container") -rectangle "$getContainer($label, $techn, $descr, $sprite)$getProps()" $toStereos("external_container", $tags) as $alias $getLink($link) + $getElementLine("rectangle", "external_container", $alias, $label, $techn, $descr, $sprite, $tags, $link) !endprocedure !unquoted procedure ContainerDb_Ext($alias, $label, $techn="", $descr="", $sprite="", $tags="", $link="") -!$sprite=$toElementArg($sprite, $tags, "ElementTagSprite", "external_container") -!$techn=$toElementArg($techn, $tags, "ElementTagTechn", "external_container") -database "$getContainer($label, $techn, $descr, $sprite)$getProps()" $toStereos("external_container", $tags) as $alias $getLink($link) + $getElementLine("database", "external_container", $alias, $label, $techn, $descr, $sprite, $tags, $link) !endprocedure !unquoted procedure ContainerQueue_Ext($alias, $label, $techn="", $descr="", $sprite="", $tags="", $link="") -!$sprite=$toElementArg($sprite, $tags, "ElementTagSprite", "external_container") -!$techn=$toElementArg($techn, $tags, "ElementTagTechn", "external_container") -queue "$getContainer($label, $techn, $descr, $sprite)$getProps()" $toStereos("external_container", $tags) as $alias $getLink($link) + $getElementLine("queue", "external_container", $alias, $label, $techn, $descr, $sprite, $tags, $link) !endprocedure ' Boundaries ' ################################## !unquoted procedure Container_Boundary($alias, $label, $tags="", $link="") -Boundary($alias, $label, "Container", $tags, $link) -!endprocedure + !if ($tags != "") + !$allTags = $tags + '+container' + !else + !$allTags = 'container' + !endif + ' $type defined via $tag style + Boundary($alias, $label, "", $allTags, $link) +!endprocedure \ No newline at end of file diff --git a/server/src/main/resources/c4_context.puml b/server/src/main/resources/c4_context.puml index 1a8d3be24..9a385c72f 100644 --- a/server/src/main/resources/c4_context.puml +++ b/server/src/main/resources/c4_context.puml @@ -6,35 +6,60 @@ ' Colors ' ################################## -!global $PERSON_BG_COLOR = "#08427B" -!global $PERSON_BORDER_COLOR = "#073B6F" -!global $EXTERNAL_PERSON_BG_COLOR = "#686868" -!global $EXTERNAL_PERSON_BORDER_COLOR = "#8A8A8A" -!global $SYSTEM_BG_COLOR = "#1168BD" -!global $SYSTEM_BORDER_COLOR = "#3C7FC0" -!global $EXTERNAL_SYSTEM_BG_COLOR = "#999999" -!global $EXTERNAL_SYSTEM_BORDER_COLOR = "#8A8A8A" +!$PERSON_FONT_COLOR ?= $ELEMENT_FONT_COLOR +!$PERSON_BG_COLOR ?= "#08427B" +!$PERSON_BORDER_COLOR ?= "#073B6F" + +!$EXTERNAL_PERSON_FONT_COLOR ?= $ELEMENT_FONT_COLOR +!$EXTERNAL_PERSON_BG_COLOR ?= "#686868" +!$EXTERNAL_PERSON_BORDER_COLOR ?= "#8A8A8A" + +!$SYSTEM_FONT_COLOR ?= $ELEMENT_FONT_COLOR +!$SYSTEM_BG_COLOR ?= "#1168BD" +!$SYSTEM_BORDER_COLOR ?= "#3C7FC0" + +!$SYSTEM_BOUNDARY_COLOR ?= $BOUNDARY_COLOR +!$SYSTEM_BOUNDARY_BG_COLOR ?= $BOUNDARY_BG_COLOR +!$SYSTEM_BOUNDARY_BORDER_STYLE ?= $BOUNDARY_BORDER_STYLE + +!$EXTERNAL_SYSTEM_FONT_COLOR ?= $ELEMENT_FONT_COLOR +!$EXTERNAL_SYSTEM_BG_COLOR ?= "#999999" +!$EXTERNAL_SYSTEM_BORDER_COLOR ?= "#8A8A8A" + +!$ENTERPRISE_BOUNDARY_COLOR ?= $BOUNDARY_COLOR +!$ENTERPRISE_BOUNDARY_BG_COLOR ?= $BOUNDARY_BG_COLOR +!$ENTERPRISE_BOUNDARY_BORDER_STYLE ?= $BOUNDARY_BORDER_STYLE ' Styling ' ################################## -UpdateElementStyle("person", $PERSON_BG_COLOR, $ELEMENT_FONT_COLOR, $PERSON_BORDER_COLOR) -UpdateElementStyle("external_person", $EXTERNAL_PERSON_BG_COLOR, $ELEMENT_FONT_COLOR, $EXTERNAL_PERSON_BORDER_COLOR) -UpdateElementStyle("system", $SYSTEM_BG_COLOR, $ELEMENT_FONT_COLOR, $SYSTEM_BORDER_COLOR) -UpdateElementStyle("external_system", $EXTERNAL_SYSTEM_BG_COLOR, $ELEMENT_FONT_COLOR, $EXTERNAL_SYSTEM_BORDER_COLOR) +UpdateElementStyle("person", $PERSON_BG_COLOR, $PERSON_FONT_COLOR, $PERSON_BORDER_COLOR) +UpdateElementStyle("external_person", $EXTERNAL_PERSON_BG_COLOR, $EXTERNAL_PERSON_FONT_COLOR, $EXTERNAL_PERSON_BORDER_COLOR) +UpdateElementStyle("system", $SYSTEM_BG_COLOR, $SYSTEM_FONT_COLOR, $SYSTEM_BORDER_COLOR) +UpdateElementStyle("external_system", $EXTERNAL_SYSTEM_BG_COLOR, $EXTERNAL_SYSTEM_FONT_COLOR, $EXTERNAL_SYSTEM_BORDER_COLOR) + +UpdateBoundaryStyle("system", $bgColor=$SYSTEM_BOUNDARY_BG_COLOR, $fontColor=$SYSTEM_BOUNDARY_COLOR, $borderColor=$SYSTEM_BOUNDARY_COLOR, $type="System") +UpdateBoundaryStyle("enterprise", $bgColor=$ENTERPRISE_BOUNDARY_BG_COLOR, $fontColor=$ENTERPRISE_BOUNDARY_COLOR, $borderColor=$ENTERPRISE_BOUNDARY_COLOR, $type="Enterprise") ' shortcuts with default colors -!unquoted procedure AddPersonTag($tagStereo, $bgColor=$PERSON_BG_COLOR, $fontColor=$ELEMENT_FONT_COLOR, $borderColor=$PERSON_BORDER_COLOR, $shadowing="", $shape="", $sprite="", $legendText="", $legendSprite="") - AddElementTag($tagStereo, $bgColor, $fontColor, $borderColor, $shadowing, $shape, $sprite, "", $legendText, $legendSprite) +!unquoted procedure AddPersonTag($tagStereo, $bgColor="", $fontColor="", $borderColor="", $shadowing="", $shape="", $sprite="", $legendText="", $legendSprite="", $type="") + $addElementTagInclReuse("person", $tagStereo, $bgColor, $fontColor, $borderColor, $shadowing, $shape, $sprite, $type, $legendText, $legendSprite) !endprocedure -!unquoted procedure AddExternalPersonTag($tagStereo, $bgColor=$EXTERNAL_PERSON_BG_COLOR, $fontColor=$ELEMENT_FONT_COLOR, $borderColor=$EXTERNAL_PERSON_BORDER_COLOR, $shadowing="", $shape="", $sprite="", $legendText="", $legendSprite="") - AddElementTag($tagStereo, $bgColor, $fontColor, $borderColor, $shadowing, $shape, $sprite, "", $legendText, $legendSprite) +!unquoted procedure AddExternalPersonTag($tagStereo, $bgColor="", $fontColor="", $borderColor="", $shadowing="", $shape="", $sprite="", $legendText="", $legendSprite="", $type="") + $addElementTagInclReuse("external_person", $tagStereo, $bgColor, $fontColor, $borderColor, $shadowing, $shape, $sprite, $type, $legendText, $legendSprite) !endprocedure -!unquoted procedure AddSystemTag($tagStereo, $bgColor=$SYSTEM_BG_COLOR, $fontColor=$ELEMENT_FONT_COLOR, $borderColor=$SYSTEM_BORDER_COLOR, $shadowing="", $shape="", $sprite="", $legendText="", $legendSprite="") - AddElementTag($tagStereo, $bgColor, $fontColor, $borderColor, $shadowing, $shape, $sprite, "", $legendText, $legendSprite) +!unquoted procedure AddSystemTag($tagStereo, $bgColor="", $fontColor="", $borderColor="", $shadowing="", $shape="", $sprite="", $legendText="", $legendSprite="", $type="") + $addElementTagInclReuse("system", $tagStereo, $bgColor, $fontColor, $borderColor, $shadowing, $shape, $sprite, $type, $legendText, $legendSprite) !endprocedure -!unquoted procedure AddExternalSystemTag($tagStereo, $bgColor=$EXTERNAL_SYSTEM_BG_COLOR, $fontColor=$ELEMENT_FONT_COLOR, $borderColor=$EXTERNAL_SYSTEM_BORDER_COLOR, $shadowing="", $shape="", $sprite="", $legendText="", $legendSprite="") - AddElementTag($tagStereo, $bgColor, $fontColor, $borderColor, $shadowing, $shape, $sprite, "", $legendText, $legendSprite) +!unquoted procedure AddExternalSystemTag($tagStereo, $bgColor="", $fontColor="", $borderColor="", $shadowing="", $shape="", $sprite="", $legendText="", $legendSprite="", $type="") + $addElementTagInclReuse("external_system", $tagStereo, $bgColor, $fontColor, $borderColor, $shadowing, $shape, $sprite, $type, $legendText, $legendSprite) +!endprocedure + +!unquoted procedure UpdateEnterpriseBoundaryStyle($bgColor=$ENTERPRISE_BOUNDARY_BG_COLOR, $fontColor=$ENTERPRISE_BOUNDARY_COLOR, $borderColor=$ENTERPRISE_BOUNDARY_COLOR, $shadowing="", $shape="", $type="Enterprise", $legendText="") + UpdateBoundaryStyle("enterprise", $bgColor, $fontColor, $borderColor, $shadowing, $shape, $type, $legendText) +!endprocedure +!unquoted procedure UpdateSystemBoundaryStyle($bgColor=$SYSTEM_BOUNDARY_BG_COLOR, $fontColor=$SYSTEM_BOUNDARY_COLOR, $borderColor=$SYSTEM_BOUNDARY_COLOR, $shadowing="", $shape="", $type="System", $legendText="") + UpdateBoundaryStyle("system", $bgColor, $fontColor, $borderColor, $shadowing, $shape, $type, $legendText) !endprocedure ' Sprites @@ -142,10 +167,112 @@ sprite $person2 [48x48/16] { 000000000002578888888888888888888864100000000000 } +sprite $robot [48x48/16] { +000000000000000000000000000000000000000000000000 +000000000000000000000000000000000000000000000000 +000000000000000000000000000000000000000000000000 +000000000000000000000000000000000000000000000000 +000000000000000000000000000000000000000000000000 +000000000000000000000000000000000000000000000000 +000000000000000000000000000000000000000000000000 +000000000000000000000000000000000000000000000000 +000000000000000000000000000000000000000000000000 +000000000000000000000000000000000000000000000000 +000000000005BFFFFFFFFFFFFFFFFFFFFFE9100000000000 +0000000000AFFFFFFFFFFFFFFFFFFFFFFFFFE30000000000 +0000000007FFFFFFFFFFFFFFFFFFFFFFFFFFFE1000000000 +000000000FFFFFFFFFFFFFFFFFFFFFFFFFFFFF8000000000 +000000004FFFFFFFFFFFFFFFFFFFFFFFFFFFFFC000000000 +000000005FFFFFFFFFFFFFFFFFFFFFFFFFFFFFD000000000 +000000005FFFFFFFFFFFFFFFFFFFFFFFFFFFFFE000000000 +000000005FFFFFFFFFFFFFFFFFFFFFFFFFFFFFE000000000 +000699405FFFFFFC427FFFFFFFFFC427FFFFFFE009982000 +008FFF705FFFFFE10006FFFFFFFE00007FFFFFE00FFFF100 +00CFFF705FFFFFA00001FFFFFFF900002FFFFFE00FFFF500 +00DFFF705FFFFFB00002FFFFFFFA00003FFFFFE00FFFF500 +00DFFF705FFFFFF4000AFFFFFFFF3000BFFFFFE00FFFF500 +00DFFF705FFFFFFFA8DFFFFFFFFFFA8DFFFFFFE00FFFF500 +00DFFF705FFFFFFFFFFFFFFFFFFFFFFFFFFFFFE00FFFF500 +00DFFF705FFFFFFFFFFFFFFFFFFFFFFFFFFFFFE00FFFF500 +00DFFF705FFFFFFFFFFFFFFFFFFFFFFFFFFFFFE00FFFF500 +00DFFF705FFFFFFFFFFFFFFFFFFFFFFFFFFFFFE00FFFF500 +00DFFF705FFFFFFFFFFFFFFFFFFFFFFFFFFFFFE00FFFF500 +00CFFF705FFFFFF87777777777777777CFFFFFE00FFFF500 +008FFF705FFFFFF100000000000000009FFFFFE00FFFF100 +000699405FFFFFF76666666666666666CFFFFFE009982000 +000000005FFFFFFFFFFFFFFFFFFFFFFFFFFFFFE000000000 +000000005FFFFFFFFFFFFFFFFFFFFFFFFFFFFFE000000000 +000000004FFFFFFFFFFFFFFFFFFFFFFFFFFFFFC000000000 +000000000EFFFFFFFFFFFFFFFFFFFFFFFFFFFF7000000000 +0000000005FFFFFFFFFFFFFFFFFFFFFFFFFFFD0000000000 +00000000004CFFFFFFFFFFFFFFFFFFFFFFFF910000000000 +000000000000011111111111111111111110000000000000 +000000000000000000000000000000000000000000000000 +000000000000000000000000000000000000000000000000 +000000000000000000000000000000000000000000000000 +000000000000000000000000000000000000000000000000 +000000000000000000000000000000000000000000000000 +000000000000000000000000000000000000000000000000 +000000000000000000000000000000000000000000000000 +000000000000000000000000000000000000000000000000 +000000000000000000000000000000000000000000000000 +} + +sprite $robot2 [48x48/16] { +000000000000000088888888888888880000000000000000 +000000000000000AFFFFFFFFFFFFFFFFA000000000000000 +00000000000000CFFFFFFFFFFFFFFFFFFC00000000000000 +00000000000004EFFFFFFFFFFFFFFFFFFE40000000000000 +0000000000000AFFFFFFFFFFFFFFFFFFFFA0000000000000 +00000000000008FFFFFFFFFFFFFFFFFFFF80000000000000 +00000000000008FFFFFFFFFFFFFFFFFFFF80000000000000 +00000000000008FFFFFFFFFFFFFFFFFFFF80000000000000 +00000000000888FFFFFFFFFFFFFFFFFFFF88800000000000 +00000000008FF8FFFFFFFFFFFFFFFFFFFF8FF80000000000 +00000000008FF8FFFFFFFFFFFFFFFFFFFF8FF80000000000 +00000000008FF8FFFFFFFFFFFFFFFFFFFF8FF80000000000 +00000000008FF8FFFFFFFFFFFFFFFFFFFF8FF80000000000 +00000000008FF8FFFFFFFFFFFFFFFFFFFF8FF80000000000 +00000000008FF8FFFFFFFFFFFFFFFFFFFF8FF80000000000 +00000000000888FFFFFFFFFFFFFFFFFFFF88800000000000 +00000000000008FFFFFFFFFFFFFFFFFFFF80000000000000 +00000000000008FFFFFFFFFFFFFFFFFFFF80000000000000 +00000000000008FFFFFFFFFFFFFFFFFFFF80000000000000 +00000000000008FFFFFFFFFFFFFFFFFFFF80000000000000 +00000000000008FFFFFFFFFFFFFFFFFFFF80000000000000 +00000000000004CFFFFFFFFFFFFFFFFFFC40000000000000 +000000488888848CFFFFFFFFFFFFFFFFC848888884000000 +00000CFFFFFFFFC888888888888888888CFFFFFFFFC00000 +00008FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF80000 +0000CFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFC0000 +0008FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF8000 +0008FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF8000 +0008FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF8000 +0008FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF8000 +0008FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF8000 +0008FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF8000 +0008FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF8000 +0008FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF8000 +0008FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF8000 +0008FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF8000 +0008FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF8000 +0008FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF8000 +0008FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF8000 +0008FFFFFFFF8FFFFFFFFFFFFFFFFFFFFFF8FFFFFFFF8000 +0008FFFFFFFF8FFFFFFFFFFFFFFFFFFFFFF8FFFFFFFF8000 +0008FFFFFFFF8FFFFFFFFFFFFFFFFFFFFFF8FFFFFFFF8000 +0008FFFFFFFF8FFFFFFFFFFFFFFFFFFFFFF8FFFFFFFF8000 +0000CFFFFFFF8FFFFFFFFFFFFFFFFFFFFFF8FFFFFFFC0000 +00008FFFFFFF8FFFFFFFFFFFFFFFFFFFFFF8FFFFFFF80000 +00000CFFFFFF8FFFFFFFFFFFFFFFFFFFFFF8FFFFFFC00000 +000000488887578888888888888888888864688884000000 +000000000000000000000000000000000000000000000000 +} + ' Layout ' ################################## -SetDefaultLegendEntries("person\nsystem\nexternal_person\nexternal_system") +SetDefaultLegendEntries("person\nsystem\nexternal_person\nexternal_system\nenterprise_boundary\nsystem_boundary\nboundary") !procedure LAYOUT_WITH_LEGEND() hide stereotype @@ -159,11 +286,29 @@ endlegend !endprocedure !global $defaultPersonSprite = "person" +!$dummy = $restoreEmpty("person", "sprite", $defaultPersonSprite, %true()) +UpdateElementStyle("person") +' workaround of plantuml.jar bug - person overwrites external_person setting +!$dummy = $restoreEmpty("external_person", "sprite", $defaultPersonSprite, %true()) +UpdateElementStyle("external_person") !global $portraitPerson = "false" +!procedure $clearPersonRestore() + !$dummy = $clearRestore("person", "sprite") + !$dummy = $clearRestore("person", "legendSprite") + %set_variable_value("$" + "person" + "ElementTagSprite", "") + UpdateElementStyle("person") + ' workaround of plantuml.jar bug - person overwrites external_person setting + !$dummy = $clearRestore("external_person", "sprite") + !$dummy = $clearRestore("external_person", "legendSprite") + %set_variable_value("$" + "external_person" + "ElementTagSprite", "") + UpdateElementStyle("external_person") +!endprocedure + !procedure HIDE_PERSON_SPRITE() !$defaultPersonSprite = "" !$portraitPerson = "false" + $clearPersonRestore() !endprocedure !unquoted procedure SHOW_PERSON_SPRITE($sprite="") @@ -172,114 +317,111 @@ endlegend !else !$defaultPersonSprite = $sprite !endif + !$dummy = $restoreEmpty("person", "sprite", $defaultPersonSprite, %true()) + UpdateElementStyle("person") + ' workaround of plantuml.jar bug - person overwrites external_person setting + !$dummy = $restoreEmpty("external_person", "sprite", $defaultPersonSprite, %true()) + UpdateElementStyle("external_person") !$portraitPerson = "false" !endprocedure !unquoted procedure SHOW_PERSON_PORTRAIT() !$defaultPersonSprite = "" !$portraitPerson = "portrait" + $clearPersonRestore() !endprocedure !unquoted procedure SHOW_PERSON_OUTLINE() !$defaultPersonSprite = "" !$portraitPerson = "outline" + $clearPersonRestore() !endprocedure ' Elements ' ################################## -!function $getPerson($label, $descr, $sprite) -!if ($sprite == "") && ($defaultPersonSprite != "") - !$sprite = $defaultPersonSprite -!endif -!if ($descr == "") && ($sprite == "") - !return '=='+$label -!endif -!if ($descr == "") && ($sprite != "") - !return $getSprite($sprite)+'\n=='+$label -!endif -!if ($descr != "") && ($sprite == "") - !return '=='+$label+'\n\n '+$descr -!endif -!if ($descr != "") && ($sprite != "") - !return $getSprite($sprite)+'\n=='+$label+'\n\n '+$descr -!endif -!endfunction - -!function $getSystem($label, $descr, $sprite) -!if ($descr == "") && ($sprite == "") -!return '=='+$label -!endif -!if ($descr == "") && ($sprite != "") -!return $getSprite($sprite)+'\n=='+$label -!endif -!if ($descr != "") && ($sprite == "") -!return '=='+$label+'\n\n '+$descr -!endif -!if ($descr != "") && ($sprite != "") -!return $getSprite($sprite)+'\n=='+$label+'\n\n '+$descr -!endif +!function $getPerson($label, $type, $descr, $sprite) + !if ($sprite == "") && ($defaultPersonSprite != "") + !$sprite = $defaultPersonSprite + !endif + !return $getElementBase($label, $type, $descr, $sprite) !endfunction -!unquoted procedure Person($alias, $label, $descr="", $sprite="", $tags="", $link="") +!unquoted procedure Person($alias, $label, $descr="", $sprite="", $tags="", $link="", $type="") !$sprite=$toElementArg($sprite, $tags, "ElementTagSprite", "person") +' $type reuses $techn definition of $tags +!$type=$toElementArg($type, $tags, "ElementTagTechn", "person") !if ($portraitPerson == "portrait") && ($sprite == "") -actor "$getPerson($label, $descr, $sprite)$getProps()" $toStereos("person", $tags) as $alias $getLink($link) +actor "$getPerson($label, $type, $descr, $sprite)$getProps()" $toStereos("person", $tags) as $alias $getLink($link) !elseif ($portraitPerson == "outline") && ($sprite == "") -person "$getPerson($label, $descr, $sprite)$getProps()" $toStereos("person", $tags) as $alias $getLink($link) +person "$getPerson($label, $type, $descr, $sprite)$getProps()" $toStereos("person", $tags) as $alias $getLink($link) !else -rectangle "$getPerson($label, $descr, $sprite)$getProps()" $toStereos("person", $tags) as $alias $getLink($link) +rectangle "$getPerson($label, $type, $descr, $sprite)$getProps()" $toStereos("person", $tags) as $alias $getLink($link) !endif !endprocedure -!unquoted procedure Person_Ext($alias, $label, $descr="", $sprite="", $tags="", $link="") +!unquoted procedure Person_Ext($alias, $label, $descr="", $sprite="", $tags="", $link="", $type="") !$sprite=$toElementArg($sprite, $tags, "ElementTagSprite", "external_person") +' $type reuses $techn definition of $tags +!$type=$toElementArg($type, $tags, "ElementTagTechn", "external_person") !if ($portraitPerson == "portrait") && ($sprite == "") -actor "$getPerson($label, $descr, $sprite)$getProps()" $toStereos("external_person", $tags) as $alias $getLink($link) +actor "$getPerson($label, $type, $descr, $sprite)$getProps()" $toStereos("external_person", $tags) as $alias $getLink($link) !elseif ($portraitPerson == "outline") && ($sprite == "") -person "$getPerson($label, $descr, $sprite)$getProps()" $toStereos("external_person", $tags) as $alias $getLink($link) +person "$getPerson($label, $type, $descr, $sprite)$getProps()" $toStereos("external_person", $tags) as $alias $getLink($link) !else -rectangle "$getPerson($label, $descr, $sprite)$getProps()" $toStereos("external_person", $tags) as $alias $getLink($link) +rectangle "$getPerson($label, $type, $descr, $sprite)$getProps()" $toStereos("external_person", $tags) as $alias $getLink($link) !endif !endprocedure -!unquoted procedure System($alias, $label, $descr="", $sprite="", $tags="", $link="") -!$sprite=$toElementArg($sprite, $tags, "ElementTagSprite", "system") -rectangle "$getSystem($label, $descr, $sprite)$getProps()" $toStereos("system", $tags) as $alias $getLink($link) +!unquoted procedure System($alias, $label, $descr="", $sprite="", $tags="", $link="", $type="") + ' $type reuses $techn definition of $tags + $getElementLine("rectangle", "system", $alias, $label, $type, $descr, $sprite, $tags, $link) !endprocedure -!unquoted procedure System_Ext($alias, $label, $descr="", $sprite="", $tags="", $link="") -!$sprite=$toElementArg($sprite, $tags, "ElementTagSprite", "external_system") -rectangle "$getSystem($label, $descr, $sprite)$getProps()" $toStereos("external_system", $tags) as $alias $getLink($link) +!unquoted procedure SystemDb($alias, $label, $descr="", $sprite="", $tags="", $link="", $type="") + ' $type reuses $techn definition of $tags + $getElementLine("database", "system", $alias, $label, $type, $descr, $sprite, $tags, $link) !endprocedure -!unquoted procedure SystemDb($alias, $label, $descr="", $sprite="", $tags="", $link="") -!$sprite=$toElementArg($sprite, $tags, "ElementTagSprite", "system") -database "$getSystem($label, $descr, $sprite)$getProps()" $toStereos("system", $tags) as $alias $getLink($link) +!unquoted procedure SystemQueue($alias, $label, $descr="", $sprite="", $tags="", $link="", $type="") + ' $type reuses $techn definition of $tags + $getElementLine("queue", "system", $alias, $label, $type, $descr, $sprite, $tags, $link) !endprocedure -!unquoted procedure SystemQueue($alias, $label, $descr="", $sprite="", $tags="", $link="") -!$sprite=$toElementArg($sprite, $tags, "ElementTagSprite", "system") -queue "$getSystem($label, $descr, $sprite)$getProps()" $toStereos("system", $tags) as $alias $getLink($link) +!unquoted procedure System_Ext($alias, $label, $descr="", $sprite="", $tags="", $link="", $type="") + ' $type reuses $techn definition of $tags + $getElementLine("rectangle", "external_system", $alias, $label, $type, $descr, $sprite, $tags, $link) !endprocedure -!unquoted procedure SystemDb_Ext($alias, $label, $descr="", $sprite="", $tags="", $link="") -!$sprite=$toElementArg($sprite, $tags, "ElementTagSprite", "external_system") -database "$getSystem($label, $descr, $sprite)$getProps()" $toStereos("external_system", $tags) as $alias $getLink($link) +!unquoted procedure SystemDb_Ext($alias, $label, $descr="", $sprite="", $tags="", $link="", $type="") + ' $type reuses $techn definition of $tags + $getElementLine("database", "external_system", $alias, $label, $type, $descr, $sprite, $tags, $link) !endprocedure -!unquoted procedure SystemQueue_Ext($alias, $label, $descr="", $sprite="", $tags="", $link="") -!$sprite=$toElementArg($sprite, $tags, "ElementTagSprite", "external_system") -queue "$getSystem($label, $descr, $sprite)$getProps()" $toStereos("external_system", $tags) as $alias $getLink($link) +!unquoted procedure SystemQueue_Ext($alias, $label, $descr="", $sprite="", $tags="", $link="", $type="") + ' $type reuses $techn definition of $tags + $getElementLine("queue", "external_system", $alias, $label, $type, $descr, $sprite, $tags, $link) !endprocedure ' Boundaries ' ################################## !unquoted procedure Enterprise_Boundary($alias, $label, $tags="", $link="") -Boundary($alias, $label, "Enterprise", $tags, $link) + !if ($tags != "") + !$allTags = $tags + '+enterprise' + !else + !$allTags = 'enterprise' + !endif + ' $type defined via $tag style + Boundary($alias, $label, "", $allTags, $link) !endprocedure !unquoted procedure System_Boundary($alias, $label, $tags="", $link="") -Boundary($alias, $label, "System", $tags, $link) -!endprocedure + !if ($tags != "") + !$allTags = $tags + '+system' + !else + !$allTags = 'system' + !endif + ' $type defined via $tag style + Boundary($alias, $label, "", $allTags, $link) +!endprocedure \ No newline at end of file diff --git a/server/src/main/resources/c4_deployment.puml b/server/src/main/resources/c4_deployment.puml index ae9bf0283..3416aa944 100644 --- a/server/src/main/resources/c4_deployment.puml +++ b/server/src/main/resources/c4_deployment.puml @@ -1,74 +1,45 @@ ' Colors ' ################################## -!global $NODE_FONT_COLOR = "#000000" -!global $NODE_BG_COLOR = "#FFFFFF" -!global $NODE_BORDER_COLOR = "#A2A2A2" +!$NODE_FONT_COLOR ?= "#000000" +!$NODE_BG_COLOR ?= "#FFFFFF" +!$NODE_BORDER_COLOR ?= "#A2A2A2" ' Styling ' ################################## +' PlantUML supports no automatic line breaks of "PlantUML containers" (C4 Deployment_Node is a "PlantUML container") +' therefore (Deployment_)Node() implements an automatic line break based on spaces (like in all other objects). +' If a $type contains \n then these are used (and no automatic space based line breaks are done) +' $NODE_TYPE_MAX_CHAR_WIDTH defines the automatic line break position +!$NODE_TYPE_MAX_CHAR_WIDTH ?= 35 +!$NODE_DESCR_MAX_CHAR_WIDTH ?= 32 + UpdateElementStyle("node", $bgColor=$NODE_BG_COLOR, $fontColor=$NODE_FONT_COLOR, $borderColor=$NODE_BORDER_COLOR) skinparam rectangle<> { FontStyle normal } ' shortcuts with default colors -' node specific: $type reuses $techn definition of $tags -!unquoted procedure AddNodeTag($tagStereo, $bgColor=$NODE_BG_COLOR, $fontColor=$NODE_FONT_COLOR, $borderColor=$NODE_BORDER_COLOR, $shadowing="", $shape="", $sprite="", $techn="", $legendText="", $legendSprite="") - AddElementTag($tagStereo, $bgColor, $fontColor, $borderColor, $shadowing, $shape, $sprite, $techn, $legendText, $legendSprite) +' node specific: $techn is only used in old scripts, new scripts uses $type ($techn has to remain, it could be called via named argument) +!unquoted procedure AddNodeTag($tagStereo, $bgColor="", $fontColor="", $borderColor="", $shadowing="", $shape="", $sprite="", $type="", $legendText="", $legendSprite="", $techn="") + !$type=$type+$techn + $addElementTagInclReuse("node", $tagStereo, $bgColor, $fontColor, $borderColor, $shadowing, $shape, $sprite, $type, $legendText, $legendSprite) !endprocedure ' Layout ' ################################## ' comment if node should not be added to legend. No calculated legend extension required -SetDefaultLegendEntries("person\nsystem\ncontainer\nexternal_person\nexternal_system\nexternal_container\nnode") +SetDefaultLegendEntries("person\nsystem\ncontainer\nexternal_person\nexternal_system\nexternal_container\nnode\nenterprise_boundary\nsystem_boundary\ncontainer_boundary\nboundary") ' Line breaks ' ################################## -' PlantUML supports no automatic line breaks of "PlantUML containers" (C4 Deployment_Node is a "PlantUML container") -' therefore (Deployment_)Node() implements an automatic line break based on spaces (like in all other objects). -' If a $type contains \n then these are used (and no automatic space based line breaks are done) -' $NODE_TYPE_MAX_CHAR_WIDTH defines the automatic line break position -!global $NODE_TYPE_MAX_CHAR_WIDTH = 35 -!global $NODE_DESCR_MAX_CHAR_WIDTH = 32 - -!unquoted function $breakNode($type, $widthStr) -!$width = %intval($widthStr) -!$multiLine = "" -!if (%strpos($type, "\n") >= 0) - !while (%strpos($type, "\n") >= 0) - !$brPos = %strpos($type, "\n") - !$multiLine = $multiLine + %substr($type, 0, $brPos) + '\n' - !$type = %substr($type, $brPos+2) - !endwhile -!else - !while (%strlen($type) > $width) - !$brPos = $width - !while ($brPos > 0 && %substr($type, $brPos, 1) != ' ') - !$brPos = $brPos - 1 - !endwhile - - !if ($brPos < 1) - !$brPos = %strpos($type, " ") - !else - !endif - - !if ($brPos > 0) - !$multiLine = $multiLine + %substr($type, 0, $brPos) + '\n' - !$type = %substr($type, $brPos + 1) - !else - !$multiLine = $multiLine+ $type - !$type = "" - !endif - !endwhile -!endif -!if (%strlen($type) > 0) - !$multiLine = $multiLine + $type -!endif -!return $multiLine +' $breakTechn() in C4 supports //...//; $breakNode() in C4_Deployment supports no //....// +!unquoted function $breakNode($text, $widthStr) + !$usedNewLine = '\n' + !return $breakText($text, $usedNewLine, $widthStr) !endfunction ' Elements @@ -79,7 +50,7 @@ SetDefaultLegendEntries("person\nsystem\ncontainer\nexternal_person\nexternal_sy !if ($sprite != "") !$nodeText = $nodeText + $getSprite($sprite) + '\n' !endif - !$nodeText = $nodeText + '==' + $label + !$nodeText = $nodeText + '== ' + $breakText($label, "\n== ") !if ($type != "") !$nodeText = $nodeText + '\n[' + $breakNode($type, $NODE_TYPE_MAX_CHAR_WIDTH) + ']' !endif @@ -94,7 +65,7 @@ SetDefaultLegendEntries("person\nsystem\ncontainer\nexternal_person\nexternal_sy !if ($sprite != "") !$nodeText = $nodeText + $getSprite($sprite) + '\l' !endif - !$nodeText = $nodeText + '==' + $label + !$nodeText = $nodeText + '== ' + $breakText($label, "\l== ") !if ($type != "") !$nodeText = $nodeText + '\l[' + $breakNode($type, $NODE_TYPE_MAX_CHAR_WIDTH) + ']' !endif @@ -109,7 +80,7 @@ SetDefaultLegendEntries("person\nsystem\ncontainer\nexternal_person\nexternal_sy !if ($sprite != "") !$nodeText = $nodeText + $getSprite($sprite) + '\r' !endif - !$nodeText = $nodeText + '==' + $label + !$nodeText = $nodeText + '== ' + $breakText($label, "\r== ") !if ($type != "") !$nodeText = $nodeText + '\r[' + $breakNode($type, $NODE_TYPE_MAX_CHAR_WIDTH) + ']' !endif @@ -159,4 +130,4 @@ rectangle "$getNode_L($label, $type, $descr, $sprite)$getProps_L()" $toStereos(" ' nodes $type reuses $techn definition of $tags !$type=$toElementArg($type, $tags, "ElementTagTechn", "node") rectangle "$getNode_R($label, $type, $descr, $sprite)$getProps_R()" $toStereos("node",$tags) as $alias $getLink($link) -!endprocedure +!endprocedure \ No newline at end of file diff --git a/server/src/main/resources/c4_dynamic.puml b/server/src/main/resources/c4_dynamic.puml index f9f4b0e3b..3416aa944 100644 --- a/server/src/main/resources/c4_dynamic.puml +++ b/server/src/main/resources/c4_dynamic.puml @@ -1,139 +1,133 @@ -' Scope: Interactions in an enterprise, software system or container. -' Primary and supporting elements: Depends on the diagram scope - -' enterprise - people and software systems Related to the enterprise in scope -' software system - see system context or container diagrams, -' container - see component diagram. -' Intended audience: Technical and non-technical people, inside and outside of the software development team. - -' Dynamic diagram introduces (automatically) numbered interactions: -' (lowercase) increment($offset=1): increase current index (procedure which has no direct output) -' (lowercase) setIndex($new_index): set the new index (procedure which has no direct output) -' -' (Uppercase) LastIndex(): return the last used index (function which can be used as argument) -' (Uppercase) Index($offset=1): returns current index and calculates next index (function which can be used as argument) -' (Uppercase) SetIndex($new_index): returns new set index and calculates next index (function which can be used as argument) - -' Index +' Colors ' ################################## -!$lastIndex = 0 -!$index = 1 +!$NODE_FONT_COLOR ?= "#000000" +!$NODE_BG_COLOR ?= "#FFFFFF" +!$NODE_BORDER_COLOR ?= "#A2A2A2" -!procedure increment($offset=1) - !$lastIndex = $index - !$index = $index + $offset -!endprocedure +' Styling +' ################################## -!procedure setIndex($new_index) - !$lastIndex = $index - !$index = $new_index -!endprocedure +' PlantUML supports no automatic line breaks of "PlantUML containers" (C4 Deployment_Node is a "PlantUML container") +' therefore (Deployment_)Node() implements an automatic line break based on spaces (like in all other objects). +' If a $type contains \n then these are used (and no automatic space based line breaks are done) +' $NODE_TYPE_MAX_CHAR_WIDTH defines the automatic line break position +!$NODE_TYPE_MAX_CHAR_WIDTH ?= 35 +!$NODE_DESCR_MAX_CHAR_WIDTH ?= 32 -!function Index($offset=1) - !$lastIndex = $index - !$index = $lastIndex + $offset - !return $lastIndex -!endfunction +UpdateElementStyle("node", $bgColor=$NODE_BG_COLOR, $fontColor=$NODE_FONT_COLOR, $borderColor=$NODE_BORDER_COLOR) +skinparam rectangle<> { + FontStyle normal +} -!function LastIndex() - !return $lastIndex -!endfunction +' shortcuts with default colors +' node specific: $techn is only used in old scripts, new scripts uses $type ($techn has to remain, it could be called via named argument) +!unquoted procedure AddNodeTag($tagStereo, $bgColor="", $fontColor="", $borderColor="", $shadowing="", $shape="", $sprite="", $type="", $legendText="", $legendSprite="", $techn="") + !$type=$type+$techn + $addElementTagInclReuse("node", $tagStereo, $bgColor, $fontColor, $borderColor, $shadowing, $shape, $sprite, $type, $legendText, $legendSprite) +!endprocedure -!function SetIndex($new_index, $offset=1) - !$lastIndex = $new_index - !$index = $new_index + $offset - !return $lastIndex -!endfunction +' Layout +' ################################## + +' comment if node should not be added to legend. No calculated legend extension required +SetDefaultLegendEntries("person\nsystem\ncontainer\nexternal_person\nexternal_system\nexternal_container\nnode\nenterprise_boundary\nsystem_boundary\ncontainer_boundary\nboundary") -' Relationship override +' Line breaks ' ################################## -' Relationship +' $breakTechn() in C4 supports //...//; $breakNode() in C4_Deployment supports no //....// +!unquoted function $breakNode($text, $widthStr) + !$usedNewLine = '\n' + !return $breakText($text, $usedNewLine, $widthStr) +!endfunction + +' Elements ' ################################## -!unquoted procedure Rel_($e_index, $alias1, $alias2, $label, $direction) -$alias1 $direction $alias2 : **$e_index: $label** -!endprocedure -!unquoted procedure Rel_($e_index, $alias1, $alias2, $label, $techn, $direction) -$alias1 $direction $alias2 : **$e_index: $label**\n//[$techn]// -!endprocedure +!function $getNode($label, $type, $descr, $sprite) + !$nodeText = "" + !if ($sprite != "") + !$nodeText = $nodeText + $getSprite($sprite) + '\n' + !endif + !$nodeText = $nodeText + '== ' + $breakText($label, "\n== ") + !if ($type != "") + !$nodeText = $nodeText + '\n[' + $breakNode($type, $NODE_TYPE_MAX_CHAR_WIDTH) + ']' + !endif + !if ($descr != "") + !$nodeText = $nodeText + '\n\n' + $breakDescr($descr, $NODE_DESCR_MAX_CHAR_WIDTH) + !endif + !return $nodeText +!endfunction -!unquoted procedure Rel($from, $to, $label, $techn="", $descr="", $sprite="", $tags="", $link="") -$getRel("-->>", $from, $to, Index() + ": " + $label, $techn, $descr, $sprite, $tags, $link) -!endprocedure -!unquoted procedure RelIndex($e_index, $from, $to, $label, $techn="", $descr="", $sprite="", $tags="", $link="") -$getRel("-->>", $from, $to, $e_index + ": " + $label, $techn, $descr, $sprite, $tags, $link) -!endprocedure +!function $getNode_L($label, $type, $descr, $sprite) + !$nodeText = "" + !if ($sprite != "") + !$nodeText = $nodeText + $getSprite($sprite) + '\l' + !endif + !$nodeText = $nodeText + '== ' + $breakText($label, "\l== ") + !if ($type != "") + !$nodeText = $nodeText + '\l[' + $breakNode($type, $NODE_TYPE_MAX_CHAR_WIDTH) + ']' + !endif + !if ($descr != "") + !$nodeText = $nodeText + '\l\l' + $breakDescr($descr, $NODE_DESCR_MAX_CHAR_WIDTH) + !endif + !return $nodeText +!endfunction -!unquoted procedure Rel_Back($from, $to, $label, $techn="", $descr="", $sprite="", $tags="", $link="") -$getRel("<<--", $from, $to, Index() + ": " + $label, $techn, $descr, $sprite, $tags, $link) -!endprocedure -!unquoted procedure RelIndex_Back($e_index, $from, $to, $label, $techn="", $descr="", $sprite="", $tags="", $link="") -$getRel("<<--", $from, $to, $e_index + ": " + $label, $techn, $descr, $sprite, $tags, $link) -!endprocedure +!function $getNode_R($label, $type, $descr, $sprite) + !$nodeText = "" + !if ($sprite != "") + !$nodeText = $nodeText + $getSprite($sprite) + '\r' + !endif + !$nodeText = $nodeText + '== ' + $breakText($label, "\r== ") + !if ($type != "") + !$nodeText = $nodeText + '\r[' + $breakNode($type, $NODE_TYPE_MAX_CHAR_WIDTH) + ']' + !endif + !if ($descr != "") + !$nodeText = $nodeText + '\r\r' + $breakDescr($descr, $NODE_DESCR_MAX_CHAR_WIDTH) + !endif + !return $nodeText +!endfunction -!unquoted procedure Rel_Neighbor($from, $to, $label, $techn="", $descr="", $sprite="", $tags="", $link="") -$getRel("->>", $from, $to, Index() + ": " + $label, $techn, $descr, $sprite, $tags, $link) -!endprocedure -!unquoted procedure RelIndex_Neighbor($e_index, $from, $to, $label, $techn="", $descr="", $sprite="", $tags="", $link="") -$getRel("->>", $from, $to, $e_index + ": " + $label, $techn, $descr, $sprite, $tags, $link) +!unquoted procedure Deployment_Node($alias, $label, $type="", $descr="", $sprite="", $tags="", $link="") +!$sprite=$toElementArg($sprite, $tags, "ElementTagSprite", "node") +' nodes $type reuses $techn definition of $tags +!$type=$toElementArg($type, $tags, "ElementTagTechn", "node") +rectangle "$getNode($label, $type, $descr, $sprite)$getProps()" $toStereos("node",$tags) as $alias $getLink($link) !endprocedure -!unquoted procedure Rel_Back_Neighbor($from, $to, $label, $techn="", $descr="", $sprite="", $tags="", $link="") -$getRel("<<-", $from, $to, Index() + ": " + $label, $techn, $descr, $sprite, $tags, $link) -!endprocedure -!unquoted procedure RelIndex_Back_Neighbor($e_index, $from, $to, $label, $techn="", $descr="", $sprite="", $tags="", $link="") -$getRel("<<-", $from, $to, $e_index + ": " + $label, $techn, $descr, $sprite, $tags, $link) +!unquoted procedure Deployment_Node_L($alias, $label, $type="", $descr="", $sprite="", $tags="", $link="") +!$sprite=$toElementArg($sprite, $tags, "ElementTagSprite", "node") +' nodes $type reuses $techn definition of $tags +!$type=$toElementArg($type, $tags, "ElementTagTechn", "node") +rectangle "$getNode_L($label, $type, $descr, $sprite)$getProps_L()" $toStereos("node",$tags) as $alias $getLink($link) !endprocedure -!unquoted procedure Rel_D($from, $to, $label, $techn="", $descr="", $sprite="", $tags="", $link="") -$getRel($down("-","->>"), $from, $to, Index() + ": " + $label, $techn, $descr, $sprite, $tags, $link) -!endprocedure -!unquoted procedure Rel_Down($from, $to, $label, $techn="", $descr="", $sprite="", $tags="", $link="") -$getRel($down("-","->>"), $from, $to, Index() + ": " + $label, $techn, $descr, $sprite, $tags, $link) -!endprocedure -!unquoted procedure RelIndex_D($e_index, $from, $to, $label, $techn="", $descr="", $sprite="", $tags="", $link="") -$getRel($down("-","->>"), $from, $to, $e_index + ": " + $label, $techn, $descr, $sprite, $tags, $link) -!endprocedure -!unquoted procedure RelIndex_Down($e_index, $from, $to, $label, $techn="", $descr="", $sprite="", $tags="", $link="") -$getRel($down("-","->>"), $from, $to, $e_index + ": " + $label, $techn, $descr, $sprite, $tags, $link) +!unquoted procedure Deployment_Node_R($alias, $label, $type="", $descr="", $sprite="", $tags="", $link="") +!$sprite=$toElementArg($sprite, $tags, "ElementTagSprite", "node") +' nodes $type reuses $techn definition of $tags +!$type=$toElementArg($type, $tags, "ElementTagTechn", "node") +rectangle "$getNode_R($label, $type, $descr, $sprite)$getProps_R()" $toStereos("node",$tags) as $alias $getLink($link) !endprocedure -!unquoted procedure Rel_U($from, $to, $label, $techn="", $descr="", $sprite="", $tags="", $link="") -$getRel($up("-","->>"), $from, $to, Index() + ": " + $label, $techn, $descr, $sprite, $tags, $link) -!endprocedure -!unquoted procedure Rel_Up($from, $to, $label, $techn="", $descr="", $sprite="", $tags="", $link="") -$getRel($up("-","->>"), $from, $to, Index() + ": " + $label, $techn, $descr, $sprite, $tags, $link) -!endprocedure -!unquoted procedure RelIndex_U($e_index, $from, $to, $label, $techn="", $descr="", $sprite="", $tags="", $link="") -$getRel($up("-","->>"), $from, $to, $e_index + ": " + $label, $techn, $descr, $sprite, $tags, $link) -!endprocedure -!unquoted procedure RelIndex_Up($e_index, $from, $to, $label, $techn="", $descr="", $sprite="", $tags="", $link="") -$getRel($up("-","->>"), $from, $to, $e_index + ": " + $label, $techn, $descr, $sprite, $tags, $link) +!unquoted procedure Node($alias, $label, $type="", $descr="", $sprite="", $tags="", $link="") +!$sprite=$toElementArg($sprite, $tags, "ElementTagSprite", "node") +' nodes $type reuses $techn definition of $tags +!$type=$toElementArg($type, $tags, "ElementTagTechn", "node") +rectangle "$getNode($label, $type, $descr, $sprite)$getProps()" $toStereos("node",$tags) as $alias $getLink($link) !endprocedure -!unquoted procedure Rel_L($from, $to, $label, $techn="", $descr="", $sprite="", $tags="", $link="") -$getRel($left("-","->>"), $from, $to, Index() + ": " + $label, $techn, $descr, $sprite, $tags, $link) -!endprocedure -!unquoted procedure Rel_Left($from, $to, $label, $techn="", $descr="", $sprite="", $tags="", $link="") -$getRel($left("-","->>"), $from, $to, Index() + ": " + $label, $techn, $descr, $sprite, $tags, $link) -!endprocedure -!unquoted procedure RelIndex_L($e_index, $from, $to, $label, $techn="", $descr="", $sprite="", $tags="", $link="") -$getRel($left("-","->>"), $from, $to, $e_index + ": " + $label, $techn, $descr, $sprite, $tags, $link) -!endprocedure -!unquoted procedure RelIndex_Left($e_index, $from, $to, $label, $techn="", $descr="", $sprite="", $tags="", $link="") -$getRel($left("-","->>"), $from, $to, $e_index + ": " + $label, $techn, $descr, $sprite, $tags, $link) +!unquoted procedure Node_L($alias, $label, $type="", $descr="", $sprite="", $tags="", $link="") +!$sprite=$toElementArg($sprite, $tags, "ElementTagSprite", "node") +' nodes $type reuses $techn definition of $tags +!$type=$toElementArg($type, $tags, "ElementTagTechn", "node") +rectangle "$getNode_L($label, $type, $descr, $sprite)$getProps_L()" $toStereos("node",$tags) as $alias $getLink($link) !endprocedure -!unquoted procedure Rel_R($from, $to, $label, $techn="", $descr="", $sprite="", $tags="", $link="") -$getRel($right("-","->>"), $from, $to, Index() + ": " + $label, $techn, $descr, $sprite, $tags, $link) -!endprocedure -!unquoted procedure Rel_Right($from, $to, $label, $techn="", $descr="", $sprite="", $tags="", $link="") -$getRel($right("-","->>"), $from, $to, Index() + ": " + $label, $techn, $descr, $sprite, $tags, $link) -!endprocedure -!unquoted procedure RelIndex_R($e_index, $from, $to, $label, $techn="", $descr="", $sprite="", $tags="", $link="") -$getRel($right("-","->>"), $from, $to, $e_index + ": " + $label, $techn, $descr, $sprite, $tags, $link) -!endprocedure -!unquoted procedure RelIndex_Right($e_index, $from, $to, $label, $techn="", $descr="", $sprite="", $tags="", $link="") -$getRel($right("-","->>"), $from, $to, $e_index + ": " + $label, $techn, $descr, $sprite, $tags, $link) -!endprocedure +!unquoted procedure Node_R($alias, $label, $type="", $descr="", $sprite="", $tags="", $link="") +!$sprite=$toElementArg($sprite, $tags, "ElementTagSprite", "node") +' nodes $type reuses $techn definition of $tags +!$type=$toElementArg($type, $tags, "ElementTagTechn", "node") +rectangle "$getNode_R($label, $type, $descr, $sprite)$getProps_R()" $toStereos("node",$tags) as $alias $getLink($link) +!endprocedure \ No newline at end of file diff --git a/server/src/main/resources/c4_sequence.puml b/server/src/main/resources/c4_sequence.puml new file mode 100644 index 000000000..0108a6632 --- /dev/null +++ b/server/src/main/resources/c4_sequence.puml @@ -0,0 +1,387 @@ +' Scope: Interactions in an enterprise, software system or container. +' Primary and supporting elements: Depends on the diagram scope - +' enterprise - people and software systems Related to the enterprise in scope +' software system - see system context or container diagrams, +' container - see component diagram. +' Intended audience: Technical and non-technical people, inside and outside of the software development team. + +' Sequence diagram introduces (automatically) numbered interactions: +' (lowercase) increment($offset=1): increase current index (procedure which has no direct output) +' (lowercase) setIndex($new_index): set the new index (procedure which has no direct output) +' +' (Uppercase) LastIndex(): return the last used index (function which can be used as argument) +' (Uppercase) Index($offset=1): returns current index and calculates next index (function which can be used as argument) +' (Uppercase) SetIndex($new_index): returns new set index and calculates next index (function which can be used as argument) + +' enables multi-level boxes +!pragma teoz true + + +' Legend redefintion +' ################################## +' sequence has no dashed boxes +!if ($LEGEND_DASHED_BOUNDARY == "dashed") + !$LEGEND_DASHED_BOUNDARY = "" +!endif +!if ($LEGEND_DASHED_TRANSPARENT_BOUNDARY == "dashed") + !$LEGEND_DASHED_TRANSPARENT_BOUNDARY = "" +!endif +UpdateBoundaryStyle("", $bgColor=$BOUNDARY_BG_COLOR, $fontColor=$BOUNDARY_COLOR, $borderColor=$BOUNDARY_COLOR) +UpdateBoundaryStyle("enterprise", $bgColor=$ENTERPRISE_BOUNDARY_BG_COLOR, $fontColor=$ENTERPRISE_BOUNDARY_COLOR, $borderColor=$ENTERPRISE_BOUNDARY_COLOR, $type="Enterprise") +UpdateBoundaryStyle("system", $bgColor=$SYSTEM_BOUNDARY_BG_COLOR, $fontColor=$SYSTEM_BOUNDARY_COLOR, $borderColor=$SYSTEM_BOUNDARY_COLOR, $type="System") +UpdateBoundaryStyle("container", $bgColor=$CONTAINER_BOUNDARY_BG_COLOR, $fontColor=$CONTAINER_BOUNDARY_COLOR, $borderColor=$CONTAINER_BOUNDARY_COLOR, $type="Container") + +' Styling and Layout +' ################################## + +!global $display_element_description = %false() + +' typically the element/participant descriptions are not displayed in a sequence diagram, but it can be activated with this call +!unquoted procedure SHOW_ELEMENT_DESCRIPTIONS($show="true") +!if ($show == "true") + !global $display_element_description = %true() +!else + !global $display_element_description = %false() +!endif +!endprocedure + +' typically the foot boxes descriptions are not displayed in a sequence diagram, but it can be activated with this call +!unquoted procedure SHOW_FOOT_BOXES($show="true") +!if ($show == "true") + show footbox +!else + hide footbox +!endif +!endprocedure + +!global $show_index = %false() +' All relation specific (default) ordinary index numbers can be shown with this call +!unquoted procedure SHOW_INDEX($show="true") +!if ($show == "true") + !global $show_index = %true() +!else + !global $show_index = %false() +!endif +!endprocedure + +' ======= if no theme is defined hide foot box and activate C4_blue styles +!if (%variable_exists("$THEME")) +!else +' $BOUNDARY_BG_COLOR... have to be defined in theme itself that it can be used in styles,... +' (no default values which are defined in C4.puml) +' If skinparams and styles are defined with concrete values no variables are required +!$BOUNDARY_BG_COLOR ?= "transparent" +!$BOUNDARY_COLOR ?= "#444444" +!$ARROW_COLOR ?= "#666666" + +' replace transparent with concrete background that it can be used as font color too +!if ($BOUNDARY_BG_COLOR == "transparent") + !$SEQUENCE_BG_COLOR = white +!else + !$SEQUENCE_BG_COLOR = $BOUNDARY_BG_COLOR +!endif + +' "C4 styled" default is no foot boxes +hide footbox +' "C4 styled" default is that lifeline is arrow color +skinparam SequenceLifelineBorderColor $ARROW_COLOR + +skinparam SequenceGroupBodyBackgroundColor $SEQUENCE_BG_COLOR +skinparam SequenceGroupFontColor $BOUNDARY_COLOR +skinparam SequenceGroupBackgroundColor $BOUNDARY_COLOR +skinparam SequenceGroupHeaderFontColor $SEQUENCE_BG_COLOR +skinparam SequenceGroupBorderColor $BOUNDARY_COLOR + +skinparam SequenceReferenceBackgroundColor $SEQUENCE_BG_COLOR +skinparam SequenceReferenceFontColor $BOUNDARY_COLOR +skinparam SequenceReferenceHeaderBackgroundColor $BOUNDARY_COLOR +' VIA STYLE +' skinparam SequenceReferenceHeaderFontColor $SEQUENCE_BG_COLOR + +skinparam SequenceReferenceBorderColor $BOUNDARY_COLOR + +skinparam SequenceDividerBackgroundColor $SEQUENCE_BG_COLOR +skinparam SequenceDividerFontColor $BOUNDARY_COLOR +skinparam SequenceDividerBorderColor $BOUNDARY_COLOR + +' VIA STYLE +' skinparam SequenceDelayFontColor green + +!endif +' ======= if no theme is defined hide foot box and activate C4_blue styles + +' Elements redefinition +' ################################## + +' all elements have to be displayed as participant +' participants requires ` %newline()` instead of `\n` + +!unquoted function $breakWithNewline($text, $lineEnd, $lineStart, $widthStr="-1") +!$width = %intval($widthStr) +!$multiLine = "" +!if (%strpos($text, "\n") >= 0) + !while (%strpos($text, "\n") >= 0) + !$brPos = %strpos($text, "\n") + !if ($brPos > 0) + !$multiLine = $multiLine + %substr($text, 0, $brPos) + $lineEnd + %newline() + $lineStart + !else + ' non breaking change that newLine breaks with formats can be used with \n\n + !$multiLine = $multiLine + "" + $lineEnd + %newline() + $lineStart + !endif + !$text = %substr($text, $brPos+2) + !if (%strlen($text) == 0) + !$text = "" + !endif + !endwhile +!else + !while ($width>0 && %strlen($text) > $width) + !$brPos = $width + !while ($brPos > 0 && %substr($text, $brPos, 1) != ' ') + !$brPos = $brPos - 1 + !endwhile + + !if ($brPos < 1) + !$brPos = %strpos($text, " ") + !else + !endif + + !if ($brPos > 0) + !$multiLine = $multiLine + %substr($text, 0, $brPos) + $lineEnd + %newline() + $lineStart + !$text = %substr($text, $brPos + 1) + !else + !$multiLine = $multiLine+ $text + !$text = "" + !endif + !endwhile +!endif +!if (%strlen($text) > 0) + !$multiLine = $multiLine + $text +!endif +!return $multiLine +!endfunction + +!unquoted function $breakNewLineLabel($text) +!$multiLine = $breakWithNewline($text, "", "==") +!return $multiLine +!endfunction + +!unquoted function $breakNewLineDescr($text) + !return $breakWithNewline($text, "", "", $REL_DESCR_MAX_CHAR_WIDTH) +!endfunction + +!unquoted function $breakNewLineTechn($text) + !$lineStart = "//" + !$lineEnd = '//' + !return $breakWithNewline($text, $lineStart, $lineEnd, $REL_TECHN_MAX_CHAR_WIDTH) +!endfunction + +' description is not displayed (size too big, line breaks not supported) +' properties are not displayed in sequence diagram (size would be too big) +' $breakLabel() not required by participant +!procedure $getParticipant($elementType, $alias, $label, $techn, $descr, $sprite, $tags, $link) + !$sprite=$toElementArg($sprite, $tags, "ElementTagSprite", $elementType) + !$techn=$toElementArg($techn, $tags, "ElementTagTechn", $elementType) + !$stereo = $toStereos($elementType,$tags) + !$calcLabel = "== " + $breakNewLineLabel($label) + !$calcTech = "//[" + $breakNewLineTechn($techn) + "]//" + !$calcDescr = $breakNewLineDescr($descr) + !$calcLink = $getLink($link) + +participant $alias $stereo $calcLink [ +!if ($sprite != "") +$getSprite($sprite) +!endif +!if ($label != "") +$calcLabel +!endif +!if ($techn != "") +$calcTech +!endif +!if ($display_element_description == %true() && $descr != "") + +$calcDescr +!endif +] +!endprocedure + + +!unquoted procedure Person($alias, $label, $descr="", $sprite="", $tags="", $link="", $type="") + ' $type reuses $techn definition of $tags + $getParticipant("person", $alias, $label, $type, $descr, $sprite, $tags, $link) +!endprocedure + +!unquoted procedure Person_Ext($alias, $label, $descr="", $sprite="", $tags="", $link="", $type="") + ' $type reuses $techn definition of $tags + $getParticipant("external_person", $alias, $label, $type, $descr, $sprite, $tags, $link) +!endprocedure + +!unquoted procedure System($alias, $label, $descr="", $sprite="", $tags="", $link="", $type="") + ' $type reuses $techn definition of $tags + $getParticipant("system", $alias, $label, $type, $descr, $sprite, $tags, $link) +!endprocedure + +!unquoted procedure SystemDb($alias, $label, $descr="", $sprite="", $tags="", $link="", $type="") + ' $type reuses $techn definition of $tags + $getParticipant("system", $alias, $label, $type, $descr, $sprite, $tags, $link) +!endprocedure + +!unquoted procedure SystemQueue($alias, $label, $descr="", $sprite="", $tags="", $link="", $type="") + ' $type reuses $techn definition of $tags + $getParticipant("system", $alias, $label, $type, $descr, $sprite, $tags, $link) +!endprocedure + +!unquoted procedure System_Ext($alias, $label, $descr="", $sprite="", $tags="", $link="", $type="") + ' $type reuses $techn definition of $tags + $getParticipant("external_system", $alias, $label, $type, $descr, $sprite, $tags, $link) +!endprocedure + +!unquoted procedure SystemDb_Ext($alias, $label, $descr="", $sprite="", $tags="", $link="", $type="") + ' $type reuses $techn definition of $tags + $getParticipant("external_system", $alias, $label, $type, $descr, $sprite, $tags, $link) +!endprocedure + +!unquoted procedure SystemQueue_Ext($alias, $label, $descr="", $sprite="", $tags="", $link="", $type="") + ' $type reuses $techn definition of $tags + $getParticipant("external_system", $alias, $label, $type, $descr, $sprite, $tags, $link) +!endprocedure + + + +!unquoted procedure Container($alias, $label, $techn="", $descr="", $sprite="", $tags="", $link="") + $getParticipant("container", $alias, $label, $techn, $descr, $sprite, $tags, $link) +!endprocedure + +!unquoted procedure ContainerDb($alias, $label, $techn="", $descr="", $sprite="", $tags="", $link="") + $getParticipant("container", $alias, $label, $techn, $descr, $sprite, $tags, $link) +!endprocedure + +!unquoted procedure ContainerQueue($alias, $label, $techn="", $descr="", $sprite="", $tags="", $link="") + $getParticipant("container", $alias, $label, $techn, $descr, $sprite, $tags, $link) +!endprocedure + +!unquoted procedure Container_Ext($alias, $label, $techn="", $descr="", $sprite="", $tags="", $link="") + $getParticipant("external_container", $alias, $label, $techn, $descr, $sprite, $tags, $link) +!endprocedure + +!unquoted procedure ContainerDb_Ext($alias, $label, $techn="", $descr="", $sprite="", $tags="", $link="") + $getParticipant("external_container", $alias, $label, $techn, $descr, $sprite, $tags, $link) +!endprocedure + +!unquoted procedure ContainerQueue_Ext($alias, $label, $techn="", $descr="", $sprite="", $tags="", $link="") + $getParticipant("external_container", $alias, $label, $techn, $descr, $sprite, $tags, $link) +!endprocedure + + + +!unquoted procedure Component($alias, $label, $techn="", $descr="", $sprite="", $tags="", $link="") + $getParticipant("component", $alias, $label, $techn, $descr, $sprite, $tags, $link) +!endprocedure + +!unquoted procedure ComponentDb($alias, $label, $techn="", $descr="", $sprite="", $tags="", $link="") + $getParticipant("component", $alias, $label, $techn, $descr, $sprite, $tags, $link) +!endprocedure + +!unquoted procedure ComponentQueue($alias, $label, $techn="", $descr="", $sprite="", $tags="", $link="") + $getParticipant("component", $alias, $label, $techn, $descr, $sprite, $tags, $link) +!endprocedure + +!unquoted procedure Component_Ext($alias, $label, $techn="", $descr="", $sprite="", $tags="", $link="") + $getParticipant("external_component", $alias, $label, $techn, $descr, $sprite, $tags, $link) +!endprocedure + +!unquoted procedure ComponentDb_Ext($alias, $label, $techn="", $descr="", $sprite="", $tags="", $link="") + $getParticipant("external_component", $alias, $label, $techn, $descr, $sprite, $tags, $link) +!endprocedure + +!unquoted procedure ComponentQueue_Ext($alias, $label, $techn="", $descr="", $sprite="", $tags="", $link="") + $getParticipant("external_component", $alias, $label, $techn, $descr, $sprite, $tags, $link) +!endprocedure + + +' Boundary redefinition +' ################################## + +' all boundaries have to be displayed as box and +' !!! important changes: without { at the end; and boundary ends with Boundary_End() instead of } + +' alias ignored +' $breakLabel() not required by participant + +!unquoted procedure Boundary($alias, $label, $type="", $tags="", $link="") +!$boundaryTags = $addBoundaryPostfix($tags) +' nodes $type reuses $techn definition of $boundaryTags +!$type=$toElementArg($type, $boundaryTags, "ElementTagTechn", "boundary") +!if ($link != "") + !$usedNewLine = ']]\n== [[' + $link + ' ' + !$labelType = '== [[' + $link + ' ' + $breakText($label, $usedNewLine) + ']]' +!else + !$usedNewLine = '\n== ' + !$labelType = $breakText($label, $usedNewLine) +!endif +!if (type != "") + !$labelType = $labelType + '\n[' + $type + ']' +!endif +box "$labelType" $toStereos("boundary", $boundaryTags) +!endprocedure + +!procedure Boundary_End() +end box +!endprocedure + +!unquoted procedure Enterprise_Boundary($alias, $label, $tags="", $link="") + !if ($tags != "") + !$allTags = $tags + '+enterprise' + !else + !$allTags = 'enterprise' + !endif + ' $type defined via $tag style + Boundary($alias, $label, "", $allTags, $link) +!endprocedure + +!unquoted procedure System_Boundary($alias, $label, $tags="", $link="") + !if ($tags != "") + !$allTags = $tags + '+system' + !else + !$allTags = 'system' + !endif + ' $type defined via $tag style + Boundary($alias, $label, "", $allTags, $link) +!endprocedure + +!unquoted procedure Container_Boundary($alias, $label, $tags="", $link="") + !if ($tags != "") + !$allTags = $tags + '+container' + !else + !$allTags = 'container' + !endif + ' $type defined via $tag style + Boundary($alias, $label, "", $allTags, $link) +!endprocedure + +' Relationship (redefinition) +' ################################## + +' only Rel is supported in sequence diagram + +' don't add empty lines in procedure otherwise & calls are not working anymore '& a -> b: call' are not working anymore +!unquoted procedure Rel($from, $to, $label, $techn="", $descr="", $sprite="", $tags="", $link="", $index="", $rel="") + !if ($show_index == %true()) + !$pre = $getPrefix($index) + !else + !$pre = "" + !endif + !if ($rel == "") + !$rel = "->" + !endif +$getRel($rel, $from, $to, $pre + $label, $techn, $descr, $sprite, $tags, $link) +!endprocedure \ No newline at end of file