Skinparam 命令

可以使用skinparam 命令更改绘图的颜色和字体。

示例

skinparam backgroundColor transparent

重要skinparam 正在逐步淘汰,请参阅问题#1464 中的评论。对于简单情况(以及向后兼容性),它仍受支持,但用户应迁移到支持更复杂情况的样式

使用

你可以(以以下方式)使用本命令:

You can use this command : * In the diagram definition, like any other commands, * In an included file, * In a configuration file, provided in the command line or the ANT task.

内嵌

为了避免重复(xxxx的部分),允许内嵌(相关的)定义。

因此,如下的定义:

To avoid repetition, it is possible to nest definition. So the following definition :

skinparam xxxxParam1 value1
skinparam xxxxParam2 value2
skinparam xxxxParam3 value3
skinparam xxxxParam4 value4

严格等价于:
is strictly equivalent to:

skinparam xxxx {
    Param1 value1
    Param2 value2
    Param3 value3
    Param4 value4
}

黑白 (Black and White)

你可以强制使用 黑白 输出格式,通过 skinparam monochrome true 命令。
You can force the use of a black&white output using skinparam monochrome true command.

🎉 Copied!

@startuml

skinparam monochrome true

actor User
participant "First Class" as A
participant "Second Class" as B
participant "Last Class" as C

User -> A: DoWork
activate A

A -> B: Create Request
activate B

B -> C: DoWork
activate C
C --> B: WorkDone
destroy C

B --> A: Request Created
deactivate B

A --> User: Done
deactivate A

@enduml

Shadowing

You can disable the shadowing using the skinparam shadowing false command.

🎉 Copied!

@startuml

left to right direction

skinparam shadowing<<no_shadow>> false
skinparam shadowing<<with_shadow>> true

actor User
(Glowing use case) <<with_shadow>> as guc
(Flat use case) <<no_shadow>> as fuc
User -- guc
User -- fuc

@enduml

颜色翻转 (Reverse colors)

可以通过 skinparam monochrome reverse 命令,强制使用 黑和白 的输出, 在黑色背景的环境下,尤其适用。

You can force the use of a black&white output using skinparam monochrome reverse command. This can be useful for black background environment.

🎉 Copied!

@startuml

skinparam monochrome reverse

actor User
participant "First Class" as A
participant "Second Class" as B
participant "Last Class" as C

User -> A: DoWork
activate A

A -> B: Create Request
activate B

B -> C: DoWork
activate C
C --> B: WorkDone
destroy C

B --> A: Request Created
deactivate B

A --> User: Done
deactivate A

@enduml

颜色 (Colors)

你可以使用 标准颜色名称 或者 RGB码

You can use either standard color name or RGB code.

🎉 Copied!

@startuml
colors
@enduml

transparent 只能用于图片背景

transparent can only be used for background of the image.

字体颜色、名称、大小 (Font color, name and size)

可以通过使用 xxxFontColor, xxxFontSize , xxxFontName 三个参数, 来修改绘图中的字体(颜色、大小、名称)。

You can change the font for the drawing using xxxFontColor, xxxFontSize and xxxFontName parameters.

示例:

skinparam classFontColor red
skinparam classFontSize 10
skinparam classFontName Aapex

也可以使用 skinparam defaultFontName 命令, 来修改默认的字体。

You can also change the default font for all fonts using skinparam defaultFontName.

Example:

skinparam defaultFontName Aapex

请注意:字体名称高度依赖于操作系统,因此不要过度使用它, 当你考虑到可移植性时。 Helvetica and Courier 应该是全平台可用。

Please note the fontname is highly system dependent, so do not over use it, if you look for portability. Helvetica and Courier should be available on all system.

还有更多的参数可用,你可以通过下面的命令打印它们:

java -jar plantuml.jar -language

A lot of parameters are available. You can list them using the following command: java -jar plantuml.jar -language

WARNING
 This translation need to be updated. 
WARNING

文本对齐 (Text Alignment)

通过left, right or center, 可以设置文本对齐.

也可以 sequenceMessageAlign 指令 赋值为 directionreverseDirection 以便让文本对齐与箭头方向一致。

Text alignment can be set up to left, right or center. You can also use direction or reverseDirection values for sequenceMessageAlign which align text depending on arrow direction.

