UML Stereotype Tutorial - Working with Styles

You can extend a model element from a stereotype to give it specific identify and specify its domain specific properties. Moreover, you can define formatting properties to stereotype, such as fill color and border style, to make model elements that extend the stereotype follow. In this tutorial, we will make use of a simple class diagram to show how to format a stereotype called API, and how to format an API class by applying stereotype.

June 24, 2015
Views: 49,234
PDF Download
  1. Download Simple-Shape-Generator.vpp. You can also find this file at the bottom of this tutorial.
  2. Open the downloaded .vpp file in Visual Paradigm. To open a project, select Project > Open from the application toolbar. You will see the class diagram below.
    class diagram
  3. We want to model the fact that the `Shape` class is an API class. We can do this by defining and applying an API stereotype. Select Windows > Configuration > Configure Stereotypes... from the toolbar.
  4. In the Configure Stereotypes window, expand the Class tree node, and select Class. Click Add... at the bottom.
    Add stereotype
  5. In the Stereotype Specification window, enter `API` as the name.
  6. Here you can see three options in the specification dialog box: Fill, Line, and Font. By setting them, you can make classes that use the API stereotype share the formatting properties defined. Let's try Fill first. Check Use for Fill. Click the ... button and select gray as the color.
    Change fill color
  7. Similarly, check Use for Line and edit its properties. Select a dotted line style, set the weight to `3`, and select blue as the color.
    Format line style
  8. Finally, check Use for Font and edit its properties. Select a font you like (Comic Sans MS is used in this tutorial), set it to bold, and select 14 as the font size, which makes the text bigger than the default.
    Set font properties
  9. Click OK to confirm the changes in the Stereotype Specification window. Click OK in the Configure Stereotypes dialog box to close it.
  10. Now, we need to apply the `API` stereotype to the `Shape` class. Right-click on the `Shape` class and select Stereotypes > API from the popup menu.
    Stereotype Shape class
  11. The appearance of the class is updated to follow the format defined for the API stereotype.
    Final diagram

Resources

  1. Simple-Shape-Generator.vpp