我认为您的示例代码中有一些错字。该类Layout
应该是 Diagram 的内部类,如下所示:
class RestuarantClasses extends ClassDiagram {
@Spacing(0.5)
@TopMost(People.class)
@Row({Customer.class, Worker.class})
@Column({People.class, Worker.class,Waiter.class})
@Row({Cooker.class, Waiter.class, Cashier.class})
class RestuarantLayout extends Layout {}
}
在 StateMachine 描述中,您还必须指定框之间的垂直关系。该算法无法解决行的垂直对齐问题。
否则,我认为您的图表描述没有问题。
注1:用Above
、Below
、表示框的直接邻接关系Left
。Right
使用Row
andColumn
是表达相同关系的一种方便形式。
注意2:您没有在Payment
任何地方写下状态。默认情况下,图表描述中不包含的框不会出现在图表中。如果你不想对盒子说什么,但你想看到它,请使用Show
注释。
阅读有关图表描述语言的更多信息
你没有得到任何关联是非常奇怪的。图表上显示的框之间的链接会自动排列和可视化。
我试图重新创建您的模型,它应该可以正常工作:
package restaurant.model;
class People;
class Worker extends People;
class Cooker extends Worker;
class Cashier extends Worker;
class Waiter extends Worker;
class Customer extends People{
initial OpenDoor;
state Waiting;
state StartSelection;
state SaladOrNoodle;
state OrderSteak;
state OrderNoodle;
state OrderSalad;
state Payment;
transition tr1{
from OpenDoor;
to Waiting;
}
transition startSelectionTr{
from Waiting;
to StartSelection;
trigger StartSelectionSignal;
}
transition orderSteakTr{
from StartSelection;
to OrderSteak;
trigger OrderSteakSignal;
}
transition orderSaladOrNoodleTr{
from StartSelection;
to SaladOrNoodle;
trigger OrderSaladOrNoodleSignal;
}
transition orderSaladTr{
from SaladOrNoodle;
to OrderSalad;
trigger OrderSaladSignal;
}
transition orderNoodleTr{
from SaladOrNoodle;
to OrderNoodle;
trigger OrderNoodleSignal;
}
transition payTr1{
from OrderNoodle;
to Payment;
trigger PaySignal;
}
transition payTr2{
from OrderSteak;
to Payment;
trigger PaySignal;
}
transition payTr3{
from SaladOrNoodle;
to Payment;
trigger PaySignal;
}
}
signal StartSelectionSignal;
signal OrderSteakSignal;
signal OrderSaladOrNoodleSignal;
signal OrderSaladSignal;
signal OrderNoodleSignal;
signal PaySignal;