André Shevantes
André Shevantes

Reputation: 449

Graphviz - is there a way to avoid long strings of text in attributes?

I am trying to draw a complete UML diagram of the concurrency-related types in Java 8 using Graphviz. When trying to plot all the 8 variations of constructors in java.lang.Thread, I will have to write a long line of text in order to input descriptions for all signatures of the constructor methods. You can see in the dot code below that the "label" attribute is getting quite long, however I am not even close to finishing the descriptions for all constructors!

        Thread [
              shape="record"
              label="{Thread | + Thread() \l+ Thread(target : Runnable) \l+ Thread(target : Runnable, name : String)}" 
]

Is there a more elegant way to do this, maybe using variables or another feature of the dot language?

Upvotes: 0

Views: 569

Answers (1)

Jens
Jens

Reputation: 2617

In the dot language you can put new lines between the quotes to avoid long lines, or you can use concatenated strings: e.g. (line break after first \l and concatenation after second)

    Thread [
          shape="record"
          label="{Thread | + Thread() \l
                + Thread(target : Runnable) \l" + 
                "+ Thread(target : Runnable, name : String)}" 
    ]

Note: tested on http://viz-js.com/

Upvotes: 1

Related Questions