Please allow adding edges to class members and methods with complex names

0 votes
asked Dec 8, 2016 in Closed feature request by anonymous

Hi! I am using PlantUML to generate simple ER diagrams, utilizing class keyword for describing entities.

Currently there is a way to link two properties or methods using class1::prop -- class2::prop syntax, but it doesn't work with complex property names that contain formatting. 

Here is an example of what I am trying to do:

hide empty methods
hide circle

skinparam linetype ortho

!define PK <size:12><&key></size><b>
!define FK <size:12><&link-intact></size><i>
!define PP <size:12><&caret-right></size>

class "<b> Some dict </b>" as d {
    PK ID        \t\t\t Integer
    PP Name          \t String
}

class "<b> Some entity </b>" as e {
    PK ID       \t\t Integer
    FK Type     \t\t Integer
    PP Some field \t JSON
}

e::Type }-- d::ID

I tried to put full property name in quotes like this:  e::"FK Type \t\t Integer" }-- d::"PK ID \t\t\t Integer", but all I get is a syntax error.

Please allow adding edges to class members and methods with complex names.

1 Answer

0 votes
answered Dec 9, 2016 by plantuml (277,020 points)
 
Best answer

This feature is under development, but we fixed several issue in the last beta. We also enhanced it so that you can use in your case.

With this beta: https://dl.dropboxusercontent.com/u/13064071/plantuml.jar

Now, the following diagram is working:

@startuml
hide empty methods
hide circle

'skinparam linetype ortho

!define PK <size:12><&key></size><b>
!define FK <size:12><&link-intact></size><i>
!define PP <size:12><&caret-right></size>

class "<b> Some dict </b>" as d {
    PK ID      \t\t Integer
    PP Name    \t String
}

class "<b> Some entity </b>" as e {
    PK ID       \t\t Integer
    FK Type     \t\t Integer
    PP Some field \t JSON
}

e::Type }-- d::ID

@enduml

Unfortunately, the skinparam linetype ortho does not work very well, and there is nothing we can really do here (all this is managed by Graphviz/Dot).

Well, there may be one solution: we could still request Graphviz/Dot to do B-splines, and then we could transform those B-splines into segment for the drawing.
Not sure that it will give some good drawing. And it needs some work.

Another thing that we can do is to enhance crowfoot drawing to only handle 0/90/180/270 angle (should be easy to do).

Does it sound good to you?

commented Dec 14, 2021 by thjungers (100 points)

This seems to work only if the desired member appears first in the class.

In this example, the arrow is expected to point to "id", but points to "id2" because it comes first in the class definition:

http://www.plantuml.com/plantuml/uml/SoWkIImgAStDuSf9JIjHACbNACfCpoXHICaiIaqkoSpFu-9ApaaiBbO8BKujKgZcKb38J35Ii5Bmz0jnTNSD0lBrzC22I6ArC3skkOcPEL1Dc7fAWIR6eqaafgGKfHONene6ijhA2gXIIrSNOgQL5LGpbqDgNWhGzG00

How could this be set up so the arrow points to "id" instead?

Alternatively, is it possible to define aliases for members and use them as endpoints for arrows? This would allow using unique names and prevent mismatches.

commented Dec 14, 2021 by plantuml (277,020 points)

Thanks for the report.

This is fixed on the online server and with last snapshot.

Alternatively, is it possible to define aliases for members and use them as endpoints for arrows? This would allow using unique names and prevent mismatches.

Actually, the main issue here is to find the right syntax to define aliases for member. It's not as simple as it might sound, so any suggestion is welcome :-)

commented Dec 15, 2021 by thjungers (100 points)

Thanks for the fast reply!

This is fixed on the online server and with last snapshot.

It does work as intended on the example :-) For my more complex diagram, the correct members are linked, but the arrows are not always attached correctly: see this example.

(Sorry for the large example; I had trouble reducing it to a MWE as the entities then move to other places and the issue disappears)

For instance, in this example, arrows from members of entity G are badly placed: the arrow from C is in front of Hs, the one from Hs is in front of Ps and the ones for L and Ps are below the entity.

Actually, the main issue here is to find the right syntax to define aliases for member. It's not as simple as it might sound, so any suggestion is welcome :-)

I was thinking of using the same syntax as aliases for entities or classes : "Class name" as CN, but I don't know if it would be compatible with the current syntax for members.

commented Dec 15, 2021 by plantuml (277,020 points)

It does work as intended on the example :-) For my more complex diagram, the correct members are linked, but the arrows are not always attached correctly: see this example.

Thanks (again) for the feedback.

This is fixed (again) in last snapshot and on the online server

Tell us if you find other issues!

commented Dec 15, 2021 by thjungers (100 points)
This works wonderfully. Thanks!
...