Left align field name, right align tpye

+2 votes
asked Sep 22, 2017 in To be sorted by anonymous
In a class diagram, is it possible to have the fields aligned left but their types aligned right?

An example:

class SomeClass {

  someStringField: String

}

I would like "someStringField" left aligned but "String" to be right-aligned.

2 Answers

0 votes
answered Sep 25, 2017 by plantuml (297,300 points)

Sorry, this is not really possible.
A possible workaround (but not perfect) is:

@startuml
class SomeClass {
  someStringField:\tString
  x: \t\t\t\tString
}
@enduml


 

0 votes
answered Sep 2 by Marcelo

Hi there!

I've managed to create this behavior this way:

@startuml

' I hope this (not appropriate at all) tweak works for you.
class SomeClass {
  <#transparent,#transparent>| ""- anAttribute"" | ""String"" |
  --
  <#transparent,#transparent>| ""+ aMethod()         "" | ""String"" |
  <#transparent,#transparent>| ""+ anotherMethod()   "" | ""boolean"" |
  <#transparent,#transparent>| ""+ yetAnotherMethod()"" | ""SomeClass"" |
}

@enduml

Explanation:

- I put a table inside the class :(

- I set the border colors to be transparent

- I used ""this"" to ensure monospacing and avoid/prevent layout issues.

Its visual appeal is better than the official one, in my opinion (although not only I encourage but prefer to use the official one).

Hope that helps!

...