PlantUML has some features that come from the underlying software to create diagrams. Graphviz is used by PlantUML and we can use Graphviz features in our PlantUML diagrams. For example we can align multi-line text of labels to be either center (default), left or right aligned using a Graphviz feature. When we want to text to be center aligned we simply use the new-line character \n
. If we want to have our text left aligned we use \l
instead of \n
. And to right align the text we use \r
.
In the following example we have three labels that are center, left and right aligned:
@startuml actor "Application User" as User [Mail server] as Mail <<Mail>> #ffcc66 package "Sample Application" { [Controller] <<Spring REST controllers>> [Service] <<Spring service>> } ' Label text is centered User --> Controller : Types in\ndata to\nsend a message. ' Label text is left aligned Controller --> Service : User data to\lcreate a\lnew message. ' Label text is right aligned Service --> Mail : Mail message\robject containing\rall user information. @enduml
When we run PlantUML with this diagram syntax we get the following diagram:
Written with PlantUML 1.2017.16.