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

#232 Legend details can be smaller or hidden #259

Merged
merged 2 commits into from
Nov 14, 2022

Conversation

kirchsth
Copy link
Contributor

@kirchsth kirchsth commented Nov 12, 2022

implementation of #232

Idea:

  • Legend text of a tag definition consists of a label and the (display) details.
  • If details are displayed with a smaller font then the whole legend gets smaller.
  • If $legendText of a tag definition contains a \n then the first part defines the label and the second part the details.
  • (the first planed idea with pictograms is discarded, I found no useful images)

Realization:

  • SHOW_LEGEND(?hideStereotype, ?details) and SHOW_FLOATING_LEGEND(?alias, ?hideStereotype, ?details) is extended with ?details:

    • $details = Small() .. default; details are displayed with a smaller size compared to the legend labels
    • $details = Normal() .. details and labels are displayed with same size
    • $details = None() .. only the labels are displayed
@startuml
' convert it with additional command line argument -DRELATIVE_INCLUDE="./.." to use locally
!if %variable_exists("RELATIVE_INCLUDE")
  !include %get_variable_value("RELATIVE_INCLUDE")/C4_Container.puml
!else
  !include https://raw.githubusercontent.com/kirchsth/C4-PlantUML/extended/C4_Container.puml
!endif
' $legendText with \n defines the label and details of the legend entry ("backend container" is label, "eight sided shape" is details) 
AddElementTag("backendContainer", $fontColor=$ELEMENT_FONT_COLOR, $bgColor="#335DA5", $shape=EightSidedShape(), $legendText="backend container\neight sided shape")
' $legendText without \n defines only a label 
AddRelTag("async", $textColor=$ARROW_COLOR, $lineColor=$ARROW_COLOR, $lineStyle=DashedLine(), $legendText="async call")
' if no $legendText defined, $tag is automatically the label and all additional displayed properties are the details
AddRelTag("sync/async", $textColor=$ARROW_COLOR, $lineColor=$ARROW_COLOR, $lineStyle=DottedLine())

System_Boundary(c1, "Internet Banking") {
    Container(mobile_app, "Mobile App", "C#, Xamarin", "Provides a limited subset of the Internet banking functionality to customers via their mobile device")
    Container(backend_api, "API Application", "Java, Docker Container", "Provides Internet banking functionality via API", $tags="backendContainer")
}
System_Ext(banking_system, "Mainframe Banking System", "Stores all of the core banking information about customers, accounts, transactions, etc.")

Rel(mobile_app, backend_api, "Uses", "async, JSON/HTTPS", $tags="async")
Rel_Neighbor(backend_api, banking_system, "Uses", "sync/async, XML/HTTPS", $tags="sync/async")

SHOW_LEGEND()
@enduml

SHOW_LEGEND Sample, $legendText defines legend details

Legend details can be deactivated via SHOW_LEGEND($details=None())

@startuml
' convert it with additional command line argument -DRELATIVE_INCLUDE="./.." to use locally
!if %variable_exists("RELATIVE_INCLUDE")
  !include %get_variable_value("RELATIVE_INCLUDE")/C4_Container.puml
!else
  !include https://raw.githubusercontent.com/kirchsth/C4-PlantUML/extended/C4_Container.puml
!endif
' $legendText with \n defines the label and details of the legend entry ("backend container" is label, "eight sided shape" is details) 
AddElementTag("backendContainer", $fontColor=$ELEMENT_FONT_COLOR, $bgColor="#335DA5", $shape=EightSidedShape(), $legendText="backend container\neight sided shape")
' $legendText without \n defines only a label 
AddRelTag("async", $textColor=$ARROW_COLOR, $lineColor=$ARROW_COLOR, $lineStyle=DashedLine(), $legendText="async call")
' if no $legendText defined, $tag is automatically the label and all additional displayed properties are the details
AddRelTag("sync/async", $textColor=$ARROW_COLOR, $lineColor=$ARROW_COLOR, $lineStyle=DottedLine())

System_Boundary(c1, "Internet Banking") {
    Container(mobile_app, "Mobile App", "C#, Xamarin", "Provides a limited subset of the Internet banking functionality to customers via their mobile device")
    Container(backend_api, "API Application", "Java, Docker Container", "Provides Internet banking functionality via API", $tags="backendContainer")
}
System_Ext(banking_system, "Mainframe Banking System", "Stores all of the core banking information about customers, accounts, transactions, etc.")

Rel(mobile_app, backend_api, "Uses", "async, JSON/HTTPS", $tags="async")
Rel_Neighbor(backend_api, banking_system, "Uses", "sync/async, XML/HTTPS", $tags="sync/async")

SHOW_LEGEND($details=None())
@enduml

SHOW_LEGEND Sample, hide details with $details=None()

It can be tested with my extended branch

BR Helmut

PS.: I changed the "no" in the color related details to "last", maybe this is better (we uses "no" in "no shadow" too and there it means that an exiting shadow will be explicit deactivate; but in the context of color it remains only unchanged)

…or None(); defined via SHOW_LEGEND($details=...)

- if $legendText contains a  `\n` then the part before is the label and the part behind the details
@kirchsth kirchsth added this to the v2.5.0 milestone Nov 12, 2022
@kirchsth kirchsth mentioned this pull request Nov 12, 2022
7 tasks
Copy link
Member

@Potherca Potherca left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work! Looks good.

@kirchsth kirchsth merged commit f1aa60f into plantuml-stdlib:master Nov 14, 2022
@kirchsth kirchsth deleted the feature/232_LegendLayout branch November 14, 2022 20:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Should we reduce legend text width with line, border style symbols (instead of text)?
2 participants