Weird ordering with complex components and horizontalLineBetweenDifferentPackageAllowed

+2 votes
asked Mar 13, 2015 in Closed question / help by anonymous

Hi,

I thought I'd asked about this before, but I can't seem to find the question when searching now, so I'll try again; please forgive me if there is a duplicate:

I find that the location of components and direction of lines are not quite as expected when:

  1. Horizontal positioning is enabled via !pragma horizontalLineBetweenDifferentPackageAllowed.
  2. Complex components are used, i.e. there are components within components.
  3. A "lollipop" interface outside the "super" component lis linked to a sub component.
  4. A sub component from a different complex component connects to the interface.

Consider for instance the following:

@startuml
!pragma horizontalLineBetweenDifferentPackageAllowed

component "A System" as sys {
  database "Configuration" as aConfigDb
  database "Observations" as aDataDb
  database "Data" as aStateDb

  [Inversion] as aNetwork

  aDataDb -up-> aNetwork
  aNetwork -left-> aStateDb
  aConfigDb --> aNetwork
}

() "Spread\nconfiguration" as config
aConfigDb -left- config
() "Output\nData" as data
aStateDb -left- data

component "Another System" as sys2 {
  [Config\nReceiver] as receiver1
  [Config\nReceiver] as receiver2
  receiver1 -[hidden]- receiver2
}

receiver1 -right-( config
receiver2 -right-( data

@enduml
 

Which produces the output included below. The main question is of  course, why isn't "Another System" placed to on the left-hand-side of "A System"??


1 Answer

0 votes
answered Feb 11 by Anthony-Gaudino (7,760 points)
edited Mar 23 by Anthony-Gaudino

Please note that PlantUML is very sensitive to order of declared stuff, also the sides that nodes appear no edges declarations can have huge effects.

These one look better:

@startuml
'!pragma horizontalLineBetweenDifferentPackageAllowed

component "Another System" as sys2 {
  [Config\nReceiver] as receiver1
  [Config\nReceiver] as receiver2

  receiver1 -[hidden]- receiver2
}

() "Spread\nconfiguration" as config
() "Output\nData"          as data

receiver1 -( config
receiver2 -( data

component "A System" as sys {
  database "Configuration" as aConfigDb
  database "Observations"  as aDataDb

  aConfigDb -[hidden]r- aDataDb
 
  database "Data"          as aStateDb
  [Inversion]              as aNetwork
 
  aDataDb   --> aNetwork
  aConfigDb --> aNetwork
  aStateDb   <- aNetwork
}

config - aConfigDb
data   - aStateDb
@enduml

@startuml
!pragma horizontalLineBetweenDifferentPackageAllowed

component "A System" as sys {
  database "Configuration" as aConfigDb
  database "Observations" as aDataDb
  database "Data" as aStateDb

  [Inversion] as aNetwork

  aDataDb --> aNetwork
  aNetwork -> aStateDb
  aConfigDb --> aNetwork
}

() "Spread\nconfiguration" as config
aConfigDb - config
() "Output\nData" as data
aStateDb - data

component "Another System" as sys2 {
  [Config\nReceiver] as receiver1
  [Config\nReceiver] as receiver2
  receiver1 -[hidden]- receiver2
}

receiver1 -( config
receiver2 -( data
@enduml

Or:

@startuml

component "A System" as sys {
  database "Configuration" as aConfigDb
  database "Observations" as aDataDb
  database "Data" as aStateDb

  [Inversion] as aNetwork

  aDataDb -up-> aNetwork
  aNetwork -> aStateDb
  aConfigDb --> aNetwork
}

() "Spread\nconfiguration" as config
aConfigDb - config
() "Output\nData" as data
aStateDb - data

component "Another System" as sys2 {
  [Config\nReceiver] as receiver1
  [Config\nReceiver] as receiver2
  receiver1 -[hidden]- receiver2
}

receiver1 -( config
receiver2 -( data
@enduml

commented Mar 23 by Toralf
Yeah, those do look better. "Another system" still appears to the right of "A system", though. Is there really no way to move it to the opposite side??
commented Mar 23 by Anthony-Gaudino (7,760 points)
Updated the answer with a solution.
...