From 32c482facde891fd51e8de768c6fd251d484e36b Mon Sep 17 00:00:00 2001 From: KIRCHSTH Date: Thu, 17 Jun 2021 19:15:11 +0200 Subject: [PATCH] #159 Relation tags support line styles --- C4.puml | 51 ++++++++++++++++++++++++++++++++++++++++++++------- README.md | 9 ++++++--- 2 files changed, 50 insertions(+), 10 deletions(-) diff --git a/C4.puml b/C4.puml index 331c469..5dcfe91 100644 --- a/C4.puml +++ b/C4.puml @@ -27,6 +27,9 @@ !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) " ' Styling ' ################################## @@ -38,6 +41,10 @@ !global $ROUNDED_BOX = "roundedBox" !global $EIGHT_SIDED = "eightSided" +!global $DOTTED_LINE = "dotted" +!global $DASHED_LINE = "dashed" +!global $BOLD_LINE = "bold" + skinparam defaultTextAlignment center skinparam wrapWidth 200 @@ -226,7 +233,7 @@ $tagSkin !return $c !endfunction -!unquoted procedure $defineRelSkinparams($tagStereo, $textColor, $lineColor) +!unquoted procedure $defineRelSkinparams($tagStereo, $textColor, $lineColor, $lineStyle) !$elementSkin = "skinparam arrow<<" + $tagStereo + ">> {" + %newline() !$elementSkin = $elementSkin + " Color " !if ($lineColor!="") @@ -235,6 +242,9 @@ $tagSkin !if ($textColor!="") !$elementSkin = $elementSkin + ";text:" + $colorWithoutHash($textColor) !endif + !if ($lineStyle!="") + !$elementSkin = $elementSkin + ";line." + $lineStyle + !endif !$elementSkin = $elementSkin + %newline() !$elementSkin = $elementSkin + "}" + %newline() $elementSkin @@ -398,7 +408,7 @@ $elementSkin !return $tagEntry !endfunction -!function $tagRelLegendEntry($tagStereo, $textColor, $lineColor) +!function $tagRelLegendEntry($tagStereo, $textColor, $lineColor, $lineStyle) !$tc = $textColor !$lc = $lineColor @@ -428,11 +438,26 @@ $elementSkin !if ($lineColor == "") !$tagEntry = $tagEntry + $LEGEND_NO_LINE_TEXT !endif + !if ($lineStyle != "") + !if ($lineStyle == $DOTTED_LINE) + !$tagEntry = $tagEntry + $LEGEND_DOTTED_LINE + !elseif ($lineStyle == $DASHED_LINE) + !$tagEntry = $tagEntry + $LEGEND_DASHED_LINE + !elseif ($lineStyle == $BOLD_LINE) + !$tagEntry = $tagEntry + $LEGEND_BOLD_LINE + !else + !$tagEntry = $tagEntry + "(" + $lineStyle + ") " + !endif + !endif !$tagEntry = $tagEntry + " " !$tagEntry = $tagEntry + "|" !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="") '' 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 @@ -446,7 +471,7 @@ $elementSkin ' !endif !endprocedure -!unquoted procedure $addRelTagToLegend($tagStereo, $textColor="", $lineColor="") +!unquoted procedure $addRelTagToLegend($tagStereo, $textColor="", $lineColor="", $lineStyle="") '' 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"). @@ -454,7 +479,7 @@ $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) + !$tagEntry = $tagRelLegendEntry($tagStereo, $textColor, $lineColor, $lineStyle) %set_variable_value("$" + $tagStereo + "_LineLegendEntry", $tagEntry) !$tagCustomLegend = $tagCustomLegend + $tagStereo + "_Line\n" ' !endif @@ -486,6 +511,18 @@ $elementSkin !return $EIGHT_SIDED !endfunction +!function DottedLine() +!return $DOTTED_LINE +!endfunction + +!function DashedLine() +!return $DASHED_LINE +!endfunction + +!function BoldLine() +!return $BOLD_LINE +!endfunction + ' used by new defined tags !unquoted procedure AddElementTag($tagStereo, $bgColor="", $fontColor="", $borderColor="", $shadowing="", $shape="") $defineSkinparams($tagStereo, $bgColor, $fontColor, $borderColor, $shadowing, $shape) @@ -493,9 +530,9 @@ $addTagToLegend($tagStereo, $bgColor, $fontColor, $borderColor, $shadowing, $sha !endprocedure ' used by new defined rel tags -!unquoted procedure AddRelTag($tagStereo, $textColor="", $lineColor="") -$defineRelSkinparams($tagStereo, $textColor, $lineColor) -$addRelTagToLegend($tagStereo, $textColor, $lineColor) +!unquoted procedure AddRelTag($tagStereo, $textColor="", $lineColor="", $lineStyle = "") +$defineRelSkinparams($tagStereo, $textColor, $lineColor, $lineStyle) +$addRelTagToLegend($tagStereo, $textColor, $lineColor, $lineStyle) !endprocedure ' update the style of existing elements like person, ... diff --git a/README.md b/README.md index cd975e9..cdb9334 100644 --- a/README.md +++ b/README.md @@ -132,7 +132,7 @@ AddElementTag("v1.0", $borderColor="#d73027") AddElementTag("v1.1", $fontColor="#d73027") AddElementTag("backup", $fontColor="orange") -AddRelTag("backup", $textColor="orange", $lineColor="orange") +AddRelTag("backup", $textColor="orange", $lineColor="orange", $lineStyle = DashedLine()) Person(user, "Customer", "People that need products") Person(admin, "Administrator", "People that administrates the products via the new v1.1 components", $tags="v1.1") @@ -153,7 +153,7 @@ SHOW_LEGEND() @enduml ``` -![tags](https://www.plantuml.com/plantuml/png/bLJTJjjC4BtdAVRprukWGWBz4L8b9AA0IgNGfWJ49Hfx9ywswrrhPnpQj--COs884LMlTZLpPiwSsMEV4KFYfl9x_xbG-CQYMJBNz6aqIl0mB1qlcxmXJ4KCZ867HQn6jOUWDOV4rhjyDFbmEDFGxTLqL04n9WdTJwG2NC0qhBN_tjZQ2uyL1hw1Sf2jZeT7sO5vayTaCK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-EGPI2IqBLKXql1jz0_Myh6W8MKDzLwAVNjADSvJcNFpCNZ8WJ0GtQd2MR8hBnRVfv7PQadxJPwB-448deRLRQmgaD-LTHLuPdofmnLhjS6WfVsLX9-DL3uCNYfJXi22JMHT7yKJWZiSm_xw-N3dg7TNszx30o65olXNm82GZnashZkzdBUcHh5p14dPerCUT-dzTH_jlvkZJRz6D6s93j9RdW2ha0XAx9IukFtsk9nEFa--ZjFUsGqQsLJwDm00 "tags") ## Supported Diagram Types @@ -376,7 +376,7 @@ Additional tags/stereotypes can be added to the existing element stereotypes (co * `AddElementTag(tagStereo, ?bgColor, ?fontColor, ?borderColor, ?shadowing, ?shape)`: Introduces a new element tag. The styles of the tagged elements are updated and the tag is displayed in the calculated legend. -* `AddRelTag(tagStereo, ?textColor, ?lineColor)`: +* `AddRelTag(tagStereo, ?textColor, ?lineColor, ?lineStyle)`: Introduces a new relation tag. The styles of the tagged relations are updated and the tag is displayed in the calculated legend. * `UpdateElementStyle(elementName, ?bgColor, ?fontColor, ?borderColor, ?shadowing, ?shape)`: This call updates the default style of the elements (component, ...) and creates no additional legend entry. @@ -384,6 +384,9 @@ Additional tags/stereotypes can be added to the existing element stereotypes (co This call updates the default relationship colors and creates no additional legend entry. * `RoundedBoxShape()`: This call returns the name of the rounded box shape and can be used as ?shape argument. * `EightSidedShape()`: This call returns the name of the eight sided shape and can be used as ?shape argument. +* `DashedLine()`: This call returns the name of the dashed line and can be used as ?lineStyle argument. +* `DottedLine()`: This call returns the name of the dotted line and can be used as ?lineStyle argument. +* `BoldLine()`: This call returns the name of the bold line and can be used as ?lineStyle argument. Each element can be extended with one or multiple custom tags via the keyword argument `$tags="..."`, like `Container(spaAdmin, "Admin SPA", $tags="v1.1")`. Multiple tags can be combined with `+`, like `Container(api, "API", $tags="v1.0+v1.1")`.