Drawing a UML Profile Diagram
- Create a profile by selecting Modeling > Profile > New Profile from the application toolbar.
- A new profile diagram is created and you are prompted to enter a name. Enter Vehicle Engineering Profile as name and press Enter to confirm.
- You are going to model your profile in this diagram. Let's create a stereotype first. Select the Stereotype tool from the diagram toolbar.
- Click on the diagram to create a stereotype. You are immediately prompted to choose the base type of this stereotype, which is the type of element for which the creating stereotype will be used. Expand the Class node and select Class.
- Click OK to confirm.
- A stereotype is created in the diagram. Enter Vehicle as its name and Enter to confirm.
- Let's define some tags associated with this stereotype. Right-click on the Vehicle stereotype and select Open Specification... from the popup menu.
- Open the Tagged Value Definitions tab.
- At the bottom of the tab, click Add and then select Floating Point Number Tag from the popup menu.
- Enter speed-limit as tag name and press Enter to confirm.
- Create two integer tags passenger and id, and one enumeration tag automatic-transmission.
- Let's configure the possible values for the enumeration tag automatic-transmission. Click on the ... button in its Default Value cell.
- In the Edit Enumeration window, click Add to add and then enter yes as value. Add another value no.
- Select yes and check Default value to make it the default option.
- Click OK to confirm and return to the specification window.
- Click OK in the specification window to return to the diagram.
- Let's create the other stereotypes in this profile. Move your mouse pointer over the Vehicle stereotype.
- Press on the Resource Catalog button that appear at the top right of shape. Drag it out.
- Release the mouse button in empty space. Select Composition -> Stereotype from Resource Catalog.
- A new stereotype is created and has Class automatically chosen as base type. Enter Body as name and press Enter to confirm.
- Besides composition, you can also create specialized stereotypes. Let's create a stereotype Pickup Truck which is a specialized type of vehicle, using Resource Catalog. This time, choose the resource Generalization -> Stereotype.
- Up to now, your profile diagram should look like this:
- Apply the techniques taught above to add tags to the new stereotypes. Add a text tag painting to Body and a floating point number tag cargo-capacity to Pickup Truck.
- Draw two more specialized stereotypes Mini and Convertible from Vehicle. Draw another composite stereotype Interior from Vehicle, and another composite stereotype Seat from Interior. Add a text tag int-painting to Interior and two text tags texture and pattern to Seat. Your diagram should look like this:
Creating a Class with Stereotype
The profile is now ready to use. Let's create a class diagram with the stereotype defined in Profile Diagram.
- Create a class diagram by selecting Diagram > New from the application toolbar. Select Class Diagram in the New Diagram window and click Next. Keep the diagram name as provided and click OK to confirm.
- Create a class Light Motor Vehicle.
- Right-click on Light Motor Vehicle and select Stereotypes > Edit Stereotypes from the popup menu.
- Select Pickup Truck on the left hand side and then click > to add it.
- Open the Tagged Values tab. The tags defined in the stereotypes are listed. Besides the tag defined in <<Pickup Truck>>, there are tags defined under its generalized stereotype <<Vehicle>> and its composited stereotypes.
- Click the ... button in the Value cell of Body tag. The Sub-level Tagged Values window is shown. You can specify the tagged values of the Body stereotype there.