How can I align the text of components?

0 votes
asked Jan 23, 2021 in Question / help by kirchsth (4,960 points)

The text of "grouping" components can be aligned \r\l\n.
But how can I align the text of "normal" component?

@startuml
rectangle "RIGHT Group\rRIGHT RIGHT RIGHT RIGHT\rRIGHT RIGHT" as supR {
  rectangle "LEFT Group\lLEFT LEFT LEFT LEFT LEFT\lLEFT LEFT" as supL {
    rectangle "CENTER Group\nCENTER CENTER CENTER CENTER\nCENTER CENTER" as supC {
      rectangle "RIGHT Component\rRIGHT RIGHT RIGHT RIGHT\rRIGHT RIGHT" as subR   
      rectangle "LEFT Component\lLEFT LEFT LEFT LEFT LEFT\lLEFT LEFT" as subL   
      rectangle "CENTER Component\nCENTER CENTER CENTER CENTER\nCENTER CENTER" as subC   
    }
  }
}
@enduml

thank you and best regards
Helmut

commented Jan 23, 2021 by kirchsth (4,960 points)

Hi Th,

your hint with skinparam is not working (see below) therefore I thought it could simpler with the different line breaks

Regards Helmut

@startuml
skinparam defaultTextAlignment<<right>> right
skinparam defaultTextAlignment<<left>> left
skinparam defaultTextAlignment<<center>> center

skinparam componentDefaultTextAlignment<<right>> right
skinparam componentDefaultTextAlignment<<left>> left
skinparam componentDefaultTextAlignment<<center>> center

skinparam componentTextAlignment<<right>> right
skinparam componentTextAlignment<<left>> left
skinparam componentTextAlignment<<center>> center

skinparam rectanangleDefaultTextAlignment<<right>> right
skinparam rectanangleDefaultTextAlignment<<left>> left
skinparam rectanangleDefaultTextAlignment<<center>> center

skinparam rectangleTextAlignment<<right>> right
skinparam rectangleTextAlignment<<left>> left
skinparam rectangleTextAlignment<<center>> center


rectangle "RIGHT Group\rRIGHT RIGHT RIGHT RIGHT\rRIGHT RIGHT" as supR {
  rectangle "LEFT Group\lLEFT LEFT LEFT LEFT LEFT\lLEFT LEFT" as supL {
    rectangle "CENTER Group\nCENTER CENTER CENTER CENTER\nCENTER CENTER"  as supC {
      rectangle "RIGHT Component\rRIGHT RIGHT RIGHT RIGHT\rRIGHT RIGHT" <<right>> as subR   
      rectangle "LEFT Component\lLEFT LEFT LEFT LEFT LEFT\lLEFT LEFT" <<left>> as subL   
      rectangle "CENTER Component\nCENTER CENTER CENTER CENTER\nCENTER CENTER" <<center>> as subC   
    }
  }
}
@enduml

commented Jan 25, 2021 by The-Lu (64,340 points)

Hello K.,

your hint with skinparam is not working (see below)

It is normal.
This is the reason of my comment:

See similar requests here:

There are request or wanted feature: not an answers.

But with that, and 'defaultTextAlignment' global parameter, we can answer with a workaround, using sub-diagram.

I will post a possible workaround soon.

Regards,
Th.

2 Answers

0 votes
answered Jan 24, 2021 by Martin (8,360 points)
edited Jan 24, 2021 by Martin

I'm  not really suggesting this as a serious answer.  But you could do it like this:

(click diagram for online server)

commented Jan 24, 2021 by kirchsth (4,960 points)

Thank you, I like it that I have a sample of low level formats into PlantUml.
But it fear your solution is too low level. I want to combine it with tables, sprites and skinparam based colors, ...  like in .

I tried it with tables and it was not working. And I assume colors and sprites are not working too
BR Helmut

commented Jan 24, 2021 by Martin (8,360 points)
edited Jan 24, 2021 by Martin

Yes, sorry, too low-level.  I'm bypassing Plantuml's node layout and using the Graphviz one instead.

I mean Graphviz can do html style nodes containing colours, tables, images, etc (see my answer to this question).  But it is not nearly as easy to use, which is part of the reason for Plantuml's existence in the first place.

I've no real solution for you.  Your post is really a 'wanted feature'.  I'm not sure why Plantuml has coded \r & \l to work in some text areas and not others.  And in fact, before your post I had no idea they existed.

Looking for documentation on \l & \r I found: here via here

0 votes
answered Jan 25, 2021 by The-Lu (64,340 points)

Hello K.,

Awaiting management by style (I will post wanted feature later);

From my first comment and using the global parameter (because defaultTextAlignment is a global parameter... not possible to use on stereotype):

skinparam defaultTextAlignment

and sub-diagram or embedded diagram, a possible workaround will be:

@startuml
skinparam defaultTextAlignment center
rectangle "RIGHT Group\rRIGHT RIGHT RIGHT RIGHT\rRIGHT RIGHT" as supR {
  rectangle "LEFT Group\lLEFT LEFT LEFT LEFT LEFT\lLEFT LEFT" as supL {
    rectangle supC [
<b>CENTER Group
<b>CENTER CENTER CENTER CENTER
<b>CENTER CENTER
{{
skinparam defaultTextAlignment right
      rectangle "RIGHT Component\rRIGHT RIGHT RIGHT RIGHT\rRIGHT RIGHT" as subR
}}
{{
skinparam defaultTextAlignment left
      rectangle "LEFT Component\lLEFT LEFT LEFT LEFT LEFT\lLEFT LEFT" as subL   
}}
{{
skinparam defaultTextAlignment center
      rectangle "CENTER Component\nCENTER CENTER CENTER CENTER\nCENTER CENTER" as subC
}}
    ]
  }
}
@enduml


[See on PlantUML online server]

If that can help,
Regards,
Th.

commented Jan 25, 2021 by kirchsth (4,960 points)
Hello Th.
thank you. Your solution enables the tables,... but now I cannot use relations anymore.
Best regards
Helmut
commented Jan 25, 2021 by The-Lu (64,340 points)

Yes,

It is the reason to open a wanted feature... or enhance style functionality (I can open it at the end of the afternoon)

Regards,
Th.

...