我正在寻求帮助和建议,以帮助我在这个州机器模型允许客户在xtxUml餐厅订餐。我想显示如下图所示的模型,那么如何修复下面的代码呢?我得到的结果没有任何关联。感谢您的建议和帮助。
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 {}
}
class CustomerStates extends StateMachineDiagram<Customer> {
@TopMost({Customer.OpenDoor.class})
@Row({Customer.Waiting.class, Customer.StartSelection.class})
@Row({Customer.SaladOrNoodle.class, Customer.OrderSteak.class})
@Row({Customer.OrderNoodle.class, Customer.OrderSalad.class})
class L extends Layout {
}
答案 0 :(得分:0)
尝试使用节点的下一个布局约束:
@Above(val = A.class, from = B.class)
:方框A从B向北,紧挨着它。
@Right(val = A.class, from = B.class)
:方框A从B向东,紧挨着它。
@Below(val = A.class, from = B.class)
:方框A位于B的南边,紧挨着它。
@Left(val = A.class, from = B.class)
:方框A位于B的西边,紧挨着它。
您的代码应如下所示:
@Above(val = OpenDoor.class, from = Waiting.class)
@Row({Waiting.class, StartSelection.class})
@Below(val= SaladOrNoodle.class, from = Waiting.class)
@Below(val=OrderNoodle.class, from = SaladOrNoodle.class)
@Right(val=OrderSalad.class, from = OrderNoodle.class)
@Right(val=OrderSteak.class, from = SaladOrNoodle.class)
@Below(val = Payment.class, from = OrderSalad.class)
答案 1 :(得分:0)
我认为您的示例代码中存在一些拼写错误。 Layout
类应该是图的内部类,如下所示:
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
和Column
是表达相同关系的便捷方式。
注2:您没有在任何地方写Payment
州。默认情况下,图表描述中未包含的框不会出现在图表中。如果你想对盒子说什么,但是你想看到它使用Show
注释。
Read more about the diagram description language
你没有得到任何联想是非常有意义的。图表上显示的框之间的链接自动排列和可视化。
我尝试重新创建你的模型,它应该可以正常工作:
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;