Skip to content

Commit c811921

Browse files
committed
plantuml-stdlib#245,plantuml-stdlib#291 Themes can be defined/used (5 - extract all constant values)
1 parent 5b0d601 commit c811921

File tree

2 files changed

+31
-21
lines changed

2 files changed

+31
-21
lines changed

C4.puml

+24-14
Original file line numberDiff line numberDiff line change
@@ -67,17 +67,34 @@ rectangle C4VersionDetailsArea <<legendArea>> [
6767

6868
!$STEREOTYPE_FONT_SIZE ?= 12
6969
!global $TRANSPARENT_STEREOTYPE_FONT_SIZE = $STEREOTYPE_FONT_SIZE/2
70-
7170
!$TECHN_FONT_SIZE ?= 12
72-
!$ROUNDED_BOX_SIZE ?= 25
73-
!$EIGHT_SIDED_SIZE ?= 18
7471

7572
!$ARROW_FONT_SIZE ?= 12
7673

7774
!$LEGEND_DETAILS_SMALL_SIZE ?= 10
7875
!$LEGEND_DETAILS_NORMAL_SIZE ?= 14
7976
!global $LEGEND_DETAILS_SIZE = $LEGEND_DETAILS_SMALL_SIZE
8077

78+
' element symbols typically 4 times too big in legend
79+
!$LEGEND_IMAGE_SIZE_FACTOR ?= 0.25
80+
81+
!$ROUNDED_BOX_SIZE ?= 25
82+
!$EIGHT_SIDED_SIZE ?= 18
83+
84+
' Default element wrap width (of an element)
85+
!$DEFAULT_WRAP_WIDTH ?= 200
86+
' Maximum size in pixels, of a message (in a sequence diagram?)
87+
!$MAX_MESSAGE_SIZE ?= 150
88+
' PlantUML supports no DETERMINISTIC/automatic line breaks of "PlantUML line" (C4 Relationships)
89+
' therefore Rel...() implements an automatic line break based on spaces (like in all other objects).
90+
' If a $type contains \n then these are used (and no automatic space based line breaks are done)
91+
' $REL_TECHN_MAX_CHAR_WIDTH defines the automatic line break position
92+
!$REL_TECHN_MAX_CHAR_WIDTH ?= 35
93+
!$REL_DESCR_MAX_CHAR_WIDTH ?= 32
94+
95+
' internal
96+
' ##################################
97+
8198
!global $ROUNDED_BOX = "roundedBox"
8299
!global $EIGHT_SIDED = "eightSided"
83100

@@ -91,8 +108,8 @@ rectangle C4VersionDetailsArea <<legendArea>> [
91108

92109
skinparam defaultTextAlignment center
93110

94-
skinparam wrapWidth 200
95-
skinparam maxMessageSize 150
111+
skinparam wrapWidth $DEFAULT_WRAP_WIDTH
112+
skinparam maxMessageSize $MAX_MESSAGE_SIZE
96113

97114
skinparam LegendFontColor $LEGEND_FONT_COLOR
98115
skinparam LegendBackgroundColor $LEGEND_BG_COLOR
@@ -465,9 +482,9 @@ $elementSkin
465482
' ,scale= ... has to be first (...,color=black,scale=0.25... is invalid too)
466483
!if (%strpos($sprite, "=") < 0)
467484
!if (%substr($sprite, 0, 4) == "img:")
468-
!$smallSprite = $sprite + "{scale=0.25}"
485+
!$smallSprite = $sprite + "{scale=" + $LEGEND_IMAGE_SIZE_FACTOR + "}"
469486
!else
470-
!$smallSprite = $sprite + ",scale=0.25"
487+
!$smallSprite = $sprite + ",scale=" + $LEGEND_IMAGE_SIZE_FACTOR
471488
!endif
472489
!else
473490
!$smallSprite = $sprite
@@ -870,13 +887,6 @@ $elementSkin
870887
' Line breaks
871888
' ##################################
872889

873-
' PlantUML supports no DETERMINISTIC/automatic line breaks of "PlantUML line" (C4 Relationships)
874-
' therefore Rel...() implements an automatic line break based on spaces (like in all other objects).
875-
' If a $type contains \n then these are used (and no automatic space based line breaks are done)
876-
' $REL_TECHN_MAX_CHAR_WIDTH defines the automatic line break position
877-
!global $REL_TECHN_MAX_CHAR_WIDTH = 35
878-
!global $REL_DESCR_MAX_CHAR_WIDTH = 32
879-
880890
!unquoted function $breakText($text, $usedNewLine, $widthStr="-1")
881891
!$width = %intval($widthStr)
882892
!$multiLine = ""

C4_Deployment.puml

+7-7
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,13 @@
1515
' Styling
1616
' ##################################
1717

18+
' PlantUML supports no automatic line breaks of "PlantUML containers" (C4 Deployment_Node is a "PlantUML container")
19+
' therefore (Deployment_)Node() implements an automatic line break based on spaces (like in all other objects).
20+
' If a $type contains \n then these are used (and no automatic space based line breaks are done)
21+
' $NODE_TYPE_MAX_CHAR_WIDTH defines the automatic line break position
22+
!$NODE_TYPE_MAX_CHAR_WIDTH ?= 35
23+
!$NODE_DESCR_MAX_CHAR_WIDTH ?= 32
24+
1825
UpdateElementStyle("node", $bgColor=$NODE_BG_COLOR, $fontColor=$NODE_FONT_COLOR, $borderColor=$NODE_BORDER_COLOR)
1926
skinparam rectangle<<node>> {
2027
FontStyle normal
@@ -36,13 +43,6 @@ SetDefaultLegendEntries("person\nsystem\ncontainer\nexternal_person\nexternal_sy
3643
' Line breaks
3744
' ##################################
3845

39-
' PlantUML supports no automatic line breaks of "PlantUML containers" (C4 Deployment_Node is a "PlantUML container")
40-
' therefore (Deployment_)Node() implements an automatic line break based on spaces (like in all other objects).
41-
' If a $type contains \n then these are used (and no automatic space based line breaks are done)
42-
' $NODE_TYPE_MAX_CHAR_WIDTH defines the automatic line break position
43-
!global $NODE_TYPE_MAX_CHAR_WIDTH = 35
44-
!global $NODE_DESCR_MAX_CHAR_WIDTH = 32
45-
4646
' $breakTechn() in C4 supports //...//; $breakNode() in C4_Deployment supports no //....//
4747
!unquoted function $breakNode($text, $widthStr)
4848
!$usedNewLine = '</size>\n<size:'+$TECHN_FONT_SIZE+'>'

0 commit comments

Comments
 (0)