Organization
Last updated
Was this helpful?
Last updated
Was this helpful?
Packages are used for organizing objects in the object diagram. It is used for grouping objects together. The most basic package begins with the word "package" followed by the name of the package. Any objects belonging to the package are declared inside the body of the package. The body is defined by a set of curly braces.
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.
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.
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.
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
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.
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
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.
You can change the visibility of an object by following the key word with the object name. You can change the visibility of several objects at a time by replacing the object name with a stereotype.
Notice how the below code leaves space for Object2 because it is only hidden. However the part of the diagram containing Object3 is completely removed because we removed Object3.
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
fields - this will adjust visibility of all fields
stereotype - this will adjust the visibility of stereotypes in the class head
By adding the keyword "@unlinked" you can hide or remove unneeded entities from the class diagram.
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
The name is text that appears in the head of the package. The name can be a single word without quotation marks or it can be a string with quotation marks. Single word supports creole syntax for emphasis. The string method supports emphasis with creole and markup language. The string method also supports colors with markup language. You can define colors with a standard color name or hex code. See for a list of creole and markup options.
You can hide relations with the key word "hidden". In the example Object4 sticks out to the right. This makes the diagram wider than is needed. You can manually move it under Object2 by creating a relation between them and then hiding the relation.