UML Diagram
To create a general UML diagram, one uses the umlDiagram diagram function:
umlDiagram {
// define elements
}The general UML diagram provides the elements of all other UML diagram types except the sequence diagram, so it can be used for diagrams which do not fit exactly one diagram type, or which mix several of them. It is also the diagram type to reach for when a deployment diagram is combined with the elements of another type - deploying a component onto a node needs nothing but both elements in one diagram. Each element behaves exactly like in the diagram type it belongs to, therefore this page only gives one example per element and links to the diagram type documenting it in detail.
TIP
If your diagram is a class, component, activity or deployment diagram, prefer the respective diagram type: it offers the same elements, but its toolbox and its generated edits are tailored to that diagram type. Sequence diagrams are not part of the general UML diagram at all, as their participants require the sequence diagram specific layouting - use sequenceDiagram for them.
Classifiers
Classifiers are the box-shaped elements with a title and optional compartments. They all register themselves in the diagram scope under their name, so they can be referenced later on.
class
Creates a class, see UML Class Diagram:
interface
Creates an interface, a class with the «interface» keyword, see UML Class Diagram:
enum
Creates an enumeration, see UML Class Diagram:
component
Creates a component, see UML Component Diagram:
instance
Creates an instance, a classifier with an underlined title and optional values, see UML Sequence Diagram:
node, device and executionEnvironment
Create the deployment targets, rendered as a 3D box, see UML Deployment Diagram. device and executionEnvironment are nodes carrying the respective keyword. Naming a type as the second argument turns any of them into an instance specification:
artifact
Creates an artifact, see UML Deployment Diagram:
deploymentSpec
Creates a deployment specification, see UML Deployment Diagram:
useCase
Creates a use case, rendered as an ellipse, see UML Use Case Diagram:
subject
Creates the subject, the system boundary of a use case diagram, see UML Use Case Diagram:
actor
Creates an actor, see UML Sequence Diagram:
systemActor
Creates an actor in the rectangle notation, used for non-human actors, see UML Use Case Diagram:
package
Creates a package, see UML Class Diagram:
comment
Creates a comment, see UML Class Diagram:
Classifier content
The content of a classifier is defined by the function passed to it, and works the same for all classifiers.
Properties and methods
Properties and methods are declared in a visibility block, one of public, private, protected, package and default, see UML Class Diagram:
section
Adds an additional compartment with plain text entries, see UML Class Diagram:
entries
Adds the entries of an enumeration, see UML Class Diagram:
extensionPoints
Adds the extension points of a use case, see UML Use Case Diagram:
values
Adds the values of an instance, see UML Sequence Diagram:
Nesting
Classifiers can contain other classifiers, which are then displayed inside of them, see UML Class Diagram:
port
Adds a port, a connection point on the outline of a classifier, see UML Component Diagram:
provides and requires
Add a provided or required interface to a classifier or one of its ports, see UML Component Diagram:
Activity nodes
In contrast to classifiers, activity nodes have no compartments: each node is a single shape with its label centered inside.
action
Creates an action, the primary node of an activity diagram, optionally with pins, see UML Activity Diagram:
object and signalObject
Create an object node, respectively an object node for a signal, see UML Activity Diagram:
decision and merge
Create a decision, respectively a merge node, see UML Activity Diagram:
fork and join
Create a fork, respectively a join node, see UML Activity Diagram:
start, stop and end
Create the nodes at which a flow begins and terminates, see UML Activity Diagram:
sendSignal and acceptEvent
Create the signal nodes, see UML Activity Diagram:
connector
Creates a connector, used in pairs to split a long flow into multiple parts, see UML Activity Diagram:
Connections
All connection operators of the class diagram are available, see UML Class Diagram:
The --> operator is also used for the control and object flows of an activity, see UML Activity Diagram, and dependsOn connects a required to a provided interface, see UML Component Diagram.
The «include» and «extend» of a use case diagram are the dashed arrow ..> with a keyword label, see UML Use Case Diagram, and extends is the generalization between two actors or two use cases:
The stereotyped dependencies of a deployment diagram are the dashed arrow ..> with a keyword label, see UML Deployment Diagram:
Config properties
The following config properties are available for general UML diagrams:
| Variable | Meaning | Default value (in pixels) | Comment |
|---|---|---|---|
abstractAsProperty | Whether to show { abstract } after the name of abstract classes | false | - |
providesDistance | Default distance of provided interfaces to the classifier outline | 100 | - |
requiresDistance | Default distance of required interfaces to the classifier outline | 100 | - |
showArtifactIcon | Whether to show the artifact symbol | true | - |
showArtifactKeyword | Whether to show the artifact keyword | true | - |
showComponentKeyword | Whether to show the component keyword | true | - |
showComponentSymbol | Whether to show the component symbol | true | - |
showDeviceKeyword | Whether to show the device keyword | true | - |
showExecutionEnvironmentKeyword | Whether to show the executionEnvironment keyword | true | - |
Styling
The following style variables are used by the general UML diagram elements:
| Variable | Meaning | Default value (in pixels) |
|---|---|---|
artifactIconSize | Width of the artifact symbol in the title | 20 |
componentIconSize | Size of the component symbol in the title | 25 |
providedInterfaceSize | Diameter of the circle of a provided interface | 30 |
requiredInterfaceSize | Size of the socket of a required interface | 45 |
barLength | Length of a fork / join bar | 200 |
barThickness | Thickness of a fork / join bar | 10 |
terminalNodeSize | Diameter of the start, stop and end nodes | 30 |
pinSize | Edge length of a pin | 20 |
pinLabelDistance | Distance of a pin label to the pin | 8 |
Example
The following example mixes the elements of several UML diagram types in one diagram: the Place order use case a customer performs, the Shop component realizing it, the classes it operates on, and the activity it performs.