PlantUML: 使用简单的文字描述画UML图,入门

2 篇文章 0 订阅
2 篇文章 0 订阅

PlantUML: 使用简单的文字描述画UML图,入门

概述

PlantUML支持的UML图类别还挺多的:时序图,用例图,类图,活动图,组件图,状态图,对象图等。

文字描述UML图的好处或特点:

  • 轻量级,文本编辑器即可操作(本地安装PlantUML或在线工具解析)
  • 类似于word vs latex,虽然少了图形拖拽,但可以自动按描述生成对象和布局,对于熟悉者,更方便
  • 文本,便于版本控制

入门文档方面,官方的文档也很丰富。
官网:http://plantuml.com/

在线编辑

在线编辑器1:http://www.plantuml.com/plantuml/uml/
在线编辑器2:https://www.planttext.com/

实战

以下是实现Simon Game之前,尝试用PlantUML画的状态机。

@startuml

title Simon Game
state "Game Ready" as sGameReady
state "Game In Progress" as sGameInProgress {
    state "Game Beginning" as sGameBeginning
    state "Generate One More Step" as sGameOneMore
    state "Series Presentation" as sGamePresentation
    state "Series Re-press" as sGameRepress

    sGameBeginning: Random series is empty: n=0:
    sGameOneMore:  n=n+1, generate one more step
    sGamePresentation: show series and play sound
    sGameRepress: play sound

    [*] --> sGameBeginning
    sGameBeginning-left-> sGameOneMore
    sGameOneMore-down-> sGamePresentation
    sGamePresentation-right->sGameRepress: presentation over
    sGameRepress-left->sGamePresentation: failed, strictmode==false
    sGameRepress-up->sGameOneMore: succeed, n<20
    sGameRepress-up->sGameBeginning: failed, strictmode==true
    sGameRepress -->[*]:succeed, n==20
}
state "Game Success" as sGameSuccess
[*] --> sGameReady: swich on
sGameReady-right->sGameInProgress: click start button
sGameInProgress-right->sGameSuccess: n==20, succeeded
sGameSuccess -left-> sGameInProgress: click start button

sGameReady-->[*]: switch off
sGameInProgress-->[*]: switch off
sGameSuccess-->[*]: switch off

@enduml

效果图(使用在线编辑器2)
Simon Game效果图

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值