Share via


Defining Shape Maps

You can map a shape to a domain class by selecting the Diagram Element Map tool in the Toolbox, clicking the domain class, clicking the shape, and then entering information about the Shape Mapping page of the DSL Details window.

Diagram Mapping

Diagrams are typically mapped to the root of the model. For example, in the Component Models solution template, the ComponentDiagram diagram shape is mapped to the ComponentModel domain class. Diagrams typically act as containers of the shapes on the diagram.

However, if a diagram has swimlanes, the shapes that belong to a swimlane are contained in a swimlane, and the swimlanes are contained in the diagram. For more information about how to map swimlanes, see Defining Swimlane Maps.

Defining General Shape Maps

You must specify a domain class and a parent element path for every shape. The following procedure shows how to map domain classes to shapes.

To define general shape maps

  1. Create a Domain-Specific Language Tools solution by using the MinimalLanguage solution template.

  2. Add a domain class named FirstDomainClass, and then draw an embedding relationship from the ExampleModel domain class to FirstDomainClass.

  3. Add a shape named FirstShape. The shape can be a geometry shape, a compartment shape, or an image shape.

  4. Select the Diagram Element Map tool in the Toolbox, click FirstDomainClass, and then click FirstShape.

  5. Select the line between FirstDomainClass and FirstShape, and then click the DSL Details window.

  6. Make sure that the Shape box shows FirstShape and the Domain class box shows FirstDomainClass.

  7. The parent element path should resemble ExampleModelHasElements.ExampleModel/!ExampleModel. The parent element path specifies the path of the domain class that is represented by the container of the shape. If the shape is contained in a diagram, this is the path of the root domain class. If the shape is contained in a swimlane, it is the path of the domain class that is mapped to the swimlane. To specify a different parent element path, click the Parent element path box and then select an appropriate path from the tree view that is displayed.

  8. You must add a toolbox item for FirstDomainClass before it can be used as a diagram element in your domain-specific language designer. For information about how to add toolbox items, see Customizing Tools and the Toolbox.

Defining Port Shape Maps

Every port shape must appear on another shape and be contained in the other shape. The second shape may be a geometry shape, a compartment shape, or another port shape. A port that is contained in a diagram or a swimlane will provoke a validation error. The following procedure shows how to map a domain class to a port shape.

To define a port map

  1. Create a Domain-Specific Language Tools solution by using the MinimalLanguage template.

  2. The ExampleModel domain class is mapped to the diagram.

  3. Add a domain class named Component.

  4. Draw an embedding relationship between ComponentModel and Component.

  5. Map the Component domain class to a geometry shape.

  6. Add a second domain class named ComponentPort and draw an embedding relationship from Component to ComponentPort.

  7. Add a port and map ComponentPort to it. The parent element path should be ComponentHasComponentPorts.Component/!Component.

  8. You must add toolbox items for Component and ComponentPort before they can be used as diagram elements in your domain-specific language. For information about how to add toolbox items, see Customizing Tools and the Toolbox.

See Also

Other Resources

Domain-Specific Language Tools Glossary

Change History

Date

History

Reason

July 2008

Rewrote and refactored project.

Content bug fix.