Organization
Group Inheritance
The majority of skin parameters will be covered in their own chapter. However, group inheritance has a very specific use for organizing class diagrams. If multiple classes point to the same class the relationship arrow can be merged with the skin parameter groupInheritance followed by a number. By changing the number we can determine the threshold for merging relationships. If the threshold is set to two any entity with two or more relationships with the same trajectory will have those relationships merged.
Example: No Group Inheritance
Example: Group Inheritance Threshold 2
Example: Group Inheritance Threshold 4
Packages
Packages are used for organizing classes in the class diagram. It is used for grouping classes together. The most basic package begins with the word "package" followed by the name of the package. Any classes belonging to the package are declared inside the body of the package. The body is defined by a set of curly braces.
Example: Package Declaration
Name
Example: Package Name
Types
The type is set immediately after the name, wrapped in a double set of less than and greater than signs. There are six package types. The default package type is a folder.
Example: Package Types
Body Color
The body_color property determines the fill color of the drawn package entity. The body_color is defined by a standard color name or hex code. Create a gradient by using two colors. If you use this property alone it must come after a hash (#) sign and touch the hash sign. If any other properties follow this place a semicolon (;) between them. No spaces are needed.
Example: Package Body Color
Line Color
The line_color property determines the color of the line that draws the box of the package. The line_color is defined by a standard color name or hex code. Create a gradient by using two colors. If you use this property alone it must come after a hash (#) sign and touch the hash sign. If any other properties follow this place a semicolon (;) between them. No spaces are needed.
Note: Line_color gradients do not perform well on packages. They only affect the line under the package name.
Example: Package Line Color
Line Style
The line_style property determines the type of line that draws the box of the class. The line_style is defined by one of the three options below. If you use this property alone it must come after a hash (#) sign and touch the hash sign. If any other properties follow this place a semicolon (;) between them. No spaces are needed.
line.dashed
line.dotted
line.bold
Example: Package Line Style
Body
The body of the package displays the classes that belong to the package. Classes that belong to the package should be written inside the body of the package. Relationships can be written inside or outside of the package body.
Example: Package Body
With All Properties
Example: Packages With All Properties
Namespaces
Namespaces are similar to packages. However, namespaces allow multiple packages to contain classes with the same name. This is not possible with packages. Relationships between classes inside of namespaces must use fully qualified names for the classes in the form of namespace_name.class_name.
Namespaces do not have as many properties as packages.
Example: Namespace Declaration
Name
Example: Namespace Name
Body Color
The body_color property determines the fill color of the drawn namespace entity. The body_color is defined by a standard color name or hex code. Create a gradient by using two colors. This property must come after a hash (#) sign and touch the hash sign.
Example: Namespace Body Color
Body
The body of the namespace displays the classes that belong to the namespace. Classes that belong to the namespace should be written inside the body of the namespace. Relationships can be written inside or outside of the namespace body.
Example: Namespace Body
With All Properties
Example: Namespace With All Properties
Automatic Namespace Creation
You can create namespaces automatically with the namespaceSeparator setting. When activating the setting pick two special characters and those will be your separator. The example below recreates the example from the namespace body property.
To turn off automatic namespace creation set the namespaceSeparator setting to "none".
Note: The namespaceSeparator must be used to identify specific classes now, instead of the default period between namespace and class.
Example: Automatic Namespace Creation
Visibility
There are three ways to affect the visibility of entities in a class diagram. PlantUML adjusts visibility from the top down. This allows you to hide a large unneeded portion of the diagram and just show what you need.
hide - hides parts of the class diagram, the parts still take up space in the diagram
show - shows a part of a class that might otherwise be hidden
remove - removes parts from the class diagram, they no longer take up space
Example: Visibility Starting Point
Use the following code as the starting point for the rest of the visibility examples.
Note: We will be changing the background color to more easily track the size of the diagram. Skin parameters will be covered in their own section.
Hiding Showing and Removing Classes
You can change the visibility of a class by following the key word with the class name. You can change the visibility of several classes at a time by replacing the class name with a stereotype.
Example: Hiding, Showing, and Removing Classes
Notice how the below code leaves space for Interface2 because it is only hidden. However the part of the diagram containing Class3 is completely removed because we removed Class3.
Hiding and Showing Parts of Classes
You can adjust visibility on parts of classes by placing their property type after the visibility keyword. The following items are adjustable. You can be specify which class to adjust if you place the name or stereotype of the class before the property type.
members - this will adjust visibility of all fields, attributes and methods
fields or attributes - this will adjust visibility of all fields and attributes
methods - this will adjust visibility of all methods
circle - this will adjust the visibility of spots in the class heads
stereotype - this will adjust the visibility of stereotypes in the class head
Example: Hiding and Showing Parts of Classes
Hiding and Removing Empty and Unlinked Entities
By adding the keywords "empty" and "@unlinked" you can hide or remove unneeded entities from the class diagram.
Example: Empty and Unlinked Entities
Positioning Classes With Hidden Relationships
Example: Class Positioned With Hidden Relationship
Page Breaks
If you need to split a diagram into multiple pages use the command "page" followed by the number of pages you want. The page number format is HxV where H is the number of pages horizontally and V is the number of pages vertically.
When the images are generated they will be created from top to bottom and then left to right. A "page 3x2" named "Diagram" will produce six images with the below names that should be placed in the below order.
Diagram
Diagram_2
Diagram_4
Diagram_1
Diagram_3
Diagram_5
Example: Page Breaks 3x2
Last updated
Was this helpful?