Skip to content

Commit abf4877

Browse files
committed
Merge branch 'feature/350_boundaries_descr_sprite' into extended
2 parents fc2587a + 096629c commit abf4877

8 files changed

+88
-61
lines changed

C4.puml

+30-19
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ rectangle C4VersionDetailsArea <<legendArea>> [
3434
!$BOUNDARY_COLOR ?= "#444444"
3535
!$BOUNDARY_BG_COLOR ?= "transparent"
3636
!$BOUNDARY_BORDER_STYLE ?= "dashed"
37+
' boundary symbols written in the same line, typically only 50% of the size in element
38+
!$BOUNDARY_IMAGE_SIZE_FACTOR ?= 0.5
39+
!$BOUNDARY_DESCR_MAX_CHAR_WIDTH ?= 35
3740

3841
!$LEGEND_TITLE_COLOR ?= "#000000"
3942
!$LEGEND_FONT_COLOR ?= "#FFFFFF"
@@ -595,13 +598,13 @@ $elementSkin
595598
!endfunction
596599

597600
' element symbols typically 4 times too big in legend
598-
!function $smallVersionSprite($sprite)
601+
!function $smallVersionSprite($sprite, $imageScale = $LEGEND_IMAGE_SIZE_FACTOR)
599602
' ,scale= ... has to be first (...,color=black,scale=0.25... is invalid too)
600603
!if (%strpos($sprite, "=") < 0)
601604
!if (%substr($sprite, 0, 4) == "img:")
602-
!$smallSprite = $sprite + "{scale=" + $LEGEND_IMAGE_SIZE_FACTOR + "}"
605+
!$smallSprite = $sprite + "{scale=" + $imageScale + "}"
603606
!else
604-
!$smallSprite = $sprite + ",scale=" + $LEGEND_IMAGE_SIZE_FACTOR
607+
!$smallSprite = $sprite + ",scale=" + $imageScale
605608
!endif
606609
!else
607610
!$smallSprite = $sprite
@@ -1373,22 +1376,22 @@ $getLegendArea($alias, $hideStereotype, $details)
13731376
' Boundaries
13741377
' ##################################
13751378

1376-
!unquoted procedure UpdateBoundaryStyle($elementName="", $bgColor="", $fontColor="", $borderColor="", $shadowing="", $shape="", $type="", $legendText="", $borderStyle="", $borderThickness="")
1379+
!unquoted procedure UpdateBoundaryStyle($elementName="", $bgColor="", $fontColor="", $borderColor="", $shadowing="", $shape="", $type="", $legendText="", $borderStyle="", $borderThickness="", $sprite="", $legendSprite="")
13771380
!if ($elementName != "")
13781381
!$elementBoundary = $elementName + '_boundary'
1379-
UpdateElementStyle($elementBoundary, $bgColor, $fontColor, $borderColor, $shadowing, $shape, "", $type, $legendText, "", $borderStyle, $borderThickness)
1382+
UpdateElementStyle($elementBoundary, $bgColor, $fontColor, $borderColor, $shadowing, $shape, $sprite, $type, $legendText, $legendSprite, $borderStyle, $borderThickness)
13801383
!else
1381-
UpdateElementStyle("boundary", $bgColor, $fontColor, $borderColor, $shadowing, $shape, "", $type, $legendText, "", $borderStyle, $borderThickness)
1384+
UpdateElementStyle("boundary", $bgColor, $fontColor, $borderColor, $shadowing, $shape, $sprite, $type, $legendText, $legendSprite, $borderStyle, $borderThickness)
13821385
' simulate color inheritance
1383-
UpdateBoundaryStyle("enterprise", $bgColor, $fontColor, $borderColor, $shadowing, $shape, "Enterprise", "", $borderStyle, $borderThickness)
1384-
UpdateBoundaryStyle("system", $bgColor, $fontColor, $borderColor, $shadowing, $shape, "System", "", $borderStyle, $borderThickness)
1385-
UpdateBoundaryStyle("container", $bgColor, $fontColor, $borderColor, $shadowing, $shape, "Container", "", $borderStyle, $borderThickness)
1386+
UpdateBoundaryStyle("enterprise", $bgColor, $fontColor, $borderColor, $shadowing, $shape, "Enterprise", "", $borderStyle, $borderThickness, $sprite, $legendSprite)
1387+
UpdateBoundaryStyle("system", $bgColor, $fontColor, $borderColor, $shadowing, $shape, "System", "", $borderStyle, $borderThickness, $sprite, $legendSprite)
1388+
UpdateBoundaryStyle("container", $bgColor, $fontColor, $borderColor, $shadowing, $shape, "Container", "", $borderStyle, $borderThickness, $sprite, $legendSprite)
13861389
!endif
13871390
!endprocedure
13881391

1389-
!unquoted procedure AddBoundaryTag($tagStereo, $bgColor="", $fontColor="", $borderColor="", $shadowing="", $shape="", $type="", $legendText="", $borderStyle="", $borderThickness="")
1392+
!unquoted procedure AddBoundaryTag($tagStereo, $bgColor="", $fontColor="", $borderColor="", $shadowing="", $shape="", $type="", $legendText="", $borderStyle="", $borderThickness="", $sprite="", $legendSprite="")
13901393
!$tagBoundary = $tagStereo + '_boundary'
1391-
AddElementTag($tagBoundary, $bgColor, $fontColor, $borderColor, $shadowing, $shape, "", $type, $legendText, "", $borderStyle, $borderThickness)
1394+
AddElementTag($tagBoundary, $bgColor, $fontColor, $borderColor, $shadowing, $shape, $sprite, $type, $legendText, $legendSprite, $borderStyle, $borderThickness)
13921395
!endprocedure
13931396

13941397
' add _boundary to all tags that short tag version can be used
@@ -1410,20 +1413,28 @@ $getLegendArea($alias, $hideStereotype, $details)
14101413
!return $boundaryTags
14111414
!endfunction
14121415

1413-
!function $getBoundary($label, $type)
1414-
!if ($type == "")
1415-
!return '== ' + $breakLabel($label)
1416+
!function $getBoundary($label, $type, $descr, $sprite)
1417+
!$line = '== '
1418+
!if ($sprite != "")
1419+
' add sprite in label line that it is more compact
1420+
!$line = $line + $getSprite($smallVersionSprite($sprite, $BOUNDARY_IMAGE_SIZE_FACTOR)) + ' '
1421+
!endif
1422+
!$line = $line + $breakLabel($label)
1423+
!if ($type != "")
1424+
!$line = $line + '\n<size:' + $TECHN_FONT_SIZE + '>[' + $type + ']</size>'
14161425
!endif
1417-
!if (type != "")
1418-
!return '== ' + $breakLabel($label) + '\n<size:' + $TECHN_FONT_SIZE + '>[' + $type + ']</size>'
1426+
!if ($descr != "")
1427+
!$line = $line + '\n\n' + $breakDescr($descr, $BOUNDARY_DESCR_MAX_CHAR_WIDTH)
14191428
!endif
1429+
!return $line
14201430
!endfunction
14211431

1422-
!unquoted procedure Boundary($alias, $label, $type="", $tags="", $link="")
1432+
!unquoted procedure Boundary($alias, $label, $type="", $tags="", $link="", $descr = "")
14231433
!$boundaryTags = $addBoundaryPostfix($tags)
1424-
' nodes $type reuses $techn definition of $boundaryTags
1434+
' boundary $type reuses $techn definition of $boundaryTags
14251435
!$type=$toElementArg($type, $boundaryTags, "ElementTagTechn", "boundary")
1426-
rectangle "$getBoundary($label, $type)" $toStereos("boundary", $boundaryTags) as $alias $getLink($link)
1436+
!$sprite=$toElementArg("", $boundaryTags, "ElementTagSprite", "boundary")
1437+
rectangle "$getBoundary($label, $type, $descr, $sprite)" $toStereos("boundary", $boundaryTags) as $alias $getLink($link)
14271438
!endprocedure
14281439

14291440
' Boundary Styling

C4_Container.puml

+4-4
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ UpdateBoundaryStyle("container", $bgColor=$CONTAINER_BOUNDARY_BG_COLOR, $fontCol
4040
$addElementTagInclReuse("external_container", $tagStereo, $bgColor, $fontColor, $borderColor, $shadowing, $shape, $sprite, $techn, $legendText, $legendSprite, $borderStyle, $borderThickness)
4141
!endprocedure
4242

43-
!unquoted procedure UpdateContainerBoundaryStyle($bgColor=$CONTAINER_BOUNDARY_BG_COLOR, $fontColor=$CONTAINER_BOUNDARY_COLOR, $borderColor=$CONTAINER_BOUNDARY_COLOR, $shadowing="", $shape="", $type="Container", $legendText="", $borderStyle="", $borderThickness="")
44-
UpdateBoundaryStyle("container", $bgColor, $fontColor, $borderColor, $shadowing, $shape, $type, $legendText, $borderStyle, $borderThickness)
43+
!unquoted procedure UpdateContainerBoundaryStyle($bgColor=$CONTAINER_BOUNDARY_BG_COLOR, $fontColor=$CONTAINER_BOUNDARY_COLOR, $borderColor=$CONTAINER_BOUNDARY_COLOR, $shadowing="", $shape="", $type="Container", $legendText="", $borderStyle="", $borderThickness="", $sprite="", $legendSprite="")
44+
UpdateBoundaryStyle("container", $bgColor, $fontColor, $borderColor, $shadowing, $shape, $type, $legendText, $borderStyle, $borderThickness, $sprite, $legendSprite)
4545
!endprocedure
4646

4747
' Layout
@@ -92,12 +92,12 @@ endlegend
9292
' Boundaries
9393
' ##################################
9494

95-
!unquoted procedure Container_Boundary($alias, $label, $tags="", $link="")
95+
!unquoted procedure Container_Boundary($alias, $label, $tags="", $link="", $descr = "")
9696
!if ($tags != "")
9797
!$allTags = $tags + '+container'
9898
!else
9999
!$allTags = 'container'
100100
!endif
101101
' $type defined via $tag style
102-
Boundary($alias, $label, "", $allTags, $link)
102+
Boundary($alias, $label, "", $allTags, $link, $descr)
103103
!endprocedure

C4_Context.puml

+8-8
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,11 @@ UpdateBoundaryStyle("enterprise", $bgColor=$ENTERPRISE_BOUNDARY_BG_COLOR, $fontC
6262
$addElementTagInclReuse("external_system", $tagStereo, $bgColor, $fontColor, $borderColor, $shadowing, $shape, $sprite, $type, $legendText, $legendSprite, $borderStyle, $borderThickness)
6363
!endprocedure
6464

65-
!unquoted procedure UpdateEnterpriseBoundaryStyle($bgColor=$ENTERPRISE_BOUNDARY_BG_COLOR, $fontColor=$ENTERPRISE_BOUNDARY_COLOR, $borderColor=$ENTERPRISE_BOUNDARY_COLOR, $shadowing="", $shape="", $type="Enterprise", $legendText="", $borderStyle="", $borderThickness="")
66-
UpdateBoundaryStyle("enterprise", $bgColor, $fontColor, $borderColor, $shadowing, $shape, $type, $legendText, $borderStyle, $borderThickness)
65+
!unquoted procedure UpdateEnterpriseBoundaryStyle($bgColor=$ENTERPRISE_BOUNDARY_BG_COLOR, $fontColor=$ENTERPRISE_BOUNDARY_COLOR, $borderColor=$ENTERPRISE_BOUNDARY_COLOR, $shadowing="", $shape="", $type="Enterprise", $legendText="", $borderStyle="", $borderThickness="", $sprite="", $legendSprite="")
66+
UpdateBoundaryStyle("enterprise", $bgColor, $fontColor, $borderColor, $shadowing, $shape, $type, $legendText, $borderStyle, $borderThickness, $sprite, $legendSprite)
6767
!endprocedure
68-
!unquoted procedure UpdateSystemBoundaryStyle($bgColor=$SYSTEM_BOUNDARY_BG_COLOR, $fontColor=$SYSTEM_BOUNDARY_COLOR, $borderColor=$SYSTEM_BOUNDARY_COLOR, $shadowing="", $shape="", $type="System", $legendText="", $borderStyle="", $borderThickness="")
69-
UpdateBoundaryStyle("system", $bgColor, $fontColor, $borderColor, $shadowing, $shape, $type, $legendText, $borderStyle, $borderThickness)
68+
!unquoted procedure UpdateSystemBoundaryStyle($bgColor=$SYSTEM_BOUNDARY_BG_COLOR, $fontColor=$SYSTEM_BOUNDARY_COLOR, $borderColor=$SYSTEM_BOUNDARY_COLOR, $shadowing="", $shape="", $type="System", $legendText="", $borderStyle="", $borderThickness="", $sprite="", $legendSprite="")
69+
UpdateBoundaryStyle("system", $bgColor, $fontColor, $borderColor, $shadowing, $shape, $type, $legendText, $borderStyle, $borderThickness, $sprite, $legendSprite)
7070
!endprocedure
7171

7272
' Sprites
@@ -413,22 +413,22 @@ rectangle "$getPerson($label, $type, $descr, $sprite)$getProps()" $toStereos("ex
413413
' Boundaries
414414
' ##################################
415415

416-
!unquoted procedure Enterprise_Boundary($alias, $label, $tags="", $link="")
416+
!unquoted procedure Enterprise_Boundary($alias, $label, $tags="", $link="", $descr = "")
417417
!if ($tags != "")
418418
!$allTags = $tags + '+enterprise'
419419
!else
420420
!$allTags = 'enterprise'
421421
!endif
422422
' $type defined via $tag style
423-
Boundary($alias, $label, "", $allTags, $link)
423+
Boundary($alias, $label, "", $allTags, $link, $descr)
424424
!endprocedure
425425

426-
!unquoted procedure System_Boundary($alias, $label, $tags="", $link="")
426+
!unquoted procedure System_Boundary($alias, $label, $tags="", $link="", $descr = "")
427427
!if ($tags != "")
428428
!$allTags = $tags + '+system'
429429
!else
430430
!$allTags = 'system'
431431
!endif
432432
' $type defined via $tag style
433-
Boundary($alias, $label, "", $allTags, $link)
433+
Boundary($alias, $label, "", $allTags, $link, $descr)
434434
!endprocedure

C4_Sequence.puml

+20-12
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
' convert it with additional command line argument -DRELATIVE_INCLUDE="relative/absolute" to use locally
1+
' convert it with additional command line argument -DRELATIVE_INCLUDE="relative/absolute" to use locally
22
!if %variable_exists("RELATIVE_INCLUDE")
33
!include ./C4_Component.puml
44
!else
@@ -192,7 +192,6 @@ sequenceDiagram {
192192
!return $breakWithNewline($text, $lineStart, $lineEnd, $REL_TECHN_MAX_CHAR_WIDTH)
193193
!endfunction
194194

195-
' description is not displayed (size too big, line breaks not supported)
196195
' properties are not displayed in sequence diagram (size would be too big)
197196
' $breakLabel() not required by participant
198197
!procedure $getParticipant($elementType, $alias, $label, $techn, $descr, $sprite, $tags, $link)
@@ -324,55 +323,64 @@ $calcDescr
324323
' alias ignored
325324
' $breakLabel() not required by participant
326325

327-
!unquoted procedure Boundary($alias, $label, $type="", $tags="", $link="")
326+
!unquoted procedure Boundary($alias, $label, $type="", $tags="", $link="", $descr = "")
328327
!$boundaryTags = $addBoundaryPostfix($tags)
329-
' nodes $type reuses $techn definition of $boundaryTags
328+
' boundary $type reuses $techn definition of $boundaryTags
330329
!$type=$toElementArg($type, $boundaryTags, "ElementTagTechn", "boundary")
330+
!$sprite=$toElementArg("", $boundaryTags, "ElementTagSprite", "boundary")
331+
!$labelSprite=""
332+
!if ($sprite != "")
333+
' add sprite in label line that it is more compact
334+
!$labelSprite = $getSprite($smallVersionSprite($sprite, $BOUNDARY_IMAGE_SIZE_FACTOR)) + ' '
335+
!endif
331336
!if ($link != "")
332337
!$usedNewLine = ']]\n== [[' + $link + ' '
333-
!$labelType = '== [[' + $link + ' ' + $breakText($label, $usedNewLine) + ']]'
338+
!$labelType = '== [[' + $link + ' ' + $labelSprite + $breakText($label, $usedNewLine) + ']]'
334339
!else
335340
!$usedNewLine = '\n== '
336-
!$labelType = $breakText($label, $usedNewLine)
341+
!$labelType = $labelSprite + $breakText($label, $usedNewLine)
337342
!endif
338343
!if (type != "")
339344
!$labelType = $labelType + '\n<size:' + $TECHN_FONT_SIZE + '>[' + $type + ']</size>'
340345
!endif
346+
!if ($display_element_description == %true() && $descr != "")
347+
!$labelType = $labelType + '\n\n' + $breakDescr($descr, $BOUNDARY_DESCR_MAX_CHAR_WIDTH)
348+
!endif
341349
box "$labelType" $toStereos("boundary", $boundaryTags)
342350
!endprocedure
343351

344352
!procedure Boundary_End()
345353
end box
346354
!endprocedure
347355

348-
!unquoted procedure Enterprise_Boundary($alias, $label, $tags="", $link="")
356+
!unquoted procedure Enterprise_Boundary($alias, $label, $tags="", $link="", $descr = "")
349357
!if ($tags != "")
350358
!$allTags = $tags + '+enterprise'
351359
!else
352360
!$allTags = 'enterprise'
353361
!endif
354362
' $type defined via $tag style
355-
Boundary($alias, $label, "", $allTags, $link)
363+
Boundary($alias, $label, "", $allTags, $link, $descr)
356364
!endprocedure
357365

358-
!unquoted procedure System_Boundary($alias, $label, $tags="", $link="")
366+
!unquoted procedure System_Boundary($alias, $label, $tags="", $link="", $descr = "")
359367
!if ($tags != "")
360368
!$allTags = $tags + '+system'
361369
!else
362370
!$allTags = 'system'
363371
!endif
364372
' $type defined via $tag style
365-
Boundary($alias, $label, "", $allTags, $link)
373+
Boundary($alias, $label, "", $allTags, $link, $descr)
366374
!endprocedure
367375

368-
!unquoted procedure Container_Boundary($alias, $label, $tags="", $link="")
376+
!unquoted procedure Container_Boundary($alias, $label, $tags="", $link="", $descr = "")
369377
!if ($tags != "")
370378
!$allTags = $tags + '+container'
371379
!else
372380
!$allTags = 'container'
373381
!endif
374382
' $type defined via $tag style
375-
Boundary($alias, $label, "", $allTags, $link)
383+
Boundary($alias, $label, "", $allTags, $link, $descr)
376384
!endprocedure
377385

378386
' Relationship (redefinition)

README.md

+9-9
Original file line numberDiff line numberDiff line change
@@ -255,9 +255,9 @@ SHOW_LEGEND()
255255
- `System_Ext(alias, label, ?descr, ?sprite, ?tags, ?link, ?type, ?baseShape)`
256256
- `SystemDb_Ext(alias, label, ?descr, ?sprite, ?tags, ?link, ?type)`
257257
- `SystemQueue_Ext(alias, label, ?descr, ?sprite, ?tags, ?link, ?type)`
258-
- `Boundary(alias, label, ?type, ?tags, ?link)`
259-
- `Enterprise_Boundary(alias, label, ?tags, ?link)`
260-
- `System_Boundary(alias, label, ?tags, ?link)`
258+
- `Boundary(alias, label, ?type, ?tags, ?link, ?descr)`
259+
- `Enterprise_Boundary(alias, label, ?tags, ?link, ?descr)`
260+
- `System_Boundary(alias, label, ?tags, ?link, ?descr)`
261261
- Sprites:
262262
- `person`
263263
- `person2`
@@ -276,7 +276,7 @@ SHOW_LEGEND()
276276
- `Container_Ext(alias, label, ?techn, ?descr, ?sprite, ?tags, ?link, ?baseShape)`
277277
- `ContainerDb_Ext(alias, label, ?techn, ?descr, ?sprite, ?tags, ?link)`
278278
- `ContainerQueue_Ext(alias, label, ?techn, ?descr, ?sprite, ?tags, ?link)`
279-
- `Container_Boundary(alias, label, ?tags, ?link)`
279+
- `Container_Boundary(alias, label, ?tags, ?link, ?descr)`
280280

281281
### Component diagram
282282

@@ -614,13 +614,13 @@ Additional tags/stereotypes can be added to the existing element stereotypes (co
614614
Introduces a new element tag. The styles of the tagged elements are updated and the tag is displayed in the calculated legend.
615615
- `AddRelTag(tagStereo, ?textColor, ?lineColor, ?lineStyle, ?sprite, ?techn, ?legendText, ?legendSprite, ?lineThickness)`:
616616
Introduces a new Relationship tag. The styles of the tagged relationships are updated and the tag is displayed in the calculated legend.
617-
- `AddBoundaryTag(tagStereo, ?bgColor, ?fontColor, ?borderColor, ?shadowing, ?shape, ?type, ?legendText, ?borderStyle, ?borderThickness, ?borderStyle, ?borderThickness)`:
617+
- `AddBoundaryTag(tagStereo, ?bgColor, ?fontColor, ?borderColor, ?shadowing, ?shape, ?type, ?legendText, ?borderStyle, ?borderThickness, ?borderStyle, ?borderThickness, ?sprite, ?legendSprite)`:
618618
Introduces a new Boundary tag. The styles of the tagged boundaries are updated and the tag is displayed in the calculated legend.
619619
- `UpdateElementStyle(elementName, ?bgColor, ?fontColor, ?borderColor, ?shadowing, ?shape, ?sprite, ?techn, ?legendText, ?legendSprite, ?borderStyle, ?borderThickness)`:
620620
This call updates the default style of the elements (component, ...) and creates no additional legend entry.
621621
- `UpdateRelStyle(textColor, lineColor)`:
622622
This call updates the default relationship colors and creates no additional legend entry.
623-
- `UpdateBoundaryStyle(?elementName, ?bgColor, ?fontColor, ?borderColor, ?shadowing, ?shape, ?type, ?legendText, ?borderStyle, ?borderThickness)`:
623+
- `UpdateBoundaryStyle(?elementName, ?bgColor, ?fontColor, ?borderColor, ?shadowing, ?shape, ?type, ?legendText, ?borderStyle, ?borderThickness, ?sprite, ?legendSprite)`:
624624
This call updates the default style of the existing boundaries and creates no additional legend entry.
625625
If the element name is "" then it updates generic, enterprise, system and container boundary style in on call.
626626
- `RoundedBoxShape()`: This call returns the name of the rounded box shape and can be used as ?shape argument.
@@ -664,9 +664,9 @@ Following calls introduces new element tags with element specific default colors
664664

665665
Like the element specific tag definitions exist boundary specific calls with their default colors **and type**:
666666

667-
- `UpdateContainerBoundaryStyle(?bgColor, ?fontColor, ?borderColor, ?shadowing, ?shape, ?type, ?legendText, ?borderStyle, ?borderThickness)`
668-
- `UpdateSystemBoundaryStyle(?bgColor, ?fontColor, ?borderColor, ?shadowing, ?shape, ?type, ?legendText, ?borderStyle, ?borderThickness)`
669-
- `UpdateEnterpriseBoundaryStyle(?bgColor, ?fontColor, ?borderColor, ?shadowing, ?shape, ?type, ?legendText, ?borderStyle, ?borderThickness)`
667+
- `UpdateContainerBoundaryStyle(?bgColor, ?fontColor, ?borderColor, ?shadowing, ?shape, ?type, ?legendText, ?borderStyle, ?borderThickness, ?sprite, ?legendSprite)`
668+
- `UpdateSystemBoundaryStyle(?bgColor, ?fontColor, ?borderColor, ?shadowing, ?shape, ?type, ?legendText, ?borderStyle, ?borderThickness, ?sprite, ?legendSprite)`
669+
- `UpdateEnterpriseBoundaryStyle(?bgColor, ?fontColor, ?borderColor, ?shadowing, ?shape, ?type, ?legendText, ?borderStyle, ?borderThickness, ?sprite, ?legendSprite)`
670670

671671
### Comments
672672

intellij/c4_live_template.zip

-1.38 KB
Binary file not shown.

0 commit comments

Comments
 (0)