C4_Component.puml 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. ' convert it with additional command line argument -DRELATIVE_INCLUDE="relative/absolute" to use locally
  2. !if %variable_exists("RELATIVE_INCLUDE")
  3. !include ./C4_Container.puml
  4. !else
  5. !include https://raw.githubusercontent.com/plantuml-stdlib/C4-PlantUML/master/C4_Container.puml
  6. !endif
  7. ' Scope: A single container.
  8. ' Primary elements: Components within the container in scope.
  9. ' Supporting elements: Containers (within the software system in scope) plus people and software systems directly connected to the components.
  10. ' Intended audience: Software architects and developers.
  11. ' Colors
  12. ' ##################################
  13. !$COMPONENT_FONT_COLOR ?= "#000000"
  14. !$COMPONENT_BG_COLOR ?= "#85BBF0"
  15. !$COMPONENT_BORDER_COLOR ?= "#78A8D8"
  16. !$EXTERNAL_COMPONENT_LEGEND_TEXT ?= "external component"
  17. !$EXTERNAL_COMPONENT_FONT_COLOR ?= $COMPONENT_FONT_COLOR
  18. !$EXTERNAL_COMPONENT_BG_COLOR ?= "#CCCCCC"
  19. !$EXTERNAL_COMPONENT_BORDER_COLOR ?= "#BFBFBF"
  20. ' New C4 style automatically swaps font and background colors, but with those settings the component/node background would be black.
  21. ' Therefore the colors should be displayed unchanged (the init colors have to be swapped too).
  22. !$NEW_C4_USE_ORIGINAL_COMPONENT_COLORS ?= 1
  23. !$componentColorsSwappedAlready ?= 0
  24. !if (NEW_C4_STYLE == 1 && $NEW_C4_USE_ORIGINAL_COMPONENT_COLORS == 1 && $componentColorsSwappedAlready == 0)
  25. !$swap=$COMPONENT_BG_COLOR
  26. !$COMPONENT_BG_COLOR=$COMPONENT_FONT_COLOR
  27. !$COMPONENT_FONT_COLOR=$swap
  28. !$swap=$EXTERNAL_COMPONENT_BG_COLOR
  29. !$EXTERNAL_COMPONENT_BG_COLOR=$EXTERNAL_COMPONENT_FONT_COLOR
  30. !$EXTERNAL_COMPONENT_FONT_COLOR=$swap
  31. ' don't swap them again below if C4_... included again
  32. !$componentColorsSwappedAlready=1
  33. !endif
  34. ' Labels
  35. ' ##################################
  36. !$COMPONENT_LEGEND_TEXT ?= "component"
  37. !$EXTERNAL_COMPONENT_LEGEND_TEXT ?= "external component"
  38. ' Styling
  39. ' ##################################
  40. UpdateElementStyle("component", $COMPONENT_BG_COLOR, $COMPONENT_FONT_COLOR, $COMPONENT_BORDER_COLOR, $shape=$DEFAULT_SHAPE, $legendText="$COMPONENT_LEGEND_TEXT")
  41. UpdateElementStyle("external_component", $EXTERNAL_COMPONENT_BG_COLOR, $EXTERNAL_COMPONENT_FONT_COLOR, $EXTERNAL_COMPONENT_BORDER_COLOR, $shape=$DEFAULT_SHAPE, $legendText="$EXTERNAL_COMPONENT_LEGEND_TEXT")
  42. ' shortcuts with default colors
  43. !unquoted procedure AddComponentTag($tagStereo, $bgColor="", $fontColor="", $borderColor="", $shadowing="", $shape="", $sprite="", $techn="", $legendText="", $legendSprite="", $borderStyle="", $borderThickness="")
  44. $addElementTagInclReuse("component", $tagStereo, $bgColor, $fontColor, $borderColor, $shadowing, $shape, $sprite, $techn, $legendText, $legendSprite, $borderStyle, $borderThickness)
  45. !endprocedure
  46. !unquoted procedure AddExternalComponentTag($tagStereo, $bgColor="", $fontColor="", $borderColor="", $shadowing="", $shape="", $sprite="", $techn="", $legendText="", $legendSprite="", $borderStyle="", $borderThickness="")
  47. $addElementTagInclReuse("external_component", $tagStereo, $bgColor, $fontColor, $borderColor, $shadowing, $shape, $sprite, $techn, $legendText, $legendSprite, $borderStyle, $borderThickness)
  48. !endprocedure
  49. ' Layout
  50. ' ##################################
  51. SetDefaultLegendEntries("person\nsystem\ncontainer\ncomponent\nexternal_person\nexternal_system\nexternal_container\nexternal_component\nenterprise_boundary\nsystem_boundary\ncontainer_boundary\nboundary")
  52. !procedure LAYOUT_WITH_LEGEND()
  53. hide stereotype
  54. legend right
  55. |<color:$LEGEND_TITLE_COLOR>**Legend**</color> |
  56. |<$PERSON_BG_COLOR> person |
  57. |<$SYSTEM_BG_COLOR> system |
  58. |<$CONTAINER_BG_COLOR> container |
  59. |<$COMPONENT_BG_COLOR> component |
  60. |<$EXTERNAL_PERSON_BG_COLOR> external person |
  61. |<$EXTERNAL_SYSTEM_BG_COLOR> external system |
  62. |<$EXTERNAL_CONTAINER_BG_COLOR> external container |
  63. |<$EXTERNAL_COMPONENT_BG_COLOR> external component |
  64. endlegend
  65. !endprocedure
  66. ' Elements
  67. ' ##################################
  68. !unquoted procedure Component($alias, $label, $techn="", $descr="", $sprite="", $tags="", $link="", $baseShape="rectangle")
  69. $getElementLine($baseShape, "component", $alias, $label, $techn, $descr, $sprite, $tags, $link)
  70. !endprocedure
  71. !unquoted procedure ComponentDb($alias, $label, $techn="", $descr="", $sprite="", $tags="", $link="")
  72. $getElementLine("database", "component", $alias, $label, $techn, $descr, $sprite, $tags, $link)
  73. !endprocedure
  74. !unquoted procedure ComponentQueue($alias, $label, $techn="", $descr="", $sprite="", $tags="", $link="")
  75. $getElementLine("queue", "component", $alias, $label, $techn, $descr, $sprite, $tags, $link)
  76. !endprocedure
  77. !unquoted procedure Component_Ext($alias, $label, $techn="", $descr="", $sprite="", $tags="", $link="", $baseShape="rectangle")
  78. $getElementLine($baseShape, "external_component", $alias, $label, $techn, $descr, $sprite, $tags, $link)
  79. !endprocedure
  80. !unquoted procedure ComponentDb_Ext($alias, $label, $techn="", $descr="", $sprite="", $tags="", $link="")
  81. $getElementLine("database", "external_component", $alias, $label, $techn, $descr, $sprite, $tags, $link)
  82. !endprocedure
  83. !unquoted procedure ComponentQueue_Ext($alias, $label, $techn="", $descr="", $sprite="", $tags="", $link="")
  84. $getElementLine("queue", "external_component", $alias, $label, $techn, $descr, $sprite, $tags, $link)
  85. !endprocedure