Skip to content

Commit

Permalink
plantuml-stdlib#350 Boundaries support descriptions
Browse files Browse the repository at this point in the history
- Boundary(..., ?descr)
- Enterprise_Boundary(..., ?descr)
- System_Boundary(..., ?descr)
- Container_Boundary(..., ?descr)
  • Loading branch information
kirchsth committed May 1, 2024
1 parent 8bb4a58 commit 4835b90
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 20 deletions.
13 changes: 10 additions & 3 deletions C4.puml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ rectangle C4VersionDetailsArea <<legendArea>> [
!$BOUNDARY_BORDER_STYLE ?= "dashed"
' boundary symbols written in the same line, typically only 50% of the size in element
!$BOUNDARY_IMAGE_SIZE_FACTOR ?= 0.5
!$BOUNDARY_DESCR_MAX_CHAR_WIDTH ?= 35

!$LEGEND_TITLE_COLOR ?= "#000000"
!$LEGEND_FONT_COLOR ?= "#FFFFFF"
Expand Down Expand Up @@ -926,9 +927,11 @@ $line
$defineSkinparams($tagStereo, $bgColor, $fontColor, $borderColor, $shadowing, $shape, $borderStyle, $borderThickness)
!if ($sprite!="")
%set_variable_value("$" + $tagStereo + "ElementTagSprite", $sprite)
!log "DefinedlegendSprite:" + $legendSprite
!if ($legendSprite == "")
!$legendSprite = $smallVersionSprite($sprite)
!endif
!log "CalculatedlegendSprite:" + $legendSprite
!endif
!if ($techn != "")
%set_variable_value("$" + $tagStereo + "ElementTagTechn", $techn)
Expand Down Expand Up @@ -1412,24 +1415,28 @@ $getLegendArea($alias, $hideStereotype, $details)
!return $boundaryTags
!endfunction

!function $getBoundary($sprite, $label, $type)
!function $getBoundary($label, $type, $descr, $sprite)
!$line = '== '
!if ($sprite != "")
' add sprite in label line that it is more compact
!$line = $line + $getSprite($smallVersionSprite($sprite, $BOUNDARY_IMAGE_SIZE_FACTOR)) + ' '
!endif
!$line = $line + $breakLabel($label)
!if ($type != "")
!$line = $line + '\n<size:' + $TECHN_FONT_SIZE + '>[' + $type + ']</size>'
!endif
!if ($descr != "")
!$line = $line + '\n\n' + $breakDescr($descr, $BOUNDARY_DESCR_MAX_CHAR_WIDTH)
!endif
!return $line
!endfunction

!unquoted procedure Boundary($alias, $label, $type="", $tags="", $link="")
!unquoted procedure Boundary($alias, $label, $type="", $tags="", $link="", $descr = "")
!$boundaryTags = $addBoundaryPostfix($tags)
' boundary $type reuses $techn definition of $boundaryTags
!$type=$toElementArg($type, $boundaryTags, "ElementTagTechn", "boundary")
!$sprite=$toElementArg("", $boundaryTags, "ElementTagSprite", "boundary")
rectangle "$getBoundary($sprite, $label, $type)" $toStereos("boundary", $boundaryTags) as $alias $getLink($link)
rectangle "$getBoundary($label, $type, $descr, $sprite)" $toStereos("boundary", $boundaryTags) as $alias $getLink($link)
!endprocedure

' Boundary Styling
Expand Down
4 changes: 2 additions & 2 deletions C4_Container.puml
Original file line number Diff line number Diff line change
Expand Up @@ -92,12 +92,12 @@ endlegend
' Boundaries
' ##################################

!unquoted procedure Container_Boundary($alias, $label, $tags="", $link="")
!unquoted procedure Container_Boundary($alias, $label, $tags="", $link="", $descr = "")
!if ($tags != "")
!$allTags = $tags + '+container'
!else
!$allTags = 'container'
!endif
' $type defined via $tag style
Boundary($alias, $label, "", $allTags, $link)
Boundary($alias, $label, "", $allTags, $link, $descr)
!endprocedure
8 changes: 4 additions & 4 deletions C4_Context.puml
Original file line number Diff line number Diff line change
Expand Up @@ -413,22 +413,22 @@ rectangle "$getPerson($label, $type, $descr, $sprite)$getProps()" $toStereos("ex
' Boundaries
' ##################################

!unquoted procedure Enterprise_Boundary($alias, $label, $tags="", $link="")
!unquoted procedure Enterprise_Boundary($alias, $label, $tags="", $link="", $descr = "")
!if ($tags != "")
!$allTags = $tags + '+enterprise'
!else
!$allTags = 'enterprise'
!endif
' $type defined via $tag style
Boundary($alias, $label, "", $allTags, $link)
Boundary($alias, $label, "", $allTags, $link, $descr)
!endprocedure

!unquoted procedure System_Boundary($alias, $label, $tags="", $link="")
!unquoted procedure System_Boundary($alias, $label, $tags="", $link="", $descr = "")
!if ($tags != "")
!$allTags = $tags + '+system'
!else
!$allTags = 'system'
!endif
' $type defined via $tag style
Boundary($alias, $label, "", $allTags, $link)
Boundary($alias, $label, "", $allTags, $link, $descr)
!endprocedure
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -241,9 +241,9 @@ SHOW_LEGEND()
- `System_Ext(alias, label, ?descr, ?sprite, ?tags, ?link, ?type, ?baseShape)`
- `SystemDb_Ext(alias, label, ?descr, ?sprite, ?tags, ?link, ?type)`
- `SystemQueue_Ext(alias, label, ?descr, ?sprite, ?tags, ?link, ?type)`
- `Boundary(alias, label, ?type, ?tags, ?link)`
- `Enterprise_Boundary(alias, label, ?tags, ?link)`
- `System_Boundary(alias, label, ?tags, ?link)`
- `Boundary(alias, label, ?type, ?tags, ?link, ?descr)`
- `Enterprise_Boundary(alias, label, ?tags, ?link, ?descr)`
- `System_Boundary(alias, label, ?tags, ?link, ?descr)`
- Sprites:
- `person`
- `person2`
Expand All @@ -262,7 +262,7 @@ SHOW_LEGEND()
- `Container_Ext(alias, label, ?techn, ?descr, ?sprite, ?tags, ?link, ?baseShape)`
- `ContainerDb_Ext(alias, label, ?techn, ?descr, ?sprite, ?tags, ?link)`
- `ContainerQueue_Ext(alias, label, ?techn, ?descr, ?sprite, ?tags, ?link)`
- `Container_Boundary(alias, label, ?tags, ?link)`
- `Container_Boundary(alias, label, ?tags, ?link, ?descr)`

### Component diagram

Expand Down
16 changes: 9 additions & 7 deletions percy/TestBoundaryTagSupport.puml
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,21 @@
!include https://raw.githubusercontent.com/plantuml-stdlib/C4-PlantUML/master/C4_Component.puml
!endif

UpdateBoundaryStyle($bgColor="gold", $fontColor="brown", $borderColor="brown", $sprite="person,scale=1", $legendSprite="person2,scale=0.5")
UpdateBoundaryStyle($bgColor="gold", $fontColor="brown", $borderColor="brown", $sprite="person", $legendSprite="person2,scale=0.3")
' re-set $bgColor avoids '(no back color)' in legend
UpdateSystemBoundaryStyle($bgColor="gold", $fontColor="white", $borderColor="white", $sprite=robot, $legendSprite="robot2")
UpdateSystemBoundaryStyle($bgColor="gold", $fontColor="white", $borderColor="white", $sprite=robot, $legendSprite="robot2,scale=0.3")

AddElementTag("special", $sprite="person", $legendSprite="person,scale=0.3")

AddBoundaryTag("specialSystem", $bgColor="green", $fontColor="white", $borderColor="blue", $shadowing="true", $shape = RoundedBoxShape(), $type="A SPECIAL SYSTEM BOUNDARY", $sprite="robot,scale=0.5,color=black", $legendSprite="robot2,scale=0.3,color=black")
AddBoundaryTag("existingContainersBoundary", $bgColor="red", $fontColor="white", $borderColor="white", $type="Existing CONTAINER BOUNDARY", $legendText="container boundary with existing components")
AddBoundaryTag("existingContainersBoundary", $bgColor="red", $fontColor="white", $borderColor="white", $type="Existing CONTAINER BOUNDARY", $legendText="container boundary with existing components", $sprite="robot")

System_Boundary(sb, "A System Boundary") {
}

System_Boundary(sb1, "Special System 1 Boundary", $tags="specialSystem") {
Container_Boundary(cb1, "Container Boundary\nwith tag", $tags="existingContainersBoundary") {
Component(e1, "existing 1", "xyz")
System_Boundary(sb1, "Special System 1 Boundary", $tags="specialSystem", $descr="A long description ... A long description ... A long description ... A long description") {
Container_Boundary(cb1, "Container Boundary\nwith tag", $tags="existingContainersBoundary", $descr="A long description ... A long description ... A long description ... A long description") {
Component(e1, "existing 1", "xyz", $tags="special")
Component(e2, "existing 2", "xyz")
}
Container_Boundary(cb2, "A Container Boundary") {
Expand All @@ -38,7 +40,7 @@ Boundary(anotherBoundary, "Another Boundary", $type="BOUNDARY TYPE", $tags="v1")
Component(anotherComponent, "Another Component", $techn="COMPONENT TYPE", $tags="v1", $descr="Component and boundary use different tag name spaces that both v1 tags can use different styles")
}

Boundary(aBoundary, "A Boundary") {
Boundary(aBoundary, "A Boundary", $descr="A long description\nwith concrete line breaks\nNew line\nNewLine") {
}

Lay_R(sb, sb1)
Expand Down

0 comments on commit 4835b90

Please sign in to comment.