如何为PlantUML类图中的各类别单独设置样式?
PlantUML中为单个类别单独设置样式
当然可以为各类别单独设置样式,无需全局统一应用。你只需要在<style>块中,把原来的通用class选择器替换为具体的类别名称(比如interface、enum、annotation等),就能让样式只对目标类别生效。
示例1:仅调整Interface的样式
@startuml <style> classDiagram { interface { FontColor darkgreen BackgroundColor lightgreen header { FontSize 18 FontStyle italic FontColor green } } } </style> abstract abstract abstract class "abstract class" annotation annotation class class class class_stereo <<stereotype>> entity entity enum enum exception exception interface interface metaclass metaclass protocol protocol stereotype stereotype struct struct @enduml
示例2:为多个类别分别设置不同样式
如果需要同时给多个类别单独配置,直接在classDiagram下添加多个类别选择器即可:
@startuml <style> classDiagram { interface { FontColor darkgreen BackgroundColor lightgreen } enum { FontColor darkblue BackgroundColor lightblue header { FontStyle bold } } annotation { BackgroundColor pink FontColor red } } </style> abstract abstract abstract class "abstract class" annotation annotation class class class class_stereo <<stereotype>> entity entity enum enum exception exception interface interface metaclass metaclass protocol protocol stereotype stereotype struct struct @enduml
这种方式下,只有指定的类别会应用自定义样式,其余类别保持PlantUML的默认样式。
内容的提问来源于stack exchange,提问作者Corbie
相关产品推荐
相关产品推荐

