mirror of
https://github.com/plantuml-stdlib/C4-PlantUML.git
synced 2022-10-18 01:14:54 +00:00
#159 Relation tags support line styles
This commit is contained in:
@@ -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 + "</color> "
|
||||
!$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, ...
|
||||
|
||||
@@ -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
|
||||
```
|
||||
|
||||

|
||||

|
||||
|
||||
|
||||
## 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")`.
|
||||
|
||||
Reference in New Issue
Block a user