Is it possible to determine the nest level for rectangle?

0 votes
asked May 12, 2016 in To be sorted by programatix (120 points)

Hi,

I would like to accomplish a drawing as below

Is it possible?

I tried the script below and it doesn't appear like I wanted it,

@startuml
rectangle "Lvl1Block" #orange {
 rectangle "Lvl2Block1" #yellow
 rectangle "Lvl2Block2" #green {
  rectangle "Lvl3Block1" as RootDF #black {
   rectangle "Lvl4Block1" #lightblue{
    rectangle "Lvl5Block1"
    rectangle "Lvl5Block2"
   }
   rectangle "Lvl4Block2" #lightblue
   rectangle "Lvl4Block3" #lightblue
  }
 }
}
@enduml
 

1 Answer

0 votes
answered May 12, 2016 by plantuml (182,960 points)

Well, you can have

@startuml
skinparam shadowing false
rectangle Box1 #lightblue

rectangle Box2 #lightblue {
 rectangle "<color:white>Child1" as Child1 #black
 rectangle "<color:white>Child2" as Child2 #black {
 rectangle N1 #red [
#1
]
 rectangle N2 #red [
#2
]
 }
}
@enduml

http://www.plantuml.com/plantuml/uml/XSr12W8n38NXVKuHfYTebo8kTEy5n4Mc4zioiPMsCeBCtLKKnwxS1Jx-bpA6UA5CPooUXZI5wF14KXWosqhH2UCstJGg2SxNNguCq9hvCRm3BjYjRPAKLvCFbJSx7sJG7LB1zucg5xBZdy8iXVaKxPVzSoZpW0TG6ewDcA-ObymmFm00

Is this close enough to what you are expecting ?

commented May 12, 2016 by programatix (120 points)
Thanks for the response.

However, is it possible to have

a) Box1 and Box2 to be of the same height
b) Child1 and Child2 to be of the same height
c) Box1 and Child1 to be bold
d) Reorder "#2 and #1" to "#1 and #2" in Child2.

Thanks in advance.
commented May 12, 2016 by plantuml (182,960 points)
a) and b) is not possible. We could think about adding some "min_width" and "min_height" option, but that would only be possible on final Rectangle (meaning Rectangle that does NOT contains other Rectangle). This would not been perfect through, because you would have to manually compute the value for those "min_width" and "min_height".

About c), you can use the <b> syntax

About d), the best option is to change order declaration of boxes (which is a bad solution)

The result is here:

http://www.plantuml.com/plantuml/uml/TOqn3i8m34Ltdy9gJv2C27M0dGiW1ZS9JLIJeAHLaL3lJaeHf0FRbz__pwbt_awHRfWiwJ0vt-6LE1c8HWtaEpPOxTlc41wYGagu1ApPTNPeUJG0HJ4pMJ1y0fOM5JZ4tMJTO9giF5h7UfMk4UkMIVN_H--Q_2taPx5zTChdQ3IUePPmsH3n9M8XCyml
commented May 12, 2016 by programatix (120 points)
edited May 12, 2016 by programatix
I tried using "\n" as workaround but it resulted in unaligned boxes.

http://www.plantuml.com/plantuml/uml/TOqn3i8m34Ltdy9gJv2C27M0dGi0Wvk69Af9K9AgIAXtfmK4wO2y_UVtV-gTlr6aAoPBNHYTDtWXJXgYLfcyOOtLjcrsuIvElhmAAU4IOytEsDpoe04ARMQoOFW0B3jLu10tetLPD_F0tZhkH57z3h1kcLJ_NtszoPyXFyPwxZ37KNTuX5h2UKN4buY5J30z0G00

I'm actually new to plantuml. What I'm trying to achieve here is to represent containers with their children/descendants each shown in correct level. It doesn't necessary be using "rectangle". Perhaps there is other way to represent this in plantuml?
...