如何创建状态转换图?

sam*_*asa 5 libreoffice diagram

我正在 Ubuntu 11.04 上使用 LibreOffice draw 绘制状态转换图。除了最终状态之外,我几乎可以获得我需要的一切。通常我们使用嵌入的两个圆圈来显示状态转换图的最终状态。有人可以帮我做到这一点吗?也请告诉我是否有更好的工具可以在 Ubuntu 上绘制状态转换图。我已经看过直径,但它是不是也画一个状态转换图的最终状态一样有用

ert*_*rne 4

实际上 Dia 确实允许你添加一个结束状态。选择 UML 形状,然后将“初始/结束状态”形状拖到图表上。当您双击该形状时,您将看到一个显示“最终”的按钮。这使您可以定义状态是初始状态还是最终状态。

编辑:如果您不喜欢这些外观,可以很容易地在 Dia 中创建自己的形状。它们只是 SVG 文件。

将以下内容另存为~/.dia/shapes/fsm_final_state.shape

<?xml version="1.0"?>

<shape xmlns="http://www.daa.com.au/~james/dia-shape-ns"
       xmlns:svg="http://www.w3.org/2000/svg">
  <name>Finite State Machine - Final State</name>
  <icon>fsm_final_state_icon.xpm</icon>
  <connections>
    <point x="0.0" y="2.5" />
    <point x="2.5" y="5.0" />
    <point x="5.0" y="2.5" />
    <point x="2.5" y="0.0" />
  </connections>
  <textbox x1="0.0" y1="0.0" x2="5.0" y2="5.0" />
  <svg:svg width="5.0" height="5.0">
    <svg:circle style="fill: default;" cx="2.5" cy="2.5" r="2.5" />
  </svg:svg>
  <svg:svg width="4.0" height="4.0">
    <svg:circle style="fill: default;" cx="2.5" cy="2.5" r="2.0" />
  </svg:svg>
</shape>
Run Code Online (Sandbox Code Playgroud)

将以下内容另存为~/.dia/shapes/fsm_final_state_icon.xpm

/* XPM */
static char * fsm_final_state_icon_xpm[] = {
"16 16 14 1",
"   c None",
".  c #FFFFFF",
"+  c #FCFCFC",
"@  c #B6B6B6",
"#  c #545454",
"$  c #000000",
"%  c #101010",
"&  c #D8D8D8",
"*  c #121212",
"=  c #353535",
"-  c #A0A0A0",
";  c #EBEBEB",
">  c #040404",
",  c #9E9E9E",
"................",
"....+@#$%#@+....",
"...&*=-.;-=*&...",
"..&>,......,>&..",
".+*,........,*+.",
".@=..........=@.",
".#-..........-#.",
".%;..........;%.",
".%;..........;%.",
".#-..........-#.",
".@=..........=@.",
".+*,........,*+.",
"..&>,......,>&..",
"...&*=-.;-=*&...",
"....+@#$%#@+....",
"................"};
Run Code Online (Sandbox Code Playgroud)

最后,将以下内容保存为 ~/.dia/sheets/Finite_State_Machine.sheet :

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<sheet xmlns="http://www.lysator.liu.se/~alla/dia/dia-sheet-ns">
<!--File: ~/.dia/sheets/Finite_State_Machine.sheet-->

<name>Finite State Machine</name>
<description>Finite state machine diagrams</description>
<contents>
<!--add shapes here-->
<object name="Finite State Machine - Final State">
<description>Final</description></object>

</contents></sheet>
Run Code Online (Sandbox Code Playgroud)

当你重新启动 Dia 时,你应该有一个具有一种形状的“有限状态机”表:看起来不错的最终状态!