mirror of
https://github.com/plantuml-stdlib/C4-PlantUML.git
synced 2022-10-18 01:14:54 +00:00
#173 Tags support sprites, technology and custom text (resolve conflicts, fix PR findings)
This commit is contained in:
@@ -1,5 +1,18 @@
|
||||
' C4-PlantUML
|
||||
|
||||
'Version
|
||||
' ##################################
|
||||
!function C4Version()
|
||||
!return "2.4.0beta1"
|
||||
!end function
|
||||
|
||||
!procedure C4VersionDetails()
|
||||
rectangle C4VersionDetailsArea <<legendArea>> [
|
||||
| PlantUML | **%version()** |
|
||||
| C4-PlantUML | **C4Version()** |
|
||||
]
|
||||
!end procedure
|
||||
|
||||
' Colors
|
||||
' ##################################
|
||||
|
||||
@@ -130,7 +143,7 @@ skinparam rectangle<<boundary>> {
|
||||
!$tags = %substr($tags, $brPos+1)
|
||||
!$brPos = %strpos($tags, "+")
|
||||
!endwhile
|
||||
!if (%strlen($tags)>0)
|
||||
!if (%strlen($tags) > 0)
|
||||
!$stereos = $stereos + '<<' + $tags + '>>'
|
||||
%set_variable_value("$" + $tags + "_LineLegend", %true())
|
||||
!endif
|
||||
@@ -139,7 +152,7 @@ skinparam rectangle<<boundary>> {
|
||||
|
||||
' if $sprite/$techn is an empty argument, try to calculate it via the defined $tag
|
||||
!unquoted function $toRelArg($arg, $tags, $varPostfix)
|
||||
!if ($arg>"")
|
||||
!if ($arg > "")
|
||||
!return $arg
|
||||
!endif
|
||||
|
||||
@@ -150,15 +163,15 @@ skinparam rectangle<<boundary>> {
|
||||
!while ($brPos >= 0)
|
||||
!$tag = %substr($tags, 0, $brPos)
|
||||
!$newArg = %get_variable_value("$" + $tag + $varPostfix)
|
||||
!if ($newArg>"")
|
||||
!if ($newArg > "")
|
||||
!return $newArg
|
||||
!endif
|
||||
!$tags = %substr($tags, $brPos+1)
|
||||
!$brPos = %strpos($tags, "+")
|
||||
!endwhile
|
||||
!if (%strlen($tags)>0)
|
||||
!if (%strlen($tags) > 0)
|
||||
!$newArg = %get_variable_value("$" + $tags + $varPostfix)
|
||||
!if ($newArg>"")
|
||||
!if ($newArg > "")
|
||||
!return $newArg
|
||||
!endif
|
||||
!endif
|
||||
@@ -186,7 +199,7 @@ skinparam rectangle<<boundary>> {
|
||||
!$tags = %substr($tags, $brPos+1)
|
||||
!$brPos = %strpos($tags, "+")
|
||||
!endwhile
|
||||
!if (%strlen($tags)>0)
|
||||
!if (%strlen($tags) > 0)
|
||||
!$stereos = $stereos + '<<' + $tags + '>>'
|
||||
!$mergedMask = $combineMaskWithTag($mask, $tags)
|
||||
!if ($mergedMask != $mask)
|
||||
@@ -206,13 +219,13 @@ skinparam rectangle<<boundary>> {
|
||||
|
||||
' if $sprite/$techn is an empty argument, try to calculate it via the defined $tag
|
||||
!unquoted function $toElementArg($arg, $tags, $varPostfix, $elementType)
|
||||
!if ($arg>"")
|
||||
!if ($arg > "")
|
||||
!return $arg
|
||||
!endif
|
||||
|
||||
!if (%strlen($tags) == 0)
|
||||
!$newArg = %get_variable_value("$" + $elementType + $varPostfix)
|
||||
!if ($newArg>"")
|
||||
!if ($newArg > "")
|
||||
!return $newArg
|
||||
!else
|
||||
!return $arg
|
||||
@@ -222,19 +235,19 @@ skinparam rectangle<<boundary>> {
|
||||
!while ($brPos >= 0)
|
||||
!$tag = %substr($tags, 0, $brPos)
|
||||
!$newArg = %get_variable_value("$" + $tag + $varPostfix)
|
||||
!if ($newArg>"")
|
||||
!if ($newArg > "")
|
||||
!return $newArg
|
||||
!endif
|
||||
!$tags = %substr($tags, $brPos+1)
|
||||
!$brPos = %strpos($tags, "+")
|
||||
!endwhile
|
||||
!if (%strlen($tags)>0)
|
||||
!if (%strlen($tags) > 0)
|
||||
!$newArg = %get_variable_value("$" + $tags + $varPostfix)
|
||||
!if ($newArg>"")
|
||||
!if ($newArg > "")
|
||||
!return $newArg
|
||||
!endif
|
||||
!$newArg = %get_variable_value("$" + $elementType + $varPostfix)
|
||||
!if ($newArg>"")
|
||||
!if ($newArg > "")
|
||||
!return $newArg
|
||||
!endif
|
||||
!endif
|
||||
@@ -242,17 +255,17 @@ skinparam rectangle<<boundary>> {
|
||||
!endfunction
|
||||
|
||||
!function $elementTagSkinparams($element, $tagStereo, $bgColor, $fontColor, $borderColor, $shadowing, $shape)
|
||||
!$elementSkin = "skinparam " + $element +"<<" + $tagStereo + ">> {" + %newline()
|
||||
!if ($fontColor!="")
|
||||
!$elementSkin = "skinparam " + $element + "<<" + $tagStereo + ">> {" + %newline()
|
||||
!if ($fontColor != "")
|
||||
!if ($tagStereo != "boundary")
|
||||
!$elementSkin = $elementSkin + " StereotypeFontColor " + $fontColor + %newline()
|
||||
!endif
|
||||
!$elementSkin = $elementSkin + " FontColor " + $fontColor + %newline()
|
||||
!endif
|
||||
!if ($bgColor!="")
|
||||
!if ($bgColor != "")
|
||||
!$elementSkin = $elementSkin + " BackgroundColor " + $bgColor + %newline()
|
||||
!endif
|
||||
!if ($borderColor!="")
|
||||
!if ($borderColor != "")
|
||||
!$elementSkin = $elementSkin + " BorderColor " + $borderColor+ %newline()
|
||||
!endif
|
||||
!if ($shadowing == "true")
|
||||
@@ -262,7 +275,7 @@ skinparam rectangle<<boundary>> {
|
||||
!$elementSkin = $elementSkin + " Shadowing<<" + $tagStereo + ">> " + "false" + %newline()
|
||||
!endif
|
||||
' only rectangle supports shape(d corners), define both skinparam that overlays are working
|
||||
!if ($shape!="" && $element == "rectangle")
|
||||
!if ($shape != "" && $element == "rectangle")
|
||||
!if ($shape == $ROUNDED_BOX)
|
||||
!$elementSkin = $elementSkin + " RoundCorner " + $ROUNDED_BOX_SIZE+ %newline()
|
||||
!$elementSkin = $elementSkin + " DiagonalCorner " + "0" + %newline()
|
||||
@@ -283,7 +296,7 @@ skinparam rectangle<<boundary>> {
|
||||
' 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!="")
|
||||
!if ($tagStereo == "boundary" && $bgColor != "")
|
||||
!$tagSkin = $tagSkin + "skinparam package<<boundary>>StereotypeFontColor " + $bgColor + %newline()
|
||||
!$tagSkin = $tagSkin + "skinparam rectangle<<boundary>>StereotypeFontColor " + $bgColor + %newline()
|
||||
!endif
|
||||
@@ -301,13 +314,13 @@ $tagSkin
|
||||
!unquoted procedure $defineRelSkinparams($tagStereo, $textColor, $lineColor, $lineStyle)
|
||||
!$elementSkin = "skinparam arrow<<" + $tagStereo + ">> {" + %newline()
|
||||
!$elementSkin = $elementSkin + " Color "
|
||||
!if ($lineColor!="")
|
||||
!if ($lineColor != "")
|
||||
!$elementSkin = $elementSkin + $colorWithoutHash($lineColor)
|
||||
!endif
|
||||
!if ($textColor!="")
|
||||
!if ($textColor != "")
|
||||
!$elementSkin = $elementSkin + ";text:" + $colorWithoutHash($textColor)
|
||||
!endif
|
||||
!if ($lineStyle!="")
|
||||
!if ($lineStyle != "")
|
||||
!$elementSkin = $elementSkin + ";line." + $lineStyle
|
||||
!endif
|
||||
!$elementSkin = $elementSkin + %newline()
|
||||
@@ -315,7 +328,7 @@ $tagSkin
|
||||
$elementSkin
|
||||
!endprocedure
|
||||
|
||||
' %is_dark() requires PlantUML version >=1.2021.6
|
||||
' %is_dark() requires PlantUML version >= 1.2021.6
|
||||
!if (%function_exists("%is_dark"))
|
||||
!$PlantUMLSupportsDynamicLegendColor = %true()
|
||||
!else
|
||||
@@ -393,7 +406,7 @@ $elementSkin
|
||||
|
||||
!function $combineMaskWithTag($mask1, $tag)
|
||||
!$mask2 = %get_variable_value("$" + $tag+ "LegendMask")
|
||||
!if ($mask2=="")
|
||||
!if ($mask2 == "")
|
||||
' !log combineMaskWithTag $mask1, $tag, ... only $mask1
|
||||
!return $mask1
|
||||
!endif
|
||||
@@ -422,9 +435,9 @@ $elementSkin
|
||||
' if it starts with & it's a OpenIconic, details see https://useiconic.com/open/
|
||||
' if it starts with img: it's an image, details see https://plantuml.com/creole
|
||||
!if (%substr($sprite, 0, 1) != "&" && %substr($sprite, 0, 4) != "img:")
|
||||
!$formatted ="<$" + $sprite + ">"
|
||||
!$formatted = "<$" + $sprite + ">"
|
||||
!else
|
||||
!$formatted ="<" + $sprite + ">"
|
||||
!$formatted = "<" + $sprite + ">"
|
||||
!endif
|
||||
!return $formatted
|
||||
!endfunction
|
||||
@@ -470,7 +483,7 @@ $elementSkin
|
||||
!endif
|
||||
|
||||
!$tagEntry = "|"
|
||||
!$tagEntry = $tagEntry + "<" + $colorWithHash($bg) +">"
|
||||
!$tagEntry = $tagEntry + "<" + $colorWithHash($bg) +">"
|
||||
' <U+25AF> ..white rectangle
|
||||
!$tagEntry = $tagEntry + "<color:"+$bo+"> <U+25AF></color> "
|
||||
!$tagEntry = $tagEntry + "<color:"+$fo+">"
|
||||
@@ -507,26 +520,26 @@ $elementSkin
|
||||
|
||||
!$tagEntry = $tagEntry + "</color> "
|
||||
!$tagEntry = $tagEntry + "|"
|
||||
!return $tagEntry
|
||||
!return $tagEntry
|
||||
!endfunction
|
||||
|
||||
!function $tagRelLegendEntry($tagStereo, $textColor, $lineColor, $lineStyle, $legendText, $legendSprite)
|
||||
!$tc = $textColor
|
||||
!$lc = $lineColor
|
||||
|
||||
!if ($tc=="")
|
||||
!if ($PlantUMLSupportsDynamicLegendColor)
|
||||
!$tc = $flatLegend($ARROW_COLOR)
|
||||
!else
|
||||
!$tc = $LEGEND_DARK_COLOR
|
||||
!endif
|
||||
!if ($tc == "")
|
||||
!if ($PlantUMLSupportsDynamicLegendColor)
|
||||
!$tc = $flatLegend($ARROW_COLOR)
|
||||
!else
|
||||
!$tc = $LEGEND_DARK_COLOR
|
||||
!endif
|
||||
!endif
|
||||
!if ($lc=="")
|
||||
!if ($PlantUMLSupportsDynamicLegendColor)
|
||||
!$lc = $flatLegend($ARROW_COLOR)
|
||||
!else
|
||||
!$lc = $LEGEND_DARK_COLOR
|
||||
!endif
|
||||
!if ($lc == "")
|
||||
!if ($PlantUMLSupportsDynamicLegendColor)
|
||||
!$lc = $flatLegend($ARROW_COLOR)
|
||||
!else
|
||||
!$lc = $LEGEND_DARK_COLOR
|
||||
!endif
|
||||
!endif
|
||||
|
||||
!$tagEntry = "|"
|
||||
@@ -561,7 +574,7 @@ $elementSkin
|
||||
|
||||
!$tagEntry = $tagEntry + "</color> "
|
||||
!$tagEntry = $tagEntry + "|"
|
||||
!return $tagEntry
|
||||
!return $tagEntry
|
||||
!endfunction
|
||||
|
||||
!global $LEGEND_DOTTED_LINE = "(dotted) "
|
||||
@@ -570,9 +583,9 @@ $elementSkin
|
||||
|
||||
!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
|
||||
'' 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)
|
||||
' !if (%strpos($tagStereo, "&") < 0)
|
||||
!$tagEntry = $tagLegendEntry($tagStereo, $bgColor, $fontColor, $borderColor, $shadowing, $shape, $legendText, $legendSprite)
|
||||
%set_variable_value("$" + $tagStereo + "LegendEntry", $tagEntry)
|
||||
!$tagCustomLegend = $tagCustomLegend + $tagStereo + "\n"
|
||||
@@ -583,12 +596,12 @@ $elementSkin
|
||||
|
||||
!unquoted procedure $addRelTagToLegend($tagStereo, $textColor="", $lineColor="", $lineStyle="", $legendText="", $legendSprite="")
|
||||
'' 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
|
||||
'' 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").
|
||||
'' This workaround tag could be theoretically removed in the legend but after that there would
|
||||
'' be an inconsistency between the element tags and the rel tags and therefore
|
||||
'' This workaround tag could be theoretically removed in the legend but after that there would
|
||||
'' 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)
|
||||
' !if (%strpos($tagStereo, "&") < 0)
|
||||
!$tagEntry = $tagRelLegendEntry($tagStereo, $textColor, $lineColor, $lineStyle, $legendText, $legendSprite)
|
||||
%set_variable_value("$" + $tagStereo + "_LineLegendEntry", $tagEntry)
|
||||
!$tagCustomLegend = $tagCustomLegend + $tagStereo + "_Line\n"
|
||||
@@ -605,7 +618,7 @@ $elementSkin
|
||||
%get_variable_value("$" + $tagStereo + "LegendEntry")
|
||||
!endif
|
||||
!endwhile
|
||||
!if (%strlen($allDefined)>0)
|
||||
!if (%strlen($allDefined) > 0)
|
||||
!$tagStereo = $allDefined
|
||||
!if (%variable_exists("$" + $tagStereo + "Legend"))
|
||||
%get_variable_value("$" + $tagStereo + "LegendEntry")
|
||||
@@ -642,7 +655,7 @@ $defineSkinparams($tagStereo, $bgColor, $fontColor, $borderColor, $shadowing, $s
|
||||
!$legendSprite = $smallVersionSprite($sprite)
|
||||
!endif
|
||||
!endif
|
||||
!if ($techn!="")
|
||||
!if ($techn != "")
|
||||
%set_variable_value("$" + $tagStereo + "ElementTagTechn", $techn)
|
||||
!endif
|
||||
$addTagToLegend($tagStereo, $bgColor, $fontColor, $borderColor, $shadowing, $shape, $legendText, $legendSprite)
|
||||
@@ -651,14 +664,14 @@ $addTagToLegend($tagStereo, $bgColor, $fontColor, $borderColor, $shadowing, $sha
|
||||
' used by new defined rel tags
|
||||
!unquoted procedure AddRelTag($tagStereo, $textColor="", $lineColor="", $lineStyle = "", $sprite="", $techn="", $legendText="", $legendSprite="")
|
||||
$defineRelSkinparams($tagStereo, $textColor, $lineColor, $lineStyle)
|
||||
!if ($sprite!="")
|
||||
!if ($sprite != "")
|
||||
%set_variable_value("$" + $tagStereo + "RelTagSprite", $sprite)
|
||||
!if ($legendSprite == "")
|
||||
' relation symbols typically 1:1 no additional scale required
|
||||
!$legendSprite = $sprite
|
||||
!endif
|
||||
!endif
|
||||
!if ($techn!="")
|
||||
!if ($techn != "")
|
||||
%set_variable_value("$" + $tagStereo + "RelTagTechn", $techn)
|
||||
!endif
|
||||
$addRelTagToLegend($tagStereo, $textColor, $lineColor, $lineStyle, $legendText, $legendSprite)
|
||||
@@ -667,13 +680,13 @@ $addRelTagToLegend($tagStereo, $textColor, $lineColor, $lineStyle, $legendText,
|
||||
' update the style of existing elements like person, ...
|
||||
!unquoted procedure UpdateElementStyle($elementName, $bgColor="", $fontColor="", $borderColor="", $shadowing="", $shape="", $sprite="", $techn="", $legendText="", $legendSprite="")
|
||||
$defineSkinparams($elementName, $bgColor, $fontColor, $borderColor, $shadowing, $shape)
|
||||
!if ($sprite!="")
|
||||
!if ($sprite != "")
|
||||
%set_variable_value("$" + $elementName + "ElementTagSprite", $sprite)
|
||||
!if ($legendSprite == "")
|
||||
!$legendSprite = $smallVersionSprite($sprite)
|
||||
!endif
|
||||
!endif
|
||||
!if ($techn!="")
|
||||
!if ($techn != "")
|
||||
%set_variable_value("$" + $elementName + "ElementTagTechn", $techn)
|
||||
!endif
|
||||
!$tagEntry = $tagLegendEntry($elementName, $bgColor, $fontColor, $borderColor, $shadowing, $shape, $legendText, $legendSprite)
|
||||
@@ -697,7 +710,7 @@ UpdateElementStyle($elementName, $bgColor, $fontColor, $borderColor, $shadowing)
|
||||
$elementSkin
|
||||
!endprocedure
|
||||
|
||||
' tags/stereotypes have to be delimited with \n
|
||||
' tags/stereotypes have to be delimited with \n
|
||||
!unquoted procedure SetDefaultLegendEntries($tagStereoEntries)
|
||||
!$tagDefaultLegend = $tagStereoEntries
|
||||
!endprocedure
|
||||
@@ -706,7 +719,7 @@ $elementSkin
|
||||
' ##################################
|
||||
|
||||
!function $getLink($link)
|
||||
!if ($link!="")
|
||||
!if ($link != "")
|
||||
!return "[[" + $link + "]]"
|
||||
!else
|
||||
!return ""
|
||||
@@ -728,9 +741,9 @@ $elementSkin
|
||||
!$multiLine = ""
|
||||
!if (%strpos($descr, "\n") >= 0)
|
||||
!else
|
||||
!while (%strlen($descr)>$width)
|
||||
!$brPos = $width
|
||||
!while ($brPos>0 && %substr($descr, $brPos, 1)!= ' ')
|
||||
!while (%strlen($descr) > $width)
|
||||
!$brPos = $width
|
||||
!while ($brPos > 0 && %substr($descr, $brPos, 1) != ' ')
|
||||
!$brPos = $brPos - 1
|
||||
!endwhile
|
||||
|
||||
@@ -748,7 +761,7 @@ $elementSkin
|
||||
!endif
|
||||
!endwhile
|
||||
!endif
|
||||
!if (%strlen($descr)>0)
|
||||
!if (%strlen($descr) > 0)
|
||||
!$multiLine = $multiLine + $descr
|
||||
!endif
|
||||
!return $multiLine
|
||||
@@ -765,9 +778,9 @@ $elementSkin
|
||||
!$techn = %substr($techn, $brPos+2)
|
||||
!endwhile
|
||||
!else
|
||||
!while (%strlen($techn)>$width)
|
||||
!while (%strlen($techn) > $width)
|
||||
!$brPos = $width
|
||||
!while ($brPos>0 && %substr($techn, $brPos, 1)!= ' ')
|
||||
!while ($brPos > 0 && %substr($techn, $brPos, 1) != ' ')
|
||||
!$brPos = $brPos - 1
|
||||
!endwhile
|
||||
|
||||
@@ -785,7 +798,7 @@ $elementSkin
|
||||
!endif
|
||||
!endwhile
|
||||
!endif
|
||||
!if (%strlen($techn)>0)
|
||||
!if (%strlen($techn) > 0)
|
||||
!$multiLine = $multiLine + $techn
|
||||
!endif
|
||||
!return $multiLine
|
||||
@@ -857,19 +870,19 @@ SetPropertyHeader("Property","Value")
|
||||
' Layout
|
||||
' ##################################
|
||||
|
||||
!procedure $getHideStereotype($hideStereotype)
|
||||
!if ($hideStereotype=="true")
|
||||
!procedure $getHideStereotype($hideStereotype)
|
||||
!if ($hideStereotype == "true")
|
||||
hide stereotype
|
||||
!endif
|
||||
!endprocedure
|
||||
|
||||
!procedure $getLegendTable()
|
||||
!procedure $getLegendTable()
|
||||
<#00000000,#00000000>|<color:$LEGEND_TITLE_COLOR>**Legend**</color> |
|
||||
$showActiveLegendEntries($tagDefaultLegend)
|
||||
$showActiveLegendEntries($tagCustomLegend)
|
||||
!endprocedure
|
||||
|
||||
!procedure $getLegendArea($areaAlias, $hideStereotype)
|
||||
!procedure $getLegendArea($areaAlias, $hideStereotype)
|
||||
$getHideStereotype($hideStereotype)
|
||||
rectangle $areaAlias<<legendArea>> [
|
||||
$getLegendTable()
|
||||
@@ -887,11 +900,52 @@ skinparam defaultFontName "Comic Sans MS"
|
||||
center footer <font color=red>Warning:</font> Created for discussion, needs to be validated
|
||||
!endprocedure
|
||||
|
||||
!global $fix_direction=%false()
|
||||
|
||||
!function $down($start,$end)
|
||||
!if ($fix_direction)
|
||||
!return $start+"RIGHT"+$end
|
||||
!else
|
||||
!return $start+"DOWN"+$end
|
||||
!endif
|
||||
!endfunction
|
||||
|
||||
!function $up($start,$end)
|
||||
!if ($fix_direction)
|
||||
!return $start+"LEFT"+$end
|
||||
!else
|
||||
!return $start+"UP"+$end
|
||||
!endif
|
||||
!endfunction
|
||||
|
||||
!function $left($start,$end)
|
||||
!if ($fix_direction)
|
||||
!return $start+"UP"+$end
|
||||
!else
|
||||
!return $start+"LEFT"+$end
|
||||
!endif
|
||||
!endfunction
|
||||
|
||||
!function $right($start,$end)
|
||||
!if ($fix_direction)
|
||||
!return $start+"DOWN"+$end
|
||||
!else
|
||||
!return $start+"RIGHT"+$end
|
||||
!endif
|
||||
!endfunction
|
||||
|
||||
!procedure LAYOUT_TOP_DOWN()
|
||||
!global $fix_direction=%false()
|
||||
top to bottom direction
|
||||
!endprocedure
|
||||
|
||||
!procedure LAYOUT_LEFT_RIGHT()
|
||||
!global $fix_direction = %false()
|
||||
left to right direction
|
||||
!endprocedure
|
||||
|
||||
!procedure LAYOUT_LANDSCAPE()
|
||||
!global $fix_direction = %true()
|
||||
left to right direction
|
||||
!endprocedure
|
||||
|
||||
@@ -945,7 +999,7 @@ rectangle "$getBoundary($label, $type)" $toStereos("boundary", $tags) as $alias
|
||||
!$rel = $alias1 + ' ' + $direction + ' ' + $alias2
|
||||
!if ($tags != "")
|
||||
!$rel = $rel + ' ' + $toStereos($tags)
|
||||
!endif
|
||||
!endif
|
||||
!$rel = $rel + ' : '
|
||||
!if ($sprite != "")
|
||||
!$rel = $rel + $getSprite($sprite) + ' '
|
||||
@@ -989,64 +1043,68 @@ $getRel("<<--", $from, $to, $label, $techn, $descr, $sprite, $tags, $link)
|
||||
$getRel("->>", $from, $to, $label, $techn, $descr, $sprite, $tags, $link)
|
||||
!endprocedure
|
||||
|
||||
!unquoted procedure BiRel_Neighbor($from, $to, $label, $techn="", $descr="", $sprite="", $tags="", $link="")
|
||||
$getRel("<<->>", $from, $to, $label, $techn, $descr, $sprite, $tags, $link)
|
||||
!endprocedure
|
||||
|
||||
!unquoted procedure Rel_Back_Neighbor($from, $to, $label, $techn="", $descr="", $sprite="", $tags="", $link="")
|
||||
$getRel("<<-", $from, $to, $label, $techn, $descr, $sprite, $tags, $link)
|
||||
!endprocedure
|
||||
|
||||
!unquoted procedure Rel_D($from, $to, $label, $techn="", $descr="", $sprite="", $tags="", $link="")
|
||||
$getRel("-DOWN->>", $from, $to, $label, $techn, $descr, $sprite, $tags, $link)
|
||||
$getRel($down("-","->>"), $from, $to, $label, $techn, $descr, $sprite, $tags, $link)
|
||||
!endprocedure
|
||||
!unquoted procedure Rel_Down($from, $to, $label, $techn="", $descr="", $sprite="", $tags="", $link="")
|
||||
$getRel("-DOWN->>", $from, $to, $label, $techn, $descr, $sprite, $tags, $link)
|
||||
$getRel($down("-","->>"), $from, $to, $label, $techn, $descr, $sprite, $tags, $link)
|
||||
!endprocedure
|
||||
|
||||
!unquoted procedure BiRel_D($from, $to, $label, $techn="", $descr="", $sprite="", $tags="", $link="")
|
||||
$getRel("<<-DOWN->>", $from, $to, $label, $techn, $descr, $sprite, $tags, $link)
|
||||
$getRel($down("<<-","->>"), $from, $to, $label, $techn, $descr, $sprite, $tags, $link)
|
||||
!endprocedure
|
||||
!unquoted procedure BiRel_Down($from, $to, $label, $techn="", $descr="", $sprite="", $tags="", $link="")
|
||||
$getRel("<<-DOWN->>", $from, $to, $label, $techn, $descr, $sprite, $tags, $link)
|
||||
$getRel($down("<<-","->>"), $from, $to, $label, $techn, $descr, $sprite, $tags, $link)
|
||||
!endprocedure
|
||||
|
||||
!unquoted procedure Rel_U($from, $to, $label, $techn="", $descr="", $sprite="", $tags="", $link="")
|
||||
$getRel("-UP->>", $from, $to, $label, $techn, $descr, $sprite, $tags, $link)
|
||||
$getRel($up("-","->>"), $from, $to, $label, $techn, $descr, $sprite, $tags, $link)
|
||||
!endprocedure
|
||||
!unquoted procedure Rel_Up($from, $to, $label, $techn="", $descr="", $sprite="", $tags="", $link="")
|
||||
$getRel("-UP->>", $from, $to, $label, $techn, $descr, $sprite, $tags, $link)
|
||||
$getRel($up("-","->>"), $from, $to, $label, $techn, $descr, $sprite, $tags, $link)
|
||||
!endprocedure
|
||||
|
||||
!unquoted procedure BiRel_U($from, $to, $label, $techn="", $descr="", $sprite="", $tags="", $link="")
|
||||
$getRel("<<-UP->>", $from, $to, $label, $techn, $descr, $sprite, $tags, $link)
|
||||
$getRel($up("<<-","->>"), $from, $to, $label, $techn, $descr, $sprite, $tags, $link)
|
||||
!endprocedure
|
||||
!unquoted procedure BiRel_Up($from, $to, $label, $techn="", $descr="", $sprite="", $tags="", $link="")
|
||||
$getRel("<<-UP->>", $from, $to, $label, $techn, $descr, $sprite, $tags, $link)
|
||||
$getRel($up("<<-","->>"), $from, $to, $label, $techn, $descr, $sprite, $tags, $link)
|
||||
!endprocedure
|
||||
|
||||
!unquoted procedure Rel_L($from, $to, $label, $techn="", $descr="", $sprite="", $tags="", $link="")
|
||||
$getRel("-LEFT->>", $from, $to, $label, $techn, $descr, $sprite, $tags, $link)
|
||||
$getRel($left("-","->>"), $from, $to, $label, $techn, $descr, $sprite, $tags, $link)
|
||||
!endprocedure
|
||||
!unquoted procedure Rel_Left($from, $to, $label, $techn="", $descr="", $sprite="", $tags="", $link="")
|
||||
$getRel("-LEFT->>", $from, $to, $label, $techn, $descr, $sprite, $tags, $link)
|
||||
$getRel($left("-","->>"), $from, $to, $label, $techn, $descr, $sprite, $tags, $link)
|
||||
!endprocedure
|
||||
|
||||
!unquoted procedure BiRel_L($from, $to, $label, $techn="", $descr="", $sprite="", $tags="", $link="")
|
||||
$getRel("<<-LEFT->>", $from, $to, $label, $techn, $descr, $sprite, $tags, $link)
|
||||
$getRel($left("<<-","->>"), $from, $to, $label, $techn, $descr, $sprite, $tags, $link)
|
||||
!endprocedure
|
||||
!unquoted procedure BiRel_Left($from, $to, $label, $techn="", $descr="", $sprite="", $tags="", $link="")
|
||||
$getRel("<<-LEFT->>", $from, $to, $label, $techn, $descr, $sprite, $tags, $link)
|
||||
$getRel($left("<<-","->>"), $from, $to, $label, $techn, $descr, $sprite, $tags, $link)
|
||||
!endprocedure
|
||||
|
||||
!unquoted procedure Rel_R($from, $to, $label, $techn="", $descr="", $sprite="", $tags="", $link="")
|
||||
$getRel("-RIGHT->>", $from, $to, $label, $techn, $descr, $sprite, $tags, $link)
|
||||
$getRel($right("-","->>"), $from, $to, $label, $techn, $descr, $sprite, $tags, $link)
|
||||
!endprocedure
|
||||
!unquoted procedure Rel_Right($from, $to, $label, $techn="", $descr="", $sprite="", $tags="", $link="")
|
||||
$getRel("-RIGHT->>", $from, $to, $label, $techn, $descr, $sprite, $tags, $link)
|
||||
$getRel($right("-","->>"), $from, $to, $label, $techn, $descr, $sprite, $tags, $link)
|
||||
!endprocedure
|
||||
|
||||
!unquoted procedure BiRel_R($from, $to, $label, $techn="", $descr="", $sprite="", $tags="", $link="")
|
||||
$getRel("<<-RIGHT->>", $from, $to, $label, $techn, $descr, $sprite, $tags, $link)
|
||||
$getRel($right("<<-","->>"), $from, $to, $label, $techn, $descr, $sprite, $tags, $link)
|
||||
!endprocedure
|
||||
!unquoted procedure BiRel_Right($from, $to, $label, $techn="", $descr="", $sprite="", $tags="", $link="")
|
||||
$getRel("<<-RIGHT->>", $from, $to, $label, $techn, $descr, $sprite, $tags, $link)
|
||||
$getRel($right("<<-","->>"), $from, $to, $label, $techn, $descr, $sprite, $tags, $link)
|
||||
!endprocedure
|
||||
|
||||
' Layout Helpers
|
||||
|
||||
+1
-1
@@ -196,7 +196,7 @@ endlegend
|
||||
' ##################################
|
||||
|
||||
!function $getPerson($label, $descr, $sprite)
|
||||
!if ($sprite == "") && ($defaultPersonSprite!="")
|
||||
!if ($sprite == "") && ($defaultPersonSprite != "")
|
||||
!$sprite = $defaultPersonSprite
|
||||
!endif
|
||||
!if ($descr == "") && ($sprite == "")
|
||||
|
||||
+4
-4
@@ -40,7 +40,7 @@ SetDefaultLegendEntries("person\nsystem\ncontainer\nexternal_person\nexternal_sy
|
||||
' 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
|
||||
!global $NODE_DESCR_MAX_CHAR_WIDTH = 32
|
||||
|
||||
!unquoted function $breakNode($type, $widthStr)
|
||||
!$width = %intval($widthStr)
|
||||
@@ -52,9 +52,9 @@ SetDefaultLegendEntries("person\nsystem\ncontainer\nexternal_person\nexternal_sy
|
||||
!$type = %substr($type, $brPos+2)
|
||||
!endwhile
|
||||
!else
|
||||
!while (%strlen($type)>$width)
|
||||
!while (%strlen($type) > $width)
|
||||
!$brPos = $width
|
||||
!while ($brPos>0 && %substr($type, $brPos, 1)!= ' ')
|
||||
!while ($brPos > 0 && %substr($type, $brPos, 1) != ' ')
|
||||
!$brPos = $brPos - 1
|
||||
!endwhile
|
||||
|
||||
@@ -72,7 +72,7 @@ SetDefaultLegendEntries("person\nsystem\ncontainer\nexternal_person\nexternal_sy
|
||||
!endif
|
||||
!endwhile
|
||||
!endif
|
||||
!if (%strlen($type)>0)
|
||||
!if (%strlen($type) > 0)
|
||||
!$multiLine = $multiLine + $type
|
||||
!endif
|
||||
!return $multiLine
|
||||
|
||||
+17
-17
@@ -33,7 +33,7 @@
|
||||
|
||||
!procedure setIndex($new_index)
|
||||
!$lastIndex = $index
|
||||
!$index= $new_index
|
||||
!$index = $new_index
|
||||
!endprocedure
|
||||
|
||||
!function Index($offset=1)
|
||||
@@ -94,53 +94,53 @@ $getRel("<<-", $from, $to, $e_index + ": " + $label, $techn, $descr, $sprite, $t
|
||||
!endprocedure
|
||||
|
||||
!unquoted procedure Rel_D($from, $to, $label, $techn="", $descr="", $sprite="", $tags="", $link="")
|
||||
$getRel("-DOWN->>", $from, $to, Index() + ": " + $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)
|
||||
$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)
|
||||
$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)
|
||||
$getRel($down("-","->>"), $from, $to, $e_index + ": " + $label, $techn, $descr, $sprite, $tags, $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)
|
||||
$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)
|
||||
$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)
|
||||
$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)
|
||||
$getRel($up("-","->>"), $from, $to, $e_index + ": " + $label, $techn, $descr, $sprite, $tags, $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)
|
||||
$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)
|
||||
$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)
|
||||
$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)
|
||||
$getRel($left("-","->>"), $from, $to, $e_index + ": " + $label, $techn, $descr, $sprite, $tags, $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)
|
||||
$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)
|
||||
$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)
|
||||
$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)
|
||||
$getRel($right("-","->>"), $from, $to, $e_index + ": " + $label, $techn, $descr, $sprite, $tags, $link)
|
||||
!endprocedure
|
||||
|
||||
+50
-17
@@ -6,11 +6,11 @@ PlantUML uses [Graphviz](https://www.graphviz.org/) for its graph visualization.
|
||||
|
||||
For this reason, C4-PlantUML also comes with some layout options.
|
||||
|
||||
## LAYOUT_TOP_DOWN() or LAYOUT_LEFT_RIGHT()
|
||||
## LAYOUT_TOP_DOWN() or LAYOUT_LEFT_RIGHT() or LAYOUT_LANDSCAPE()
|
||||
|
||||
With the two macros `LAYOUT_TOP_DOWN()` and `LAYOUT_LEFT_RIGHT()` it is possible to easily change the flow visualization of the diagram. `LAYOUT_TOP_DOWN()` is the default.
|
||||
|
||||
```csharp
|
||||
```plantuml
|
||||
@startuml LAYOUT_TOP_DOWN Sample
|
||||
!include https://raw.githubusercontent.com/plantuml-stdlib/C4-PlantUML/master/C4_Container.puml
|
||||
|
||||
@@ -30,10 +30,9 @@ Rel(web_app, twitter, "Gets tweets from", "HTTPS")
|
||||
|
||||

|
||||
|
||||
`LAYOUT_LEFT_RIGHT()` rotates the flow visualization to *from Left to Right* and directed relations like `Rel_Left()`, `Rel_Right()`, `Rel_Up()` and `Rel_Down()` are rotated too.
|
||||
|
||||
Using `LAYOUT_LEFT_RIGHT()`
|
||||
|
||||
```csharp
|
||||
```plantuml
|
||||
@startuml LAYOUT_LEFT_RIGHT Sample
|
||||
!include https://raw.githubusercontent.com/plantuml-stdlib/C4-PlantUML/master/C4_Container.puml
|
||||
|
||||
@@ -52,6 +51,40 @@ Rel(web_app, twitter, "Gets tweets from", "HTTPS")
|
||||
|
||||

|
||||
|
||||
`LAYOUT_LANDSCAPE()` rotates the default flow visualization to *from Left to Right* like `LAYOUT_LEFT_RIGHT()` additional **directed relations** like Rel_Left(), Rel_Right(), Rel_Up() and Rel_Down() **are not rotated** anymore.
|
||||
|
||||
```plantuml
|
||||
@startuml LAYOUT_LANDSCAPE Sample
|
||||
!include https://raw.githubusercontent.com/plantuml-stdlib/C4-PlantUML/master/C4_Container.puml
|
||||
|
||||
LAYOUT_LANDSCAPE()
|
||||
|
||||
Person(admin, "Administrator")
|
||||
System_Boundary(c1, 'Sample') {
|
||||
Container(web_app, "Web Application", "C#, ASP.NET Core 2.1 MVC", "Allows users to compare multiple Twitter timelines")
|
||||
}
|
||||
System(twitter, "Twitter")
|
||||
|
||||
Rel(admin, web_app, "Uses", "HTTPS")
|
||||
Rel(web_app, twitter, "Gets tweets from", "HTTPS")
|
||||
|
||||
System(S,"S")
|
||||
System(SU,"S Up")
|
||||
System(SD,"S Down")
|
||||
System(SL,"S Left")
|
||||
System(SR,"S Right")
|
||||
|
||||
Rel_Up(S, SU, "Up")
|
||||
Rel_Down(S, SD, "Down")
|
||||
Rel_Left(S, SL, "Left")
|
||||
Rel_Right(S, SR, "Right")
|
||||
|
||||
SHOW_LEGEND()
|
||||
|
||||
@enduml
|
||||
```
|
||||
|
||||

|
||||
|
||||
## LAYOUT_WITH_LEGEND() or SHOW_LEGEND(?hideStereotype)
|
||||
|
||||
@@ -61,7 +94,7 @@ It can also help to save some space.
|
||||
All of that is the reason, C4-PlantUML uses colors and prefer also to enable a layout without `<<stereotypes>>` and with a legend.
|
||||
This can be enabled with `LAYOUT_WITH_LEGEND()`.
|
||||
|
||||
```csharp
|
||||
```plantuml
|
||||
@startuml LAYOUT_WITH_LEGEND Sample
|
||||
!include https://raw.githubusercontent.com/plantuml-stdlib/C4-PlantUML/master/C4_Container.puml
|
||||
|
||||
@@ -88,7 +121,7 @@ The calculated legend has following differences:
|
||||
* stereotypes can remain visible (with `SHOW_LEGEND(false)`)
|
||||
* **`SHOW_LEGEND()` has to be last call in the diagram**
|
||||
|
||||
```csharp
|
||||
```plantuml
|
||||
@startuml SHOW_LEGEND Sample
|
||||
!include https://raw.githubusercontent.com/plantuml-stdlib/C4-PlantUML/master/C4_Container.puml
|
||||
|
||||
@@ -111,7 +144,7 @@ SHOW_LEGEND()
|
||||
|
||||
`LAYOUT_WITH_LEGEND()` and SHOW_LEGEND(?hideStereotype)` adds the legend at the bottom right of the picture like below and additional whitespace is created.
|
||||
|
||||
```csharp
|
||||
```plantuml
|
||||
@startuml Layout With Whitespace Sample
|
||||
!include https://raw.githubusercontent.com/plantuml-stdlib/C4-PlantUML/master/C4_Container.puml
|
||||
|
||||
@@ -137,7 +170,7 @@ Therefore a floating legend can be added via SHOW_FLOATING_LEGEND(), positioned
|
||||
- `SHOW_FLOATING_LEGEND(?alias, ?hideStereotype): shows the legend in the drawing area
|
||||
- `LEGEND()`: is the default alias of the created floating legend and can be used in Lay_Distance() call
|
||||
|
||||
```csharp
|
||||
```plantuml
|
||||
@startuml Compact Legend Layout Sample
|
||||
!include https://raw.githubusercontent.com/plantuml-stdlib/C4-PlantUML/master/C4_Container.puml
|
||||
|
||||
@@ -173,7 +206,7 @@ Without any proof
|
||||
More often these sketches are used by many people as facts and are manifested into their documentations.
|
||||
With `LAYOUT_AS_SKETCH()` you can make a difference.
|
||||
|
||||
```csharp
|
||||
```plantuml
|
||||
@startuml LAYOUT_AS_SKETCH Sample
|
||||
!include https://raw.githubusercontent.com/plantuml-stdlib/C4-PlantUML/master/C4_Container.puml
|
||||
|
||||
@@ -198,7 +231,7 @@ Rel(web_app, twitter, "Gets tweets from", "HTTPS")
|
||||
To enable a layout without `<<stereotypes>>` and legend.
|
||||
This can be enabled with `HIDE_STEREOTYPE()`.
|
||||
|
||||
```csharp
|
||||
```plantuml
|
||||
@startuml HIDE_STEREOTYPE Sample
|
||||
!include https://raw.githubusercontent.com/plantuml-stdlib/C4-PlantUML/master/C4_Container.puml
|
||||
|
||||
@@ -230,7 +263,7 @@ With the macros `HIDE_PERSON_SPRITE()`, `SHOW_PERSON_SPRITE()` and `SHOW_PERSON_
|
||||
|
||||
"person" and "person2" are predefined sprites which can be used as default sprite too.
|
||||
|
||||
```csharp
|
||||
```plantuml
|
||||
@startuml predefined sprites Sample
|
||||
!include https://raw.githubusercontent.com/plantuml-stdlib/C4-PlantUML/master/C4_Container.puml
|
||||
|
||||
@@ -244,7 +277,7 @@ Person(userB, "User B", "with predefined sprite person2", "person2")
|
||||
|
||||
**Using HIDE_PERSON_SPRITE()**
|
||||
|
||||
```csharp
|
||||
```plantuml
|
||||
@startuml HIDE_PERSON_SPRITE Sample
|
||||
!include https://raw.githubusercontent.com/plantuml-stdlib/C4-PlantUML/master/C4_Container.puml
|
||||
|
||||
@@ -265,7 +298,7 @@ Rel(web_app, twitter, "Gets tweets from", "HTTPS")
|
||||
|
||||
**Using SHOW_PERSON_SPRITE()**
|
||||
|
||||
```csharp
|
||||
```plantuml
|
||||
@startuml SHOW_PERSON_SPRITE Sample
|
||||
!include https://raw.githubusercontent.com/plantuml-stdlib/C4-PlantUML/master/C4_Container.puml
|
||||
|
||||
@@ -287,7 +320,7 @@ Rel(web_app, twitter, "Gets tweets from", "HTTPS")
|
||||
|
||||
**Using SHOW_PERSON_SPRITE(sprite)**
|
||||
|
||||
```csharp
|
||||
```plantuml
|
||||
@startuml SHOW_PERSON_SPRITE(sprite) Sample
|
||||
!include https://raw.githubusercontent.com/plantuml-stdlib/C4-PlantUML/master/C4_Container.puml
|
||||
!define osaPuml https://raw.githubusercontent.com/Crashedmind/PlantUML-opensecurityarchitecture2-icons/master
|
||||
@@ -311,7 +344,7 @@ Rel(web_app, twitter, "Gets tweets from", "HTTPS")
|
||||
|
||||
**Using SHOW_PERSON_PORTRAIT()**
|
||||
|
||||
```csharp
|
||||
```plantuml
|
||||
@startuml SHOW_PERSON_PORTRAIT() Sample
|
||||
!include https://raw.githubusercontent.com/plantuml-stdlib/C4-PlantUML/master/C4_Container.puml
|
||||
|
||||
@@ -337,7 +370,7 @@ Rel(web_app, twitter, "Gets tweets from", "HTTPS")
|
||||
|
||||
> This call requires PlantUML version >= v1.2021.4!
|
||||
|
||||
```csharp
|
||||
```plantuml
|
||||
@startuml SHOW_PERSON_OUTLINE() Sample
|
||||
!include https://raw.githubusercontent.com/plantuml-stdlib/C4-PlantUML/master/C4_Container.puml
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# C4-PlantUML
|
||||
|
||||

|
||||

|
||||
|
||||
C4-PlantUML combines the benefits of [PlantUML](https://plantuml.com/) and the [C4 model](https://c4model.com/) for providing a simple way of describing and communicate software architectures – especially during up-front design sessions – with an intuitive language using open source and platform independent tools.
|
||||
|
||||
@@ -20,13 +20,13 @@ At the top of your C4 PlantUML `.puml` file, you need to include the `C4_Context
|
||||
|
||||
To be independent of any internet connectivity, you can also download the files found in the `root` and activate the local conversion with additional command line argument `-DRELATIVE_INCLUDE="."` (that the local files are included)
|
||||
|
||||
```csharp
|
||||
```plantuml
|
||||
java -jar plantuml.jar -DRELATIVE_INCLUDE="." ...
|
||||
```
|
||||
|
||||
If you want to use the always up-to-date version in this repo, use the following:
|
||||
|
||||
```csharp
|
||||
```plantuml
|
||||
!include https://raw.githubusercontent.com/plantuml-stdlib/C4-PlantUML/master/C4_Container.puml
|
||||
```
|
||||
|
||||
@@ -36,7 +36,7 @@ Now let's create a C4 Container diagram:
|
||||
|
||||
After you have included `C4_Container.puml` you can use the defined macro definitions for the C4 elements: `Person`, `Person_Ext`, `System`, `System_Ext`, `Container`, `Relationship`, `Boundary`, and `System_Boundary`
|
||||
|
||||
```csharp
|
||||
```plantuml
|
||||
@startuml C4_Elements
|
||||
!include https://raw.githubusercontent.com/plantuml-stdlib/C4-PlantUML/master/C4_Container.puml
|
||||
|
||||
@@ -54,7 +54,7 @@ In addition to this, it is also possible to define a system or component boundar
|
||||
|
||||
Take a look at the following sample of a C4 Container Diagram:
|
||||
|
||||
```csharp
|
||||
```plantuml
|
||||
@startuml Basic Sample
|
||||
!include https://raw.githubusercontent.com/plantuml-stdlib/C4-PlantUML/master/C4_Container.puml
|
||||
|
||||
@@ -73,7 +73,7 @@ Rel(web_app, twitter, "Gets tweets from", "HTTPS")
|
||||
|
||||
Entities can also be decorated with icons/sprites using the $sprite parameter, for example:
|
||||
|
||||
```csharp
|
||||
```plantuml
|
||||
@startuml
|
||||
!include https://raw.githubusercontent.com/plantuml-stdlib/C4-PlantUML/master/C4_Container.puml
|
||||
|
||||
@@ -101,7 +101,7 @@ Rel_R(api, db, "Reads/Writes")
|
||||
|
||||
Similar to icons/sprites is it possible to add links to all elements and relationships:
|
||||
|
||||
```csharp
|
||||
```plantuml
|
||||
@startuml Basic Sample
|
||||
!include https://raw.githubusercontent.com/plantuml-stdlib/C4-PlantUML/master/C4_Container.puml
|
||||
|
||||
@@ -124,7 +124,7 @@ Rel(web_app, twitter, "Gets tweets from", "HTTPS", $link="https://plantuml.com/l
|
||||
|
||||
Elements and relations can be decorated with tags and explained via a calculated legend, for example:
|
||||
|
||||
```csharp
|
||||
```plantuml
|
||||
@startuml
|
||||
!include https://raw.githubusercontent.com/plantuml-stdlib/C4-PlantUML/master/C4_Container.puml
|
||||
|
||||
@@ -237,7 +237,7 @@ Relationship specific sprites are typically smaller and therefore following opti
|
||||
* use an additional scale factor (direct as part of the argument, or via a variable)
|
||||
* if sprite argument starts with `&` an OpenIconic name can be used too (details see https://useiconic.com/open)
|
||||
|
||||
```csharp
|
||||
```plantuml
|
||||
@startuml
|
||||
!include https://raw.githubusercontent.com/plantuml-stdlib/C4-PlantUML/master/C4_Context.puml
|
||||
|
||||
@@ -292,7 +292,7 @@ In rare cases, you can force the layout of objects which have no relationships b
|
||||
|
||||
In following sample a person uses different systems, and group of persons which have no relations
|
||||
|
||||
```csharp
|
||||
```plantuml
|
||||
@startuml
|
||||
!include https://raw.githubusercontent.com/plantuml-stdlib/C4-PlantUML/master/C4_Container.puml
|
||||
HIDE_STEREOTYPE()
|
||||
@@ -331,7 +331,7 @@ e.g. floating legend could be required that all e.g. corners of the drawing area
|
||||
In following sample the floating legend should be in the left bottom corner of the drawing are.
|
||||
(The normal SHOW_LEGEND() call requires no extra Lay_Distance() call and the legend is automatically drawn below the diagram on the right side)
|
||||
|
||||
```
|
||||
```plantuml
|
||||
@startuml
|
||||
!include https://raw.githubusercontent.com/plantuml-stdlib/C4-PlantUML/master/C4_Container.puml
|
||||
|
||||
@@ -362,7 +362,7 @@ Lay_Distance(LEGEND(), db, 1)
|
||||
|
||||
C4-PlantUML also comes with some layout options to make it easy and reusable to create nice and useful diagrams:
|
||||
|
||||
* [LAYOUT_TOP_DOWN() or LAYOUT_LEFT_RIGHT()](LayoutOptions.md#layout_top_down-or-layout_left_right)
|
||||
* [LAYOUT_TOP_DOWN() or LAYOUT_LEFT_RIGHT() or LAYOUT_LANDSCAPE()](LayoutOptions.md#layout_top_down-or-layout_left_right-or-layout_landscape)
|
||||
* [LAYOUT_WITH_LEGEND() or SHOW_LEGEND(?hideStereotype)](LayoutOptions.md#layout_with_legend-or-show_legend)
|
||||
* [SHOW_FLOATING_LEGEND(?alias, ?hideStereotype) and LEGEND()](LayoutOptions.md#show_floating_legendalias-hidestereotype-and-legend)
|
||||
* [LAYOUT_AS_SKETCH()](LayoutOptions.md#layout_as_sketch)
|
||||
@@ -399,11 +399,11 @@ Multiple tags can be combined with `+`, like `Container(api, "API", $tags="v1.0+
|
||||
**Element specific tag definitions**
|
||||
|
||||
Sometimes an added element tag is element specific and all element specific colors should be used, e.g. a specific user role should be defined as element tag with the specific colors `...PERSON_...` like
|
||||
```csharp
|
||||
```plantuml
|
||||
AddElementTag("admin", $fontColor=$ELEMENT_FONT_COLOR, $bgColor=$PERSON_BG_COLOR, $borderColor=$PERSON_BORDER_COLOR, $sprite="osa_user_audit", $legendText="administration user")
|
||||
```
|
||||
Therefore element Add...Tag() shortcuts are added which use the specific colors as default values and the call can be simplified like
|
||||
```csharp
|
||||
```plantuml
|
||||
AddPersonTag("admin", $sprite="osa_user_audit", $legendText="administration user")
|
||||
```
|
||||
|
||||
@@ -434,7 +434,7 @@ Following calls introduces new element tags with element specific default colors
|
||||
|
||||
**Sample with different tag combinations**
|
||||
|
||||
```csharp
|
||||
```plantuml
|
||||
@startuml
|
||||
!include https://raw.githubusercontent.com/plantuml-stdlib/C4-PlantUML/master/C4_Container.puml
|
||||
|
||||
@@ -478,7 +478,7 @@ SHOW_LEGEND(false)
|
||||
|
||||
**Sample with tag dependent sprites and custom legend text**
|
||||
|
||||
```csharp
|
||||
```plantuml
|
||||
@startuml
|
||||
!include https://raw.githubusercontent.com/plantuml-stdlib/C4-PlantUML/master/C4_Container.puml
|
||||
|
||||
@@ -539,7 +539,7 @@ SHOW_LEGEND()
|
||||
|
||||
If the custom (color) schema is defined via `UpdateElementStyle()` then the legend of existing elements is updated too.
|
||||
|
||||
```csharp
|
||||
```plantuml
|
||||
@startuml
|
||||
!include https://raw.githubusercontent.com/plantuml-stdlib/C4-PlantUML/master/C4_Context.puml
|
||||
|
||||
@@ -561,7 +561,7 @@ UpdateElementStyle("person", $bgColor=$COLOR_A_5, $fontColor=$COLOR_NEUTRAL, $bo
|
||||
UpdateElementStyle("external_person", $bgColor=$COLOR_B_5, $fontColor=$COLOR_NEUTRAL, $borderColor=$COLOR_B_1)
|
||||
UpdateElementStyle("system", $bgColor=$COLOR_A_4, $fontColor=$COLOR_NEUTRAL, $borderColor=$COLOR_A_2)
|
||||
UpdateElementStyle("external_system", $bgColor=$COLOR_B_4, $fontColor=$COLOR_NEUTRAL, $borderColor=$COLOR_B_2)
|
||||
UpdateRelStyle($lineColor=$COLOR_REL_LINE, &textColor=$COLOR_REL_TEXT)
|
||||
UpdateRelStyle($lineColor=$COLOR_REL_LINE, $textColor=$COLOR_REL_TEXT)
|
||||
|
||||
Person(customer, "Personal Banking Customer")
|
||||
System(banking_system, "Internet Banking System")
|
||||
@@ -584,16 +584,16 @@ SHOW_LEGEND()
|
||||
|
||||
A model can be extended with (a table of) properties that concrete deployments or more detailed concepts can be documented:
|
||||
|
||||
* `SetPropertyHeader(col1Name, col2Name, ?col3Name, ?col4Name)`:
|
||||
* `SetPropertyHeader(col1Name, col2Name, ?col3Name, ?col4Name)`
|
||||
The properties table can have up to 4 columns. The default header uses the column names "Name", "Description".
|
||||
* `WithoutPropertyHeader()`
|
||||
If no header is used, then the second column is bold.
|
||||
* `AddProperty(col1, col2, ?col3, `?col4)`
|
||||
* `AddProperty(col1, col2, ?col3, ?col4)`
|
||||
(All columns of) a property which will be added to the next element.
|
||||
|
||||
Following sample uses all 3 different property definitions (and the aligned deployment node).
|
||||
|
||||
```csharp
|
||||
```plantuml
|
||||
@startuml
|
||||
!include https://raw.githubusercontent.com/plantuml-stdlib/C4-PlantUML/master/C4_Deployment.puml
|
||||
|
||||
@@ -622,6 +622,33 @@ Rel(personAlias, containerAlias, "Label", "Optional Technology")
|
||||
|
||||

|
||||
|
||||
## Version information
|
||||
|
||||
C4-PlantUML offers version information like PlantUML with its `%version()` call.
|
||||
|
||||
* `C4Version()`: Current C4-PlantUML version (e.g. `2.4.0beta1`).
|
||||
* `C4VersionDetails()`: (Floating) version details with the current PlantUML and C4-PlantUML version. (It can be referenced via the alias `C4VersionDetailsArea`.)
|
||||
|
||||
```plantuml
|
||||
@startuml
|
||||
!include https://raw.githubusercontent.com/plantuml-stdlib/C4-PlantUML/master/C4_Container.puml
|
||||
|
||||
' existing plantuml version as text
|
||||
%version()
|
||||
|
||||
' new C4-Plantuml version as text
|
||||
C4Version()
|
||||
|
||||
' new C4-Plantuml version details (incl. PlantUML version) as table
|
||||
C4VersionDetails()
|
||||
|
||||
' version functions used in e.g. footer
|
||||
footer drawn with PlantUML v. %version() and C4-PlantUML v. C4Version()
|
||||
@enduml
|
||||
```
|
||||
|
||||

|
||||
|
||||
## Snippets for Visual Studio Code
|
||||
|
||||
Because the PlantUML support inside of Visual Studio Code is excellent with the [PlantUML extension](https://marketplace.visualstudio.com/items?itemName=jebbs.plantuml), you can also find VS Code snippets for C4-PlantUML at [.vscode/C4.code-snippets](.vscode/C4.code-snippets).
|
||||
|
||||
@@ -40,4 +40,5 @@ Rel_Back(email_system, backend_api, "Sends e-mails using", "sync, SMTP")
|
||||
Rel_Neighbor(backend_api, banking_system, "Uses", "sync/async, XML/HTTPS", $tags="sync/async")
|
||||
|
||||
SHOW_LEGEND()
|
||||
footer drawn with PlantUML v. %version() and C4-PlantUML v. C4Version()
|
||||
@enduml
|
||||
@@ -0,0 +1,32 @@
|
||||
@startuml
|
||||
' convert it with additional command line argument -DRELATIVE_INCLUDE="." to use locally
|
||||
!if %variable_exists("RELATIVE_INCLUDE")
|
||||
!include ./../C4_Component.puml
|
||||
!else
|
||||
!include https://raw.githubusercontent.com/plantuml-stdlib/C4-PlantUML/master/C4_Component.puml
|
||||
!endif
|
||||
|
||||
LAYOUT_LANDSCAPE()
|
||||
|
||||
Person(admin, "Administrator")
|
||||
System_Boundary(c1, 'Sample') {
|
||||
Container(web_app, "Web Application", "C#, ASP.NET Core 2.1 MVC", "Allows users to compare multiple Twitter timelines")
|
||||
}
|
||||
System(twitter, "Twitter")
|
||||
|
||||
Rel(admin, web_app, "Uses", "HTTPS")
|
||||
Rel(web_app, twitter, "Gets tweets from", "HTTPS")
|
||||
|
||||
System(S,"S")
|
||||
System(SU,"S Up")
|
||||
System(SD,"S Down")
|
||||
System(SL,"S Left")
|
||||
System(SR,"S Right")
|
||||
|
||||
Rel_Up(S, SU, "Up")
|
||||
Rel_Down(S, SD, "Down")
|
||||
Rel_Left(S, SL, "Left")
|
||||
Rel_Right(S, SR, "Right")
|
||||
|
||||
SHOW_LEGEND()
|
||||
@enduml
|
||||
@@ -0,0 +1,32 @@
|
||||
@startuml
|
||||
' convert it with additional command line argument -DRELATIVE_INCLUDE="." to use locally
|
||||
!if %variable_exists("RELATIVE_INCLUDE")
|
||||
!include ./../C4_Dynamic.puml
|
||||
!else
|
||||
!include https://raw.githubusercontent.com/plantuml-stdlib/C4-PlantUML/master/C4_Dynamic.puml
|
||||
!endif
|
||||
|
||||
LAYOUT_LANDSCAPE()
|
||||
|
||||
Person(admin, "Administrator")
|
||||
System_Boundary(c1, 'Sample') {
|
||||
Container(web_app, "Web Application", "C#, ASP.NET Core 2.1 MVC", "Allows users to compare multiple Twitter timelines")
|
||||
}
|
||||
System(twitter, "Twitter")
|
||||
|
||||
Rel(admin, web_app, "Uses", "HTTPS")
|
||||
Rel(web_app, twitter, "Gets tweets from", "HTTPS")
|
||||
|
||||
System(S,"S")
|
||||
System(SU,"S Up")
|
||||
System(SD,"S Down")
|
||||
System(SL,"S Left")
|
||||
System(SR,"S Right")
|
||||
|
||||
Rel_Up(S, SU, "Up")
|
||||
Rel_Down(S, SD, "Down")
|
||||
Rel_Left(S, SL, "Left")
|
||||
Rel_Right(S, SR, "Right")
|
||||
|
||||
SHOW_LEGEND()
|
||||
@enduml
|
||||
@@ -29,6 +29,8 @@ Rel_Back_Neighbor(RelFrom, "To_Rel_Back_Neighbor_Tech", "A label", "A techn")
|
||||
|
||||
BiRel(BiRelFrom, "To_BiRel", "A label")
|
||||
BiRel(BiRelFrom, "To_BiRel_Tech", "A label", "A techn")
|
||||
BiRel_Neighbor(BiRelFrom, "To_BiRel_Neighbor", "A label")
|
||||
BiRel_Neighbor(BiRelFrom, "To_BiRel_Neighbor_Tech", "A label", "A techn")
|
||||
|
||||
Rel_D(RelShort, "To_Rel_D", "A label")
|
||||
Rel_D(RelShort, "To_Rel_D_Tech", "A label", "A techn")
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
@startuml
|
||||
' convert it with additional command line argument -DRELATIVE_INCLUDE="." to use locally
|
||||
!if %variable_exists("RELATIVE_INCLUDE")
|
||||
!include ./../C4_Deployment.puml
|
||||
!else
|
||||
!include https://raw.githubusercontent.com/plantuml-stdlib/C4-PlantUML/master/C4_Deployment.puml
|
||||
!endif
|
||||
|
||||
' existing plantuml version as text
|
||||
%version()
|
||||
|
||||
' new C4-Plantuml version as text
|
||||
C4Version()
|
||||
|
||||
' new C4-Plantuml version details (incl. PlantUML version) as table
|
||||
C4VersionDetails()
|
||||
|
||||
' version functions used in e.g. footer
|
||||
footer drawn with PlantUML v. %version() and C4-PlantUML v. C4Version()
|
||||
|
||||
@enduml
|
||||
Reference in New Issue
Block a user