Change arrow style through stereotypes

+1 vote
asked Oct 27, 2021 in Question / help by UGxhbnRVTUw (160 points)

Hi,

I would like to change the arrow style through stereotypes.
Is it possible ?

By "arrow style", I mean chose between plain, blod, dotted, etc...

I now it is possible with the following code, but I need stereotypes in my case.

@startuml
component a
component b

a ..> b
@enduml

What I would like :  

@startuml
skinparam ArrowStyle<<tls>> dotted

component a
component b

a --> b <<tls>>
@enduml

Regads,

PS : Same for "hidden", is it possible ?

2 Answers

0 votes
answered Oct 27, 2021 by kirchsth (4,960 points)
selected Oct 28, 2021 by UGxhbnRVTUw
 
Best answer

Hi,
I don't know if there are stereotypes, but you can change it with a ": following notation (see mix,...)" like below and hide the different formats in a function

@startuml
!unquoted function important()
!return "#line:red;line.bold;text:red :"  
!endfunction

!unquoted function notSoImportant($text)
!return "#blue;line.dotted;text:blue   : " + $text
!endfunction


class foo
foo --> bar : normal
foo --> bar1 #line:red;line.bold;text:red  : red bold
foo --> bar2 #green;line.dashed;text:green : green dashed
foo --> bar3 #blue;line.dotted;text:blue   : blue dotted

foo --> viaExtraFunction important() myText

foo --> combinedInOneFunction notSoImportant(Another text)
@enduml


If you want some more logical patterns you could use C4-PlantUML with a complete tag notation support.

BR Helmut

PS.: if no line should be displayed you can use the color `transparent`

commented Oct 28, 2021 by UGxhbnRVTUw (160 points)
Hi,

Indeed, I can switch from stereotypes to functions.
I never used it yet.

Thanks you for idea.
I'll give it a try.

Regards,
commented Oct 28, 2021 by The-Lu (64,340 points)

Hello all,

You can also just use variable, without to call function, as:

@startuml
!$important="#line:red;line.bold;text:red :"  

class foo
foo --> bar : normal

foo --> viaVariable $important myText
@enduml

See also doc. here:

If that can help,
Regards.

0 votes
answered Mar 9, 2022 by The-Lu (64,340 points)

Hello U.,

With last version, we can now use stereotype style as:

@startuml
<style>
.pls {
  LineStyle 5
  LineColor green
  FontColor blue
}
</style>

component a
component b

a ..> b : dotted
a --> b <<pls>> : stereo
@enduml

Enjoy...

...