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

New layout call SHOW_PERSON_OUTLINE() offers "Structurizr" persons #146

Closed
kirchsth opened this issue Apr 30, 2021 · 1 comment · Fixed by #147
Closed

New layout call SHOW_PERSON_OUTLINE() offers "Structurizr" persons #146

kirchsth opened this issue Apr 30, 2021 · 1 comment · Fixed by #147
Milestone

Comments

@kirchsth
Copy link
Contributor

kirchsth commented Apr 30, 2021

PlantUML supports a (new?) "person" shape. Based on that I could introduce an new macro "SHOW_PERSON_OUTLINE()" additional to SHOW_PERSON_PORTRAIT() that we could have diagrams like below.

BR Helmut

PS.: It should be an extension to SHOW_PERSON_PORTRAIT() and not a replacement of it

@startuml
' convert it with additional command line argument -DRELATIVE_INCLUDE="." to use locally
!if %variable_exists("RELATIVE_INCLUDE")
  !include ./../C4_Deployment.puml
!else
  !include https://raw.githubusercontent.com/kirchsth/C4-PlantUML/extended/C4_Deployment.puml
!endif

skinparam person {
    StereotypeFontSize 12
    shadowing false
}

!unquoted procedure $defineSkinparams($tagStereo, $bgColor, $fontColor, $borderColor, $shadowing)
  !$tagSkin = $elementTagSkinparams("rectangle", $tagStereo, $bgColor, $fontColor, $borderColor, $shadowing)
  !$tagSkin = $tagSkin + $elementTagSkinparams("database", $tagStereo, $bgColor, $fontColor, $borderColor, $shadowing)
  !$tagSkin = $tagSkin + $elementTagSkinparams("queue", $tagStereo, $bgColor, $fontColor, $borderColor, $shadowing)
  ' actor has style awesome, therefore $fontColor is ignored and text uses $bgColor too
  !$tagSkin = $tagSkin + $elementTagSkinparams("actor", $tagStereo, $bgColor, $bgColor, $borderColor, $shadowing)
  !$tagSkin = $tagSkin + $elementTagSkinparams("person", $tagStereo, $bgColor, $fontColor, $borderColor, $shadowing)
  !if ($tagStereo == "boundary" && $bgColor!="")
    !$tagSkin = $tagSkin + "skinparam package<<boundary>>StereotypeFontColor " + $bgColor + %newline()
    !$tagSkin = $tagSkin + "skinparam rectangle<<boundary>>StereotypeFontColor " + $bgColor + %newline()
  !endif
$tagSkin
!endprocedure

' update the style of existing elements like person, ...
!unquoted procedure UpdateElementStyle($elementName, $bgColor="", $fontColor="", $borderColor="", $shadowing="")
$defineSkinparams($elementName, $bgColor, $fontColor, $borderColor, $shadowing)
  !$tagEntry = $tagLegendEntry($elementName, $bgColor, $fontColor, $borderColor, $shadowing)
%set_variable_value("$" + $elementName + "LegendEntry", $tagEntry)
!endprocedure

!unquoted procedure SHOW_PERSON_OUTLINE()
  !$defaultPersonSprite = ""
  !$portraitPerson = "outline"
!endprocedure

UpdateElementStyle("person", $PERSON_BG_COLOR, $ELEMENT_FONT_COLOR, $PERSON_BORDER_COLOR)

!unquoted procedure Person($alias, $label, $descr="", $sprite="", $tags="", $link="")
!if ($portraitPerson == "true") && ($sprite == "")
actor "$getPerson($label, $descr, $sprite)$getProps()" $toStereos("person", $tags) as $alias $getLink($link)
!elseif ($portraitPerson == "outline") && ($sprite == "")
person "$getPerson($label, $descr, $sprite)$getProps()" $toStereos("person", $tags) as $alias $getLink($link)
!else
rectangle "$getPerson($label, $descr, $sprite)$getProps()" $toStereos("person", $tags) as $alias $getLink($link)
!endif
!endprocedure

!unquoted procedure Person_Ext($alias, $label, $descr="", $sprite="", $tags="", $link="")
!if ($portraitPerson == "true") && ($sprite == "")
actor "$getPerson($label, $descr, $sprite)$getProps()" $toStereos("external_person", $tags) as $alias $getLink($link)
!elseif ($portraitPerson == "outline") && ($sprite == "")
person "$getPerson($label, $descr, $sprite)$getProps()" $toStereos("external_person", $tags) as $alias $getLink($link)
!else
rectangle "$getPerson($label, $descr, $sprite)$getProps()" $toStereos("external_person", $tags) as $alias $getLink($link)
!endif
!endprocedure

' ======================

!$COLOR_A_5 = "#7f3b08"
!$COLOR_A_1 = "#fee0b6"
!$COLOR_NEUTRAL = "#f7f7f7"
UpdateElementStyle("external_person", $bgColor=$COLOR_A_5, $fontColor=$COLOR_NEUTRAL, $borderColor=$COLOR_A_1, $shadowing="true")

' existing see https://github.com/plantuml-stdlib/C4-PlantUML/pull/141
' SHOW_PERSON_PORTRAIT()
' NEW additional !!!!!!!!!!!!!!!!!!!!!  maybe other name; or via via argument SHOW_PERSON_PORTRAIT("outline")
SHOW_PERSON_OUTLINE()
 
' default header Property, Value
AddProperty("Name", "Flash")
AddProperty("Organization", "Zootopia")
AddProperty("Tool", "Internet Explorer 7.0")
Person(personAlias, "Label", "Optional Description (with default property header)")
Person(personAlias1, "Simple")
Person(personAlias2, "Simple with sprite", $sprite="person2")
AddProperty("Name", "Flash")
AddProperty("Organization", "Zootopia")
AddProperty("Tool", "Internet Explorer 7.0")
Person_Ext(personAliasExt, "Label Ext", "Optional Description (with default property header)")
Person_Ext(personAliasExt1, "Simple Ext")
Person_Ext(personAliasExt2, "Simple Ext with sprite", $sprite="person2")

SHOW_LEGEND()
@enduml
@kirchsth
Copy link
Contributor Author

I tried it with a more realistic sample too

kirchsth added a commit to kirchsth/C4-PlantUML that referenced this issue May 1, 2021
@Potherca Potherca added this to the v2.3.0 milestone May 2, 2021
@kirchsth kirchsth changed the title New layout call SHOW_PERSON_OUTLINE() offers "Structurizr" persons New layout call SHOW_PERSON_OUTLINE() offers "Structurizr" persons; new $shape argument supports rounded-box and eight-sided shapes May 9, 2021
@kirchsth kirchsth changed the title New layout call SHOW_PERSON_OUTLINE() offers "Structurizr" persons; new $shape argument supports rounded-box and eight-sided shapes New layout call SHOW_PERSON_OUTLINE() offers "Structurizr" persons May 10, 2021
This was referenced Jul 2, 2021
Potherca added a commit that referenced this issue Jul 4, 2021
#146 New layout call SHOW_PERSON_OUTLINE() activates shape "person"; new $shape argument supports rounded-box and eight-sided shapes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
2 participants