Main Content

move

Move message within interaction

Since R2024b

    Description

    move(message, Before=beforeElement) places the message specified by message immediately before the beforeElement interaction element object.

    example

    move(message, After=afterElement) places the message specified by message immediately after the afterElement interaction element object.

    example

    Examples

    collapse all

    You can programmatically move messages in a sequence diagram. This example assumes you have the TLExample model open from the Create Sequence Diagrams Programmatically. You use the move function to place the first message in the root fragment immediately before the alternative fragment.

    Open the Inhibit sequence diagram.

    model = systemcomposer.openModel("TLExample");
    diagram = getInteraction(model, "Inhibit");

    Inhibit sequence diagram

    Get the first and second message in the root fragment.

    message = diagram.RootFragment.Operands.Fragments(1).Message;
    message1 = diagram.RootFragment.Operands.Fragments(2).Message;

    Use the RootFragment property of the interaction to list the classes of all fragments.

    iterator = systemcomposer.interaction.Iterator(diagram.RootFragment);
    next = iterator.next;
    while ~isempty(next)
        if isa(next, 'systemcomposer.interaction.AltFragment')
            altFrag = next;
        end
        next = iterator.next;
    end

    Place the message message immediately before the altFrag fragment.

    if ~isempty(altFrag)
        move(message, Before=altFrag);
    end
    diagram.open;

    Inhibit sequence diagram with the original first message of the diagram placed immediately before the alt fragment.

    Input Arguments

    collapse all

    Message to be moved, specified as a systemcomposer.interaction.Message object.

    More About

    collapse all

    Version History

    Introduced in R2024b