Can I use UML notes (comments) notation in PlantUML according to the UML standard specification?

0 votes
asked Jan 10 in Question / help by Marcelo

Hello! Happy new year!

I searched the forum for questions about UML notes but none seems to be related to mine.

PlantUML provides the ability to include notes in UML diagrams. Besides floating notes, notes can also be connected to elements as balloons. However, the balloon style apparently is not compatible with the UML Specification.

I managed to achieve the expected format in Class Diagrams, but I can't use such format in other diagrams. Currently I'm trying to do so in activity diagrams - and I'm not succeeding at all. :)

Please keep in mind that I'm not talking about drawing notes with dashed borders, but about the connection between notes and the corresponding elements (which can't be set in PlantUML for activity diagrams and others, AFAIK).

I brought the content of UML Specification to clarify my request. Here's how UML Specification defines the visual notation:

A Comment is shown as a rectangle with the upper right corner bent (this is also known as a “note symbol”). The rectangle contains the body of the Comment. The connection to each annotatedElement is shown by a separate dashed line. The dashed line connecting the note symbol to the annotated element(s) may be suppressed if it is clear from the context, or not important in this diagram.

Sources:
- UML 2.4.1 Infrastructure, Section 9.5.1 - Comment, pages 37-38
- UML 2.4.1 Infrastructure, Section 7.2.4 - Notation, page 22

Is it already implement and I'm missing something? Otherwise, would it be possible to include this in PlantUML? Maybe using <style>?

I believe this applies to all UML diagrams.

Thanks in advance!

commented Jan 11 by kirchsth
Could be still open. I found https://github.com/plantuml/plantuml-server/issues/384 too.

1 Answer

0 votes
answered Jan 13 by Marcelo

Oh, thank you very much! This helped me solve my issue with a workaround!

I'll put my adjustments here using the provided link as a basis.

Kind regards!
 

@startuml

hide circle

skinparam class {
    AttributeIconSize 0
    BackgroundColor white
}

skinparam note {
    BackgroundColor white
    ' According to the UML Spec.
}

' All connections to notes use dashed lines

title "UML notes/comments"

' Source: adapted from https://github.com/plantuml/plantuml-server/issues/384

package workaround-for-uml-strict-compatibility {
    class a_class as "AClass" {
        - anAttribute : float
    }

    note as floating_note
        This note isn't
        connected to
        any element.
    end note

    note as note_to_element
        This note is
        connected to
        a classifier.
    end note

    /'
    Connection workaround: two hidden connections
    before and after the actual connection to
    make it point straight. One of the hidden ones
    can be removed for a non-straight connection.
    '/
    note_to_element .r[hidden]. a_class /' Layout purposes '/
    note_to_element .. a_class
    note_to_element .[hidden]. a_class /' Layout purposes '/

    class another_class as "AnotherClass"
    another_class <|-- a_class

    note as note_to_link
        This note is
        connected to
        a link.
    end note
    
    /'
    Connection workaround with an actual connection
    and a single hidden connection.
    '/
    
    note_to_link . (another_class, a_class)
    note_to_link .[hidden]. a_class /' Layout purposes '/
}
@enduml

I think the yellow background comes from older UML tools.

Here's the link with the result.

...