Param name Default value Comment
sequenceMessageAlign left 用于时序图中的 消息 (message)
sequenceReferenceAlign center 在时序图中用于 ref over

🎉 Copied!

@startuml
skinparam sequenceMessageAlign center
Alice -> Bob : Hi
Alice -> Bob : This is very long
@enduml

WARNING
 This translation need to be updated. 
WARNING

Examples

🎉 Copied!

@startuml
skinparam backgroundColor #EEEBDC
skinparam handwritten true

skinparam sequence {
ArrowColor DeepSkyBlue
ActorBorderColor DeepSkyBlue
LifeLineBorderColor blue
LifeLineBackgroundColor #A9DCDF

ParticipantBorderColor DeepSkyBlue
ParticipantBackgroundColor DodgerBlue
ParticipantFontName Impact
ParticipantFontSize 17
ParticipantFontColor #A9DCDF

ActorBackgroundColor aqua
ActorFontColor DeepSkyBlue
ActorFontSize 17
ActorFontName Aapex
}

actor User
participant "First Class" as A
participant "Second Class" as B
participant "Last Class" as C

User -> A: DoWork
activate A

A -> B: Create Request
activate B

B -> C: DoWork
activate C
C --> B: WorkDone
destroy C

B --> A: Request Created
deactivate B

A --> User: Done
deactivate A
@enduml

🎉 Copied!

@startuml
skinparam handwritten true

skinparam actor {
BorderColor black
FontName Courier
        BackgroundColor<< Human >> Gold
}

skinparam usecase {
BackgroundColor DarkSeaGreen
BorderColor DarkSlateGray

BackgroundColor<< Main >> YellowGreen
BorderColor<< Main >> YellowGreen

ArrowColor Olive
}

User << Human >>
:Main Database: as MySql << Application >>
(Start) << One Shot >>
(Use the application) as (Use) << Main >>

User -> (Start)
User --> (Use)

MySql --> (Use)
@enduml

🎉 Copied!

@startuml
skinparam roundcorner 20
skinparam class {
BackgroundColor PaleGreen
ArrowColor SeaGreen
BorderColor SpringGreen
}
skinparam stereotypeCBackgroundColor YellowGreen

Class01 "1" *-- "many" Class02 : contains

Class03 o-- Class04 : aggregation
@enduml

🎉 Copied!

@startuml
skinparam interface {
  backgroundColor RosyBrown
  borderColor orange
}

skinparam component {
  FontSize 13
  BackgroundColor<<Apache>> LightCoral
  BorderColor<<Apache>> #FF6655
  FontName Courier
  BorderColor black
  BackgroundColor gold
  ArrowFontName Impact
  ArrowColor #FF6655
  ArrowFontColor #777777
}

() "Data Access" as DA
[Web Server] << Apache >>

DA - [First Component]
[First Component] ..> () HTTP : use
HTTP - [Web Server]
@enduml

🎉 Copied!

@startuml
[AA] <<static lib>>
[BB] <<shared lib>>
[CC] <<static lib>>

node node1
node node2 <<shared node>>
database Production

skinparam component {
    backgroundColor<<static lib>> DarkKhaki
    backgroundColor<<shared lib>> Green
}

skinparam node {
borderColor Green
backgroundColor Yellow
backgroundColor<<shared node>> Magenta
}
skinparam databaseBackgroundColor Aqua
@enduml

所有 skinparam 参数列表

您可以在命令行中使用-language ,也可以使用 .NET Framework 生成包含所有 skinparam 参数列表的 "图表":
  • help skinparams
  • skinparameters

命令行: -language 命令

由于文档并不总是最新的,您可以使用此命令获得完整的参数列表:

java -jar plantuml.jar -language

命令行:help skinparams

从该页面(该命令的代码)可以得到以下结果:CommandHelpSkinparam.java

🎉 Copied!

@startuml
help skinparams
@enduml

命令:皮肤参数

🎉 Copied!

@startuml
skinparameters 
@enduml

Ashley's PlantUML Doc

上的所有皮肤参数您还可以在以下页面查看每个 skinparam 参数及其显示的结果 All Skin ParametersAshley's PlantUML Doc


Privacy Policy      Advertise