@startuml
[First component]
[Another component] as Comp2
component Comp3
component [Last\ncomponent] as Comp4
@enduml
Components
Components must be bracketed.
You can also use the component keyword to define a
component.
And you can define an alias, using the as
keyword.
This alias will be used later, when defining relations.
@startuml
[First component]
[Another component] as Comp2
component Comp3
component [Last\ncomponent] as Comp4
@enduml
@startuml
() "First Interface"
() "Another interface" as Interf2
interface Interf3
interface "Last\ninterface" as Interf4
@enduml
Interfaces
Interface can be defined using the () symbol (because this looks like a circle).
You can also use the interface keyword to define an interface.
And you can define an alias, using the as keyword.
This alias will be used latter, when defining relations.
We will see latter that interface definition is optional.
@startuml
() "First Interface"
() "Another interface" as Interf2
interface Interf3
interface "Last\ninterface" as Interf4
[component]
footer //Adding "component" to force diagram to be a **component diagram**//
@enduml
你可以使用
note left of , note right of ,
note top of , note bottom of
等关键字定义相对于对象位置的注释。
也可以使用关键字note单独定义注释,然后使用虚线(..)将其连接到其他对象。
@startuml
interface "Data Access" as DA
DA - [First Component]
[First Component] ..> HTTP : use
note left of HTTP : Web Service only
note right of [First Component]
A note can also
be on several lines
end note
@enduml
Using notes
You can use the
note left of , note right of ,
note top of , note bottom of
keywords to define notes related to a single object.
A note can be also define alone with the note
keywords, then linked to other objects using the .. symbol.
@startuml
interface "Data Access" as DA
DA - [First Component]
[First Component] ..> HTTP : use
note left of HTTP : Web Service only
note right of [First Component]
A note can also
be on several lines
end note
@enduml
By default, links between classes have two dashes -- and are vertically oriented.
It is possible to use horizontal link by putting a single dash (or dot) like this:
It is also possible to change arrow direction by adding left, right, up
or down keywords inside the arrow:
@startuml
[Component] -left-> left
[Component] -right-> right
[Component] -up-> up
[Component] -down-> down
@enduml
You can shorten the arrow by using only the first character of the direction (for example, -d- instead of
-down-)
or the two first characters (-do-).
Please note that you should not abuse this functionality : Graphviz gives usually good results without tweaking.
And with the left to right direction parameter:
@startuml
left to right direction
[Component] -left-> left
[Component] -right-> right
[Component] -up-> up
[Component] -down-> down
@enduml
Use UML2 notation
By default (from v1.2020.13-14), UML2 notation is used.
@startuml
interface "Data Access" as DA
DA - [First Component]
[First Component] ..> HTTP : use
@enduml
使用UML1标记符
命令skinparam componentStyle uml1 可以切换到UML1标记符。
@startuml
skinparam componentStyle uml1
interface "Data Access" as DA
DA - [First Component]
[First Component] ..> HTTP : use
@enduml
Use UML1 notation
The skinparam componentStyle uml1 command is used to switch to UML1 notation.
@startuml
skinparam componentStyle uml1
interface "Data Access" as DA
DA - [First Component]
[First Component] ..> HTTP : use
@enduml
Use rectangle notation (remove UML notation)
The skinparam componentStyle rectangle command is used to switch to rectangle notation (without any UML notation).
@startuml
skinparam componentStyle rectangle
interface "Data Access" as DA
DA - [First Component]
[First Component] ..> HTTP : use
@enduml
长描述
可以用方括号"[ ]"在连线上添加描述。
@startuml
component comp1 [
This component
has a long comment
on several lines
]
@enduml
Long description
It is possible to put description on several lines using square brackets.
@startuml
component comp1 [
This component
has a long comment
on several lines
]
@enduml
不同的颜色表示
你可以在声明一个组件时加上颜色的声明。
@startuml
component [Web Server] #Yellow
@enduml
Individual colors
You can specify a color after component definition.
@startuml
component [Web Server] #Yellow
@enduml
在定型组件中使用精灵图
你可以在定型组件中使用精灵图(sprite)。
@startuml
sprite $businessProcess [16x16/16] {
FFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFF
FFFFFFFFFF0FFFFF
FFFFFFFFFF00FFFF
FF00000000000FFF
FF000000000000FF
FF00000000000FFF
FFFFFFFFFF00FFFF
FFFFFFFFFF0FFFFF
FFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFF
}
rectangle " End to End\nbusiness process" <<$businessProcess>> {
rectangle "inner process 1" <<$businessProcess>> as src
rectangle "inner process 2" <<$businessProcess>> as tgt
src -> tgt
}
@enduml
Using Sprite in Stereotype
You can use sprites within stereotype components.
@startuml
sprite $businessProcess [16x16/16] {
FFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFF
FFFFFFFFFF0FFFFF
FFFFFFFFFF00FFFF
FF00000000000FFF
FF000000000000FF
FF00000000000FFF
FFFFFFFFFF00FFFF
FFFFFFFFFF0FFFFF
FFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFF
}
rectangle " End to End\nbusiness process" <<$businessProcess>> {
rectangle "inner process 1" <<$businessProcess>> as src
rectangle "inner process 2" <<$businessProcess>> as tgt
src -> tgt
}
@enduml