Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#364,#365 Add UpdateLegendTitle(newTitle) call and multilingual themes #366

Merged
merged 3 commits into from
Oct 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
################################################################################
# This .gitignore file was automatically created by Microsoft(R) Visual Studio.
################################################################################

/.idea
/.vs
/.vscode
18 changes: 14 additions & 4 deletions C4.puml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ rectangle C4VersionDetailsArea <<legendArea>> [
' Labels
' ##################################

!$BOUNDARY_LEGEND_TEXT ?= "boundary"

!$LEGEND_TITLE_TEXT ?= "Legend"
!$LEGEND_SHADOW_TEXT ?= "shadow"
!$LEGEND_NO_SHADOW_TEXT ?= "no shadow"
!$LEGEND_NO_FONT_BG_TEXT ?= "last text and back color"
Expand All @@ -68,6 +71,9 @@ rectangle C4VersionDetailsArea <<legendArea>> [
!$LEGEND_SOLID_LINE ?= "solid"

!$LEGEND_BOUNDARY ?= "boundary"
!$LEGEND_BOUNDARY_PRE_PART ?= ""
!$LEGEND_BOUNDARY_POST_PART ?= " " + $LEGEND_BOUNDARY

' ignore (boundary) transparent atm, that the legend is smaller
' !$LEGEND_BOUNDARY_TRANSPARENT_INCL_COMA ?= "transparent, "
!$LEGEND_BOUNDARY_TRANSPARENT_INCL_COMA ?= ""
Expand Down Expand Up @@ -692,13 +698,13 @@ $elementSkin
!if (%strpos($tagStereo, "boundary") >= 0)
!if ($tagStereo == "boundary")
!$isBoundary = 1
!$tagEntry = $tagEntry + " " + $LEGEND_BOUNDARY + " "
!$tagEntry = $LEGEND_BOUNDARY_PRE_PART + $tagEntry + $LEGEND_BOUNDARY_POST_PART + " "
!else
' if contains/ends with _boundary remove _boundary and add "boundary (dashed)"
!$pos = %strpos($tagStereo, "_boundary")
!if ($pos > 0)
!$isBoundary = 1
!$tagEntry = $tagEntry + " " + %substr($tagStereo, 0 ,$pos) + " " +$LEGEND_BOUNDARY + " "
!$tagEntry = $tagEntry + " " + $LEGEND_BOUNDARY_PRE_PART + %substr($tagStereo, 0 ,$pos) + $LEGEND_BOUNDARY_POST_PART + " "
!endif
!endif
!endif
Expand Down Expand Up @@ -1027,6 +1033,10 @@ UpdateElementStyle($elementName, $bgColor, $fontColor, $borderColor, $shadowing)
$elementSkin
!endprocedure

!unquoted procedure UpdateLegendTitle($newTitle)
!$LEGEND_TITLE_TEXT = $newTitle
!endprocedure

' tags/stereotypes have to be delimited with \n
!unquoted procedure SetDefaultLegendEntries($tagStereoEntries)
!$tagDefaultLegend = $tagStereoEntries
Expand Down Expand Up @@ -1234,7 +1244,7 @@ hide stereotype

!procedure $getLegendTable($detailsFormat)
!global $LEGEND_DETAILS_SIZE = $getLegendDetailsSize($detailsFormat)
<$colorWithHash(transparent),$colorWithHash(transparent)>|<color:$LEGEND_TITLE_COLOR>**Legend**</color> |
<$colorWithHash(transparent),$colorWithHash(transparent)>|<color:$LEGEND_TITLE_COLOR>**$LEGEND_TITLE_TEXT **</color> |
$showActiveLegendEntries($tagDefaultLegend)
$showActiveLegendEntries($tagCustomLegend)
!endprocedure
Expand Down Expand Up @@ -1457,7 +1467,7 @@ rectangle "$getBoundary($label, $type, $descr, $sprite)" $toStereos("boundary",
!endprocedure

' Boundary Styling
UpdateBoundaryStyle("", $bgColor=$BOUNDARY_BG_COLOR, $fontColor=$BOUNDARY_COLOR, $borderColor=$BOUNDARY_COLOR, $borderStyle=DashedLine())
UpdateBoundaryStyle("", $bgColor=$BOUNDARY_BG_COLOR, $fontColor=$BOUNDARY_COLOR, $borderColor=$BOUNDARY_COLOR, $borderStyle=DashedLine(), $legendText="$BOUNDARY_LEGEND_TEXT")

' Index
' ##################################
Expand Down
11 changes: 9 additions & 2 deletions C4_Component.puml
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,22 @@
!$COMPONENT_BG_COLOR ?= "#85BBF0"
!$COMPONENT_BORDER_COLOR ?= "#78A8D8"

!$EXTERNAL_COMPONENT_LEGEND_TEXT ?= "external component"
!$EXTERNAL_COMPONENT_FONT_COLOR ?= $COMPONENT_FONT_COLOR
!$EXTERNAL_COMPONENT_BG_COLOR ?= "#CCCCCC"
!$EXTERNAL_COMPONENT_BORDER_COLOR ?= "#BFBFBF"

' Labels
' ##################################

!$COMPONENT_LEGEND_TEXT ?= "component"
!$EXTERNAL_COMPONENT_LEGEND_TEXT ?= "external component"

' Styling
' ##################################

UpdateElementStyle("component", $COMPONENT_BG_COLOR, $COMPONENT_FONT_COLOR, $COMPONENT_BORDER_COLOR)
UpdateElementStyle("external_component", $EXTERNAL_COMPONENT_BG_COLOR, $EXTERNAL_COMPONENT_FONT_COLOR, $EXTERNAL_COMPONENT_BORDER_COLOR)
UpdateElementStyle("component", $COMPONENT_BG_COLOR, $COMPONENT_FONT_COLOR, $COMPONENT_BORDER_COLOR, $legendText="$COMPONENT_LEGEND_TEXT")
UpdateElementStyle("external_component", $EXTERNAL_COMPONENT_BG_COLOR, $EXTERNAL_COMPONENT_FONT_COLOR, $EXTERNAL_COMPONENT_BORDER_COLOR, $legendText="$EXTERNAL_COMPONENT_LEGEND_TEXT")

' shortcuts with default colors
!unquoted procedure AddComponentTag($tagStereo, $bgColor="", $fontColor="", $borderColor="", $shadowing="", $shape="", $sprite="", $techn="", $legendText="", $legendSprite="", $borderStyle="", $borderThickness="")
Expand Down
14 changes: 11 additions & 3 deletions C4_Container.puml
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,20 @@
!$EXTERNAL_CONTAINER_BG_COLOR ?= "#B3B3B3"
!$EXTERNAL_CONTAINER_BORDER_COLOR ?= "#A6A6A6"

' Labels
' ##################################

!$CONTAINER_LEGEND_TEXT ?= "container"
!$CONTAINER_BOUNDARY_TYPE ?= "container"
!$CONTAINER_BOUNDARY_LEGEND_TEXT ?= "container boundary"
!$EXTERNAL_CONTAINER_LEGEND_TEXT ?= "external container"

' Styling
' ##################################
UpdateElementStyle("container", $CONTAINER_BG_COLOR, $CONTAINER_FONT_COLOR, $CONTAINER_BORDER_COLOR)
UpdateElementStyle("external_container", $EXTERNAL_CONTAINER_BG_COLOR, $EXTERNAL_CONTAINER_FONT_COLOR, $EXTERNAL_CONTAINER_BORDER_COLOR)
UpdateElementStyle("container", $CONTAINER_BG_COLOR, $CONTAINER_FONT_COLOR, $CONTAINER_BORDER_COLOR, $legendText="$CONTAINER_LEGEND_TEXT")
UpdateElementStyle("external_container", $EXTERNAL_CONTAINER_BG_COLOR, $EXTERNAL_CONTAINER_FONT_COLOR, $EXTERNAL_CONTAINER_BORDER_COLOR, $legendText="$EXTERNAL_CONTAINER_LEGEND_TEXT")

UpdateBoundaryStyle("container", $bgColor=$CONTAINER_BOUNDARY_BG_COLOR, $fontColor=$CONTAINER_BOUNDARY_COLOR, $borderColor=$CONTAINER_BOUNDARY_COLOR, $type="Container")
UpdateBoundaryStyle("container", $bgColor=$CONTAINER_BOUNDARY_BG_COLOR, $fontColor=$CONTAINER_BOUNDARY_COLOR, $borderColor=$CONTAINER_BOUNDARY_COLOR, $type="$CONTAINER_BOUNDARY_TYPE", $legendText="$CONTAINER_BOUNDARY_LEGEND_TEXT")

' shortcuts with default colors
!unquoted procedure AddContainerTag($tagStereo, $bgColor="", $fontColor="", $borderColor="", $shadowing="", $shape="", $sprite="", $techn="", $legendText="", $legendSprite="", $borderStyle="", $borderThickness="")
Expand Down
26 changes: 20 additions & 6 deletions C4_Context.puml
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,30 @@
!$ENTERPRISE_BOUNDARY_BG_COLOR ?= $BOUNDARY_BG_COLOR
!$ENTERPRISE_BOUNDARY_BORDER_STYLE ?= $BOUNDARY_BORDER_STYLE

' Labels
' ##################################

!$PERSON_LEGEND_TEXT ?= "person"
!$EXTERNAL_PERSON_LEGEND_TEXT ?= "external person"

!$SYSTEM_LEGEND_TEXT ?= "system"
!$SYSTEM_BOUNDARY_TYPE ?= "system"
!$SYSTEM_BOUNDARY_LEGEND_TEXT ?= "system boundary"
!$EXTERNAL_SYSTEM_LEGEND_TEXT ?= "external system"

!$ENTERPRISE_BOUNDARY_TYPE ?= "enterprise"
!$ENTERPRISE_BOUNDARY_LEGEND_TEXT ?= "enterprise boundary"

' Styling
' ##################################

UpdateElementStyle("person", $PERSON_BG_COLOR, $PERSON_FONT_COLOR, $PERSON_BORDER_COLOR)
UpdateElementStyle("external_person", $EXTERNAL_PERSON_BG_COLOR, $EXTERNAL_PERSON_FONT_COLOR, $EXTERNAL_PERSON_BORDER_COLOR)
UpdateElementStyle("system", $SYSTEM_BG_COLOR, $SYSTEM_FONT_COLOR, $SYSTEM_BORDER_COLOR)
UpdateElementStyle("external_system", $EXTERNAL_SYSTEM_BG_COLOR, $EXTERNAL_SYSTEM_FONT_COLOR, $EXTERNAL_SYSTEM_BORDER_COLOR)
UpdateElementStyle("person", $PERSON_BG_COLOR, $PERSON_FONT_COLOR, $PERSON_BORDER_COLOR, $legendText="$PERSON_LEGEND_TEXT")
UpdateElementStyle("external_person", $EXTERNAL_PERSON_BG_COLOR, $EXTERNAL_PERSON_FONT_COLOR, $EXTERNAL_PERSON_BORDER_COLOR, $legendText="$EXTERNAL_PERSON_LEGEND_TEXT")
UpdateElementStyle("system", $SYSTEM_BG_COLOR, $SYSTEM_FONT_COLOR, $SYSTEM_BORDER_COLOR, $legendText="$SYSTEM_LEGEND_TEXT")
UpdateElementStyle("external_system", $EXTERNAL_SYSTEM_BG_COLOR, $EXTERNAL_SYSTEM_FONT_COLOR, $EXTERNAL_SYSTEM_BORDER_COLOR, $legendText="$EXTERNAL_SYSTEM_LEGEND_TEXT")

UpdateBoundaryStyle("system", $bgColor=$SYSTEM_BOUNDARY_BG_COLOR, $fontColor=$SYSTEM_BOUNDARY_COLOR, $borderColor=$SYSTEM_BOUNDARY_COLOR, $type="System")
UpdateBoundaryStyle("enterprise", $bgColor=$ENTERPRISE_BOUNDARY_BG_COLOR, $fontColor=$ENTERPRISE_BOUNDARY_COLOR, $borderColor=$ENTERPRISE_BOUNDARY_COLOR, $type="Enterprise")
UpdateBoundaryStyle("system", $bgColor=$SYSTEM_BOUNDARY_BG_COLOR, $fontColor=$SYSTEM_BOUNDARY_COLOR, $borderColor=$SYSTEM_BOUNDARY_COLOR, $type="$SYSTEM_BOUNDARY_TYPE", $legendText="$SYSTEM_BOUNDARY_LEGEND_TEXT")
UpdateBoundaryStyle("enterprise", $bgColor=$ENTERPRISE_BOUNDARY_BG_COLOR, $fontColor=$ENTERPRISE_BOUNDARY_COLOR, $borderColor=$ENTERPRISE_BOUNDARY_COLOR, $type="$ENTERPRISE_BOUNDARY_TYPE", $legendText="$ENTERPRISE_BOUNDARY_LEGEND_TEXT")

' shortcuts with default colors
!unquoted procedure AddPersonTag($tagStereo, $bgColor="", $fontColor="", $borderColor="", $shadowing="", $shape="", $sprite="", $legendText="", $legendSprite="", $type="", $borderStyle="", $borderThickness="")
Expand Down
7 changes: 6 additions & 1 deletion C4_Deployment.puml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@
!$NODE_BG_COLOR ?= "#FFFFFF"
!$NODE_BORDER_COLOR ?= "#A2A2A2"

' Labels
' ##################################

!$NODE_LEGEND_TEXT ?= "node"

' Styling
' ##################################

Expand All @@ -22,7 +27,7 @@
!$NODE_TYPE_MAX_CHAR_WIDTH ?= 35
!$NODE_DESCR_MAX_CHAR_WIDTH ?= 32

UpdateElementStyle("node", $bgColor=$NODE_BG_COLOR, $fontColor=$NODE_FONT_COLOR, $borderColor=$NODE_BORDER_COLOR)
UpdateElementStyle("node", $bgColor=$NODE_BG_COLOR, $fontColor=$NODE_FONT_COLOR, $borderColor=$NODE_BORDER_COLOR, $legendText="$NODE_LEGEND_TEXT")
skinparam rectangle<<node>> {
FontStyle normal
}
Expand Down
6 changes: 3 additions & 3 deletions C4_Sequence.puml
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@
!$LEGEND_DASHED_TRANSPARENT_BOUNDARY = ""
!endif
UpdateBoundaryStyle("", $bgColor=$BOUNDARY_BG_COLOR, $fontColor=$BOUNDARY_COLOR, $borderColor=$BOUNDARY_COLOR)
UpdateBoundaryStyle("enterprise", $bgColor=$ENTERPRISE_BOUNDARY_BG_COLOR, $fontColor=$ENTERPRISE_BOUNDARY_COLOR, $borderColor=$ENTERPRISE_BOUNDARY_COLOR, $type="Enterprise")
UpdateBoundaryStyle("system", $bgColor=$SYSTEM_BOUNDARY_BG_COLOR, $fontColor=$SYSTEM_BOUNDARY_COLOR, $borderColor=$SYSTEM_BOUNDARY_COLOR, $type="System")
UpdateBoundaryStyle("container", $bgColor=$CONTAINER_BOUNDARY_BG_COLOR, $fontColor=$CONTAINER_BOUNDARY_COLOR, $borderColor=$CONTAINER_BOUNDARY_COLOR, $type="Container")
UpdateBoundaryStyle("enterprise", $bgColor=$ENTERPRISE_BOUNDARY_BG_COLOR, $fontColor=$ENTERPRISE_BOUNDARY_COLOR, $borderColor=$ENTERPRISE_BOUNDARY_COLOR, $type="$ENTERPRISE_BOUNDARY_TYPE")
UpdateBoundaryStyle("system", $bgColor=$SYSTEM_BOUNDARY_BG_COLOR, $fontColor=$SYSTEM_BOUNDARY_COLOR, $borderColor=$SYSTEM_BOUNDARY_COLOR, $type="$SYSTEM_BOUNDARY_TYPE")
UpdateBoundaryStyle("container", $bgColor=$CONTAINER_BOUNDARY_BG_COLOR, $fontColor=$CONTAINER_BOUNDARY_COLOR, $borderColor=$CONTAINER_BOUNDARY_COLOR, $type="$CONTAINER_BOUNDARY_TYPE")

' Styling and Layout
' ##################################
Expand Down
2 changes: 1 addition & 1 deletion LayoutOptions.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ C4-PlantUML comes with some layout options.
- [SHOW_INDEX(?show)](#show_indexshow)
- [Optional support of additional PlantUML elements](#optional-support-of-additional-plantuml-elements)
- [List of supported PlantUML elements](#list-of-supported-plantuml-elements)
- [📄 Themes](Themes.md#themes)
- [📄 Themes (different styles and languages)](Themes.md#themes)
- samples
- [📄 C4 Model Diagrams](samples/C4CoreDiagrams.md#c4-model-diagrams)

Expand Down
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ C4-PlantUML includes macros, stereotypes, and other goodies (like VSCode Snippet
- [Background](#background)
- [License](#license)
- [📄 Layout Options](LayoutOptions.md#layout-options)
- [📄 Themes](Themes.md#themes)
- [📄 Themes (different styles and languages)](Themes.md#themes)
- samples
- [📄 C4 Model Diagrams](samples/C4CoreDiagrams.md#c4-model-diagrams)

Expand Down Expand Up @@ -654,6 +654,13 @@ Like the element specific tag definitions exist boundary specific calls with the
- `UpdateSystemBoundaryStyle(?bgColor, ?fontColor, ?borderColor, ?shadowing, ?shape, ?type, ?legendText, ?borderStyle, ?borderThickness, ?sprite, ?legendSprite)`
- `UpdateEnterpriseBoundaryStyle(?bgColor, ?fontColor, ?borderColor, ?shadowing, ?shape, ?type, ?legendText, ?borderStyle, ?borderThickness, ?sprite, ?legendSprite)`

### Define a new legend title

All the above described `Update....(..., ?legendText, ...)` calls can define a new legend text.
Only the legend title cannot be changed. Therefore, the following call is added to allow it to be changed as well:

- `UpdateLegendTitle(newTitle)`

### Comments

- `SHOW_LEGEND()` supports the customized stereotypes
Expand Down
Loading