Search code examples
aliasgraphvizdiagramdotplantuml

Unable to display object alias as object header inside a frame or package


Using plantuml I would like to create an object with an alias, so I can manipulate the object by means of it's actual name/ID (bar and baz in my example), but its header will show the alias ("Foo"). Also, I would like to group objects in some frame or package.

Here's my sample code.

@startuml
allowmixing
skinparam backgroundcolor transparent
!theme vibrant

frame "workflow" {

  package "batch" as p {
    object bar
  }

  object "Foo" as bar {
    + x
  }

  object "Foo" as baz {
    + x
  }
}
@enduml

And this is the result:

You can see how the object that is outside the package has the expected "Foo" alias as header (instead of its name/ID baz), whereas the other object inside the "batch" package shows its bar name/ID in the header instead of the expected "Foo" alias.

How can I achieve a "Foo" header for the bar object also? Thanks.

I'm using the following configuration:

  • Picked up _JAVA_OPTIONS: -Dawt.useSystemAAFontSettings=on -Dswing.aatext=true

  • PlantUML version 1.2022.14 (Tue Dec 06 19:24:13 CET 2022) (GPL source distribution)

  • Java Runtime: OpenJDK Runtime Environment

  • JVM: OpenJDK 64-Bit Server VM

  • Default Encoding: UTF-8

  • Language: en

  • Country: GB

  • PLANTUML_LIMIT_SIZE: 4096

  • Dot version: dot - graphviz version 7.1.0 (0)

  • Installation seems OK. File generation OK


Solution

  • Aliases are used on associations, I think.

    If I define the object inside the package, I get this:

    @startuml
    allowmixing
    skinparam backgroundcolor transparent
    !theme vibrant
    
    frame "workflow" {
    
      package "batch" as p {
        object "Foo" as bar {
          + x
        }
      }
    
      object "Foo" as baz {
        + x
      }
    }
    @enduml