Proposed way to define fixed layout in class diagrams

0 votes
asked Feb 14 in Wanted features by Riccardo (120 points)

Hi!

First of all, thanks for this great tool.

I'm planning to substitute Astah use with PlantUML. For sequence diagrams, PlantUML is great, easy, fast to write, perfect. For Class diagrams the resulting layout is confused to present to not I.T. people.

I see that, for this diagram, PlantUML uses Graphviz that has it owns way to organize things. I tried to use [hidden] relations to setup a fixed layout, but It was without success.

Basically, I can use relations on objects (or better in  'together' groups) to make my specific layout, but then when I define relation between objects the previous good layout changes to a confused one.

This is an example (using groups and hidden relations to define the layout), with the problematic relations commented:

@startuml

hide circle
skinparam linetype ortho

together cln {
  class Client
}
together mls {
  interface MemberListener
}
together mrl {
  interface MemberRole
}
together msg {
  class Message
}

' my defined layout
mls -u[hidden]- mrl
cln -r[hidden]- mrl
mrl -d[hidden]- msg

' object real relations
Client -> MemberRole
''''''Client -|> MemberListener
''''''Client -|> MemberListener

@enduml

However, according with http://graphviz.996277.n3.nabble.com/grid-layout-tp1942p1943.html there is a way to Graphviz to ignore the relations (edge [constraint=false]; ) when it make the diagram layout. The behavior can be shown in the difference between

http://www.plantuml.com/plantuml/uml/VPAnoi9048JxVOfzWH_-lJOeQInijHG9fxd4GDn8xbA5lBjAb85DSAlXFhvYXijZydqQxYsLJTtxnushhkEH-7LnkCnF8uMo3dowTXfJxnjDcygtCPmpukyT2r-7uf__jhn3t2CUvcWDWI4m18POmy5mC1mCPms5eJ0KXdwAJ3_w2DYYe608MnbmjRC3D2iOQ7S1N1j60SrK1Yx6qunf8ig3bkzVyGG0

and

http://www.plantuml.com/plantuml/uml/VP8n2y8m48Nt-nMtEGacgoXT75nr52dHfhLGhvAaK-b_rrhbmLcywP6FRtYFP36vaBfxGqLT1VUuSTcst1E_BdQNwQcdnVjyKNa-NLk9ARXQqgPqJVJdDV7tZhchVBxYvPPtY7l4mnIrOM0O60Q6qOQ5OM5O65OR0aDW20pv51d-z35WFmKDXj2L0MSxMq2rWe9g5y3POGHGJQMW6c-4J0DHvgKO_yOJ

So, my suggestion is to make a new 'tag', like the -left- one or the -[hidden] one to enable this behavior on specific relations, so that the others relations can be the only used by Graphviz to define the layout.

Do you think that it can be possible?

Thanks again,

Riccardo

1 Answer

0 votes
answered Feb 14 by plantuml (201,280 points)

It's not that simple.

If I understand correctly, the "edge [constraint=false];" stuff applies globally on a whole subgraph.
The equivalent in PlantUML of a subgraph is a package/folder.
So we could add an option per package/folder so that this package/folder turns globally to "edge [constraint=false];"
I am note sure that it's exactly what you want.


Note that there is a "norank" option available today that may help you:

@startuml
class B extends A
class C extends A
B -[norank]- C
@enduml

I am wondering if it's not what you are looking for.

commented Feb 15 by Riccardo (120 points)
commented Feb 16 by zimchaa (1,190 points)
Hi - it's possible to get a bit closer with something like this that makes it easier to maintain:

http://liveuml.com/diagram/view/5c680e9f3fa83d1ca990c725

@startuml
''hide circle
skinparam linetype ortho
skinparam shadowing false
'skinparam MinClassWidth 70
skinparam nodesep 80
skinparam ranksep 80


interface MemberListener
interface MemberRole
interface HallService
interface Member

'' relations ''

Client                  -->              HallService
MemberListener          <|-            Client
Client          "1"     ->      "0..*"  MemberRole

HallService             <|-            Hall
MemberListener  "0..*"  -       "1"     Hall
Hall                    ---       "0..*"  Room
    
Hall            "1"     -      "0..*"  ControlledMember

MemberListener  "1"     <---             ControlledMember
MemberRole              <|---            ControlledMember
Member                  <|-            ControlledMember
Room            "1"     <-             ControlledMember
Room                    ->             Member

Member                  <|--            BotMember


@enduml
commented Feb 16 by Riccardo (120 points)
edited Feb 17 by Riccardo
Hi @zimchaa, and thanks

It is good enough.  However, let me just define 2 packages to organize such classes, and you will see that the default resulting layout is unusable http://liveuml.com/diagram/view/5c6816663fa83d1ca990c72f

little better http://liveuml.com/diagram/view/5c681a633fa83d1ca990c730

little better http://liveuml.com/diagram/view/5c68dd713fa83d1ca990c731

seq diagram: http://liveuml.com/diagram/view/5c68dda33fa83d1ca990c732

I really would be like to define the position of the objects
...