Main Content

move

Move fragment within interaction

Since R2024b

    Description

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

    example

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

    example

    Examples

    collapse all

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

    Open the Inhibit sequence diagram.

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

    Inhibit sequence diagram.

    Get the first message in the root fragment.

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

    Use an iterator to navigate through all elements of the sequence diagram and find the AltFragment.

    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 altFrag fragment immediately before the message message.

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

    Inhibit sequence diagram with alt fragment placed before the messages.

    Input Arguments

    collapse all

    More About

    collapse all

    Version History

    Introduced in R2024b