You can create Legends automatically by extracting them from model elements. Additionally, you can automatically add new Legend items directly from the smart manipulator of the Legend already displayed on your diagram. 

Extracting Legends

You can create a Legend with the selected Legend items automatically. Legends can be extracted either from stereotype tags or the elements displayed on the diagram.


To extract Legends automatically from the applied stereotype tags typed by Boolean or Enumeration


  1. Do one of the following:

    • in open diagram, right-click the element shape and select Tools > Extract Legends in the shortcut menu.
    • in the Model Browser, right-click the actual element and select Tools > Extract Legends in the shortcut menu.
    • in the open table, right-click the row representing the actual element and select  > Extract Legends From Row Type.
  2. In the open Extract Legends dialog, select the Legend representing the stereotype tag to generate a Legend from.



To extract Legends automatically from the elements displayed on a diagram

  1. Open a diagram in which you want to create a Legend.
  2. In the diagram toolbar, click  > Extract Legends
  3. In the open Extract Legends dialog, select the Legends you want to create automatically
  4. Click Extract.

Extracting Legend items

You can add the selected Legend items automatically from the smart manipulator of the Legend shape displayed on the diagram pane. 


To extract the selected Legend items automatically


  1. Open a diagram in which you want to create a Legend.
  2. In the smart manipulator toolbar of the selected Legend shape, click Auto-create Legend items
  3. In the open Auto-create Legend Items dialog, select the specific Legend item(s) to extract.

  4. Click Extract.

The selected Legend items are automatically displayed in the Legend shape and diagram symbols are adorned accordingly.


When extracting Legends or Legend items, you can specify the following options:

  • Select Create Adornments to automatically set a Fill Color for element shapes and Pen Color for paths.
  • Select Connectors by Ports to automatically create Legends for Connectors depending on the selected Ports Legend(s) (Stereotypes of Port Types, Stereotypes of Ports, and/or Port Types).


by checking connector end port in the similar way as selected port legend does.

Legend extraction mechanism

Legends listed in the Extract Legends dialog are generated automatically according to the types of elements displayed as symbols on the diagram pane.


LegendLegend items
Element Typeselement types (metaclasses and stereotypes) displayed on a diagram.
Stereotypes of Port Typesstereotypes of classifiers used as displayed port types in a diagram.
Stereotypes of Part Typesstereotypes of classifiers used as displayed property types in a diagram
Stereotypes of Portsstereotypes of ports displayed in a diagram.
Stereotypes of Partsstereotypes of parts displayed in a diagram.
Stereotypes of Connectorsstereotypes of connectors displayed in a diagram.
Port Typesclassifiers used as displayed port types in a diagram.
Part Typesclassifiers used as displayed property types in a diagram.
Flowing Items of Connectorconveyed classifiers of item flows realized by displayed connectors in a diagram.
Flowing Items of Activity Edgeconveyed classifiers of item flows realized by displayed activity edges in a diagram.
Flowing Items of Associationconveyed classifiers of item flows realized by displayed associations in a diagram.
Name of applied stereotype tag typed by enumerationenumeration literals owned by the applied stereotype tag type.
Name of applied stereotype tag typed by booleantrue and false values.

Example

Let's say that you want to extract the Legend identifying different Risk property values of Requirements in your model. To do this, complete the following steps:

  1. Open the Requirement Diagram in which you want to create the Legend identifying different Requirement risk values.
  2. Right-click the shape of any Requirement and select Tools > Extract Legends OR in the diagram toolbar, click  > Extract Legends
  3. In the open dialog, select the Risk Legend, as shown in the figure below.
  4. Click OK.


The Risk Legend is automatically displayed and applied to the Requirements Diagram. The name of the element tag is used as the Legend name, and every possible Risk property value creates an individual Legend Item.

The process of creating the Legend identifying different Requirement risk values in a Requirement Diagram.

Sample model

The model used in the figures of this page is the Legends sample model that comes with SysML plugin. To open this model, do one of the following:

  • Download legends.mdzip.
  • Open the model from the <modeling tool installation directory>\samples\SysML directory.