forked from plantuml-stdlib/C4-PlantUML
-
Notifications
You must be signed in to change notification settings - Fork 0
/
C4_Deployment.puml
139 lines (119 loc) · 6.14 KB
/
C4_Deployment.puml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
' convert it with additional command line argument -DRELATIVE_INCLUDE="relative/absolute" to use locally
!if %variable_exists("RELATIVE_INCLUDE")
!include ./C4_Container.puml
!else
!include https://raw.githubusercontent.com/plantuml-stdlib/C4-PlantUML/master/C4_Container.puml
!endif
' Colors
' ##################################
!global $NODE_FONT_COLOR = "#000000"
!global $NODE_BG_COLOR = "#FFFFFF"
!global $NODE_BORDER_COLOR = "#A2A2A2"
' Styling
' ##################################
UpdateElementStyle("node", $bgColor=$NODE_BG_COLOR, $fontColor=$NODE_FONT_COLOR, $borderColor=$NODE_BORDER_COLOR)
skinparam rectangle<<node>> {
FontStyle normal
}
' shortcuts with default colors
' node specific: $type reuses $techn definition of $tags
!unquoted procedure AddNodeTag($tagStereo, $bgColor="", $fontColor="", $borderColor="", $shadowing="", $shape="", $sprite="", $techn="", $legendText="", $legendSprite="")
$addElementTagInclReuse("node", $tagStereo, $bgColor, $fontColor, $borderColor, $shadowing, $shape, $sprite, $techn, $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\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
' $breakTechn() in C4 supports //...//; $breakNode() in C4_Deployment supports no //....//
!unquoted function $breakNode($text, $widthStr)
!$usedNewLine = '</size>\n<size:'+$TECHN_FONT_SIZE+'>'
!return $breakText($text, $usedNewLine, $widthStr)
!endfunction
' Elements
' ##################################
!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<size:' + $TECHN_FONT_SIZE + '>[' + $breakNode($type, $NODE_TYPE_MAX_CHAR_WIDTH) + ']</size>'
!endif
!if ($descr != "")
!$nodeText = $nodeText + '\n\n' + $breakDescr($descr, $NODE_DESCR_MAX_CHAR_WIDTH)
!endif
!return $nodeText
!endfunction
!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<size:' + $TECHN_FONT_SIZE + '>[' + $breakNode($type, $NODE_TYPE_MAX_CHAR_WIDTH) + ']</size>'
!endif
!if ($descr != "")
!$nodeText = $nodeText + '\l\l' + $breakDescr($descr, $NODE_DESCR_MAX_CHAR_WIDTH)
!endif
!return $nodeText
!endfunction
!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<size:' + $TECHN_FONT_SIZE + '>[' + $breakNode($type, $NODE_TYPE_MAX_CHAR_WIDTH) + ']</size>'
!endif
!if ($descr != "")
!$nodeText = $nodeText + '\r\r' + $breakDescr($descr, $NODE_DESCR_MAX_CHAR_WIDTH)
!endif
!return $nodeText
!endfunction
!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 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 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 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 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 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