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

Proposal: Add support for lineThickness in AddRelTag #218

Closed

Conversation

netrounds-fredrik
Copy link
Contributor

This is a proposal how to add support for specifying the line thickness in AddRelTag. It used style rather than skinparam for the tag. Not sure if this can cause some other issues, for example with older versions of PlantUML.

I tried to visualize the thickness in the legend, and it kind of works for values between 1 and 8. The line is not vertically centered for higher values though.

It also exposes the more flexible lineStyle in the new style method.

Here is an example:

@startuml
!include C4_Container.puml

AddRelTag("tag1", $lineStyle="3;15", $lineThickness=3)
AddRelTag("tag2", $lineColor="#800000", $lineStyle=DottedLine(), $lineThickness=8)

Container(a, "A")
Container(b, "B")
Container(c, "C")

Rel(a, b, " ", $tags="tag1")
Rel(b, c, " ", $tags="tag2")

SHOW_LEGEND()
@enduml

test

@kirchsth kirchsth self-requested a review March 25, 2022 07:48
@kirchsth
Copy link
Member

Hi @netrounds-fredrik,

thank you for the PR,
but with your changes the combination of different colors is not working anymore (see below, I tried it with the reduced Readme sample).

Can you reduce your changes to the thickness and avoid changes of the color definitions at all?
(Color definition was trick and I created multiple forum.plantuml.net entries for the current solution)

BR Helmut

@startuml
' independent colors not working
'!include https://raw.githubusercontent.com/netrounds-fredrik/C4-PlantUML/patch-1/C4.puml

' independent colors working
!include https://raw.githubusercontent.com/plantuml-stdlib/C4-PlantUML/master/C4.puml


UpdateRelStyle(green, green)
AddRelTag("service1", $textColor="red")
AddRelTag("service2", $lineColor="red")
AddRelTag("service1&service2", $textColor="red", $lineColor="red")


' AddRelTag("tag1", $lineStyle="3;15", $lineThickness=3)
' AddRelTag("tag2", $lineColor="#blue", $lineStyle=DottedLine(), $lineThickness=8)

AddRelTag("tag1", $lineStyle=Bold())
AddRelTag("tag2", $lineColor="#blue", $lineStyle=DottedLine())


[a]
[b]
[c]

Rel(a, b, "3-15 - thick 3 (green, green)", $tags="tag1")
Rel(b, c, ".... - thick 8 (green, blue)", $tags="tag2")

Rel_R(spaAdmin, spaAdmin2, "no style (green, green)", "https")

Rel_D(api, services, "uses service1 via this call (red, green)", $tags="service1")
Rel_D(api, services, "uses service2 via this call (green, red) ", $tags="service2")
Rel_D(services, fileStorage, "both services stores via this call (red, red)", $tags="service1&service2+service1+service2")


SHOW_LEGEND()
@enduml

current implementation

With your changes

@netrounds-fredrik
Copy link
Contributor Author

I have made a fix for UpdateRelStyle to also use <style>. The default style seems like it has to be repeated for each defineRelSkinparams, or it will be overridden.

@kirchsth
Copy link
Member

kirchsth commented Apr 3, 2022

Hi @netrounds-fredrik

I checked your implementation and I think we can use a simpler implementation which requires no default colors like below.
Additional I checked, whether we could combine skinparams and styles. And this is working too. (In special case the combination tag1+tag3 has the correct font colors blue; and tage3+tag1 is gray [first tag wins])

This means, the last Plantuml versions supports the combination of old skinparam with new styles too (and we get/got direct plantuml support if we would found some problems)

@startuml
[%version()]

skinparam arrow {
    Color red
    FontColor red
    FontSize 15
}

<style>
arrow {
    FontColor green
}
</style>


<style>
arrow {
    .tag1 {
        FontColor blue
        lineThickness 6
    }
}
</style>

<style>
arrow {
    .tag2 {
        LineColor #blue
        LineStyle 2;2
    }
}
</style>

skinparam arrow<<tag3>> {
        FontColor gray
}

[A] -> [B] : hello

[A2] -> [B2] <<tag2>> : hello

[A12] -> [B12] <<tag1>><<tag2>> : hello

[A1] -> [B1] <<tag1>> : hello

[A13] -> [B13] <<tag1>><<tag3>> : hello
[A31] -> [B31] <<tag3>><<tag1>> : hello
@enduml

But I checked it with an old PlantUML versions 2021.13 too and with this version the combination of styles and skinprams is not 100% working (both tag combinations produces the gray color font). If it is defined via skinparam it works without any problems.

Additional I know there are some style related bugfixes in PlantUML 2022.2 (the plantuml team fixed it for me) which enables the simpler handling.

Based on that I would not mix styles and skinparams in the C4-PlantUML default implementation.

I would suggest another solution: I add a new (experimental) "StyledTags.puml" files which contains style based features. And if the latest Plantuml version is used then it can be included/activated and the relationship tags with line thickness can be used.
(And in one of the next version the element tags with style support could be added too).

@netrounds-fredrik and @Potherca: What do you think?

BR Helmut

@stale
Copy link

stale bot commented Jun 10, 2022

This issue has been automatically marked as stale because it has not had activity in the past 60 days. It will be closed in seven days if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale Issue has not been active for 60 days label Jun 10, 2022
@kirchsth kirchsth closed this Jun 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stale Issue has not been active for 60 days
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants