首页 > 解决方案 > PlantUML 类图 - 图例中的字段/方法可见性

问题描述

是否可以使用真实图标在图例中拥有类图的字段/方法可见性标签的键?

即获取下表中的真实图标

@startuml
class Dummy {
-field1
#field2
~method1()
+method2()
}

legend
|= field |= method |=  |
|  -     |   -     | private |
|  #     |   #     | protected |
|  ~     |   ~     | package private |
|  +     |   +     | public |

endlegend
@enduml

示例图

我尝试过但没有成功的事情:

标签: plantuml

解决方案


这非常好(对于我的目的来说肯定足够好):

@startuml
class Dummy {
-field1
#field2
~method1()
+method2()
}

skinparam legendBackgroundColor #ffffff
legend

|= field |= method |=  |
|  <img:http://s.plantuml.com/private-field.png>     |   <img:http://s.plantuml.com/private-method.png>     | private |
|  <img:http://s.plantuml.com/protected-field.png>   |   <img:http://s.plantuml.com/protected-method.png>   | protected |
|  <img:http://s.plantuml.com/package-private-field.png>     |   <img:http://s.plantuml.com/package-private-method.png>    | package private |
|  <img:http://s.plantuml.com/public-field.png>     |   <img:http://s.plantuml.com/public-method.png>     | public |

endlegend
@enduml

带有图标的图例


推荐阅读