之前我们讨论了graphviz的dot图,mermaid画流程图和时序图,plantuml画时序图。
plantuml除了可以画时序图之外,还可以画类图。就跟写代码一样,直接上例子:
@startuml
interface Tree{
+ Tree getParent()
+ Object getPayload()
+ Tree getChild(int i)
+ int getChildCount()
+ String toStringTree()
}
interface SyntaxTree{
+ Interval getSourceInterval()
}
interface ParseTree{
+ <T> T accept(ParseTreeVisitor<? extends T> visitor)
+ String getText()
+ String toStringTree(Parser parser)
}
interface RuleNode{
+ RuleContext getRuleContext()
}
interface TerminalNode{
+ Token getSymbol()
}
class RuleContext
class ParserRuleContext
Tree <|-- SyntaxTree
SyntaxTree <|-- ParseTree
ParseTree <|-- RuleNode
ParseTree <|-- TerminalNode
RuleNode <|.. RuleContext
RuleContext <|-- ParserRuleContext
@enduml
简单介绍一下:
- interface定义接口,属性:公开的前面加"+",私有的之前加"-"
- class定义类
- 关系定义: