0

我正在寻求帮助和建议,以帮助我在这个 stateMachine 模型中允许客户在 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 {
}

在此处输入图像描述

4

2 回答 2

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)
于 2016-10-22T23:18:38.273 回答
0

我认为您的示例代码中有一些错字。该类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:AboveBelow、表示框的直接邻接关系LeftRight使用RowandColumn是表达相同关系的一种方便形式。

注意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;
于 2016-10-26T17:40:03.140 回答