Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Line break for components

Tags:

uml

plantuml

My PlantUML code looks like this

package "parent" {
  package "child1" {
  }

  package "child2" {
  }

  package "child3" {
  }

  //and so on...
}

The rendered diagram has all the child packages side by side and so the diagram is too wide. Is there a way to force all packages after child2 to be below (line break) the previous packages?

like image 846
onepiece Avatar asked Apr 14 '17 21:04

onepiece


People also ask

What is code for line break?

<br>: The Line Break element. The <br> HTML element produces a line break in text (carriage-return). It is useful for writing a poem or an address, where the division of lines is significant.

How do you create a line break?

Press ALT+ENTER to insert the line break.

How is a line break applied?

To do a line break in HTML, use the <br> tag. Simply place the tag wherever you want to force a line break. Since an HTML line break is an empty element, there's no closing tag.

What does it mean to add a line break?

Updated: 07/31/2022 by Computer Hope. A line break is a command or sequence of control characters that returns the cursor to the next line and does not create a new paragraph. Essentially, line breaks denote the end of one line and the start of a new one.


2 Answers

As mentioned in this answer, the simplest approach approach is to use hidden links. However, to ensure better layout and minimize the number of hidden links, use the together keyword to "group" objects. All objects in a group will maintain the same relative position set by a single link.

An expanded version of your example

package "parent" {
  together {
    package "childA2" {
    }

    package "childA1" {
    }
  }

  together {
    package "childB4" {
    }

    package "childB3" {
    }

    package "childB2" {
    }

    package "childB1" {
    }
  }


  together {
    package "childC2" {
    }

    package "childC1" {
    }
  }
  childA1 -[hidden]-> childB1
  childB1 -[hidden]-> childC1
}

would yield the following diagram.

enter image description here

like image 79
Frelling Avatar answered Oct 04 '22 15:10

Frelling


The typical approach is to add hidden edges, as described in the Help on layout section of PlantUML.

e.g.

package "parent" {
  package "child1" {
  }

  package "child2" {
  }

  package "child3" {
  }

  child1 -[hidden]-> child2
  ' you can add more space by adding more dashes
  child2 -[hidden]---> child3

}
like image 33
Peter Uhnak Avatar answered Oct 04 '22 15:10

Peter Uhnak