Rational Software Corp.

TOC PREV NEXT INDEX



Chapter 12

Stereotypes


Overview

A stereotype is a modeling element subclassification that has been given a more specific meaning. Stereotypes can be applied to:

A stereotype can be depicted by either a name or by an icon.

Benefits to Using Stereotypes

A stereotype allows you to provide additional distinctions in your model that are not explicitly supported by the UML. The use of stereotypes:

User-Defined Stereotypes

Some stereotypes are predefined, but you can also define your own to add new kinds of modeling types. User-defined stereotypes are defined in a stereotype configuration file. For each stereotype, you can customize icons to be displayed in diagrams, in the browser, and in the toolbox.

Rational Rose offers ten stereotype icons that you can use when modeling a business:

For more information on these icons, refer to the Rational Unified Process.


Viewing Stereotypes

You can control how stereotypes are displayed. The settings are found on the Diagram tab and the Browser tab, located in the Options dialog box under the Tools menu.

Diagram Tab


Figure 94 Options Dialog Box--Diagram Tab
The following selections are applied to new model elements are added to the diagrams. To make changes to existing model elements, use the shortcut menu.
Compartments--Show Stereotypes

This option allows you to control the display of stereotype names for operations and attributes of new classes in the class compartments.

Stereotype Display--None, Label, Decoration, Icon

These options allow you to control the display of stereotypes (except for relationships) in diagrams. The selection is applied to new model elements that are added to diagrams.

Selecting Label, makes the name of the stereotype appear inside angled brackets, << >>. Decorating displays a graphic marker such as highlighting an icon or tool. Selecting None means the name is not displayed, while selecting Icon means the icon created for that stereotype is displayed.

Stereotype Display--Show labels on relations and associations

This option allows you to control the display of stereotype labels on new relationships in diagrams. If enabled, the name of the stereotypes will appear inside angle brackets, << >>.

Browser Tab


Figure 95 Options Dialog Box--Browser Tab

The changes made on the Browser tab are reflected in the browser.

Show stereotype names

This option allows you to control the display of stereotype names of model elements in the browser.

Hide stereotype name if there is an icon for it

Select this option to display stereotype icons, but not stereotype names, of model elements in the browser. This option is only relevant for stereotypes that have an icon.


Creating Stereotypes

Creating a New Stereotype for the Current Model

You can create a new stereotype by typing a new name in the Stereotype field of a model element's specification. The new stereotype will then be available in the Stereotype field for all model elements of that type (which are assigned the same language), in the current model.

If you want the stereotype to be available in all Rose models, follow the steps below. If you already have a stereotype configuration file, skip to the section titled Creating a New Stereotype for All Rose Models.

Creating a New Stereotype Configuration File

The stereotypes in Rational Rose must be defined in a stereotype configuration file. Rational Rose is delivered with a default stereotype configuration file, called DefaultStereotypes.ini. If possible, add your stereotypes to that file. If you do not want to use that file, follow these steps to create a new stereotype configuration file:

  1. Close Rational Rose.
  2. Create a text file (called, for example, MyStereotypes.ini) using Notepad or another text editor, and save it in the Rose installation folder.
  3. Edit the new stereotype configuration file. For information on how to create a new stereotype and add it to a stereotype configuration file, please refer to the Creating a New Stereotype section.
  4. Run the Windows Registry Editor (regedit.exe) by selecting Run on the Start menu. Type "regedit" and click OK.
  5. Locate and select the section entitled [HKEY_LOCAL_MACHINE\SOFTWARE\Rational Software\RoseStereotypeCfgFiles] in the registry list.
  6. Click Edit > New and click String Value. Give the new registry key the name "file#", where # is the next consecutive number (1, 2, or 3, etc.).
  7. Double-click the new key, and enter the name of your configuration file (for example, MyStereotypes.ini).
  8. Close the registry. Next time you open a model in Rational Rose, the stereotypes defined in your new stereotype configuration file will be available in the model.

Creating a New Stereotype for All Rose Models

To create a new stereotype and make it available in all models in Rose:

  1. Close Rational Rose.

Note: Optionally, create icons for the stereotype to be used in diagrams, lists, and diagram toolboxes. Please refer to the Creating Stereotype Icons section later in this chapter.

  1. Open the default stereotype configuration file, DefaultStereotypes.ini.
  2. In the stereotype configuration file, add a line for the new stereotype in the section called [Stereotyped Items]. For example, to add the class stereotype Controller to an existing configuration file, add a corresponding line as follows:
    [Stereotyped Items]
    Class:Model
    Class:View
    Class:Controller
  3. Create a section for the new stereotype, named exactly as the line you added in the [Stereotyped Items] section, for example:
    [Class:Controller]
    Item=Class
    Stereotype=Controller
  4. If you have created a diagram icon for the stereotype, specify the name of that file (Metafile). Note that you can use "&" instead of the folder of the stereotype configuration file. For example:
    Metafile=&\MyStereotypeIcons\controller.emf
  5. If you want to create a diagram toolbox button for this stereotype, specify the name of the file where you created the corresponding small toolbox icon (SmallPaletteImages) and the location of the icon in that file (SmallPaletteIndex ). You can also specify the name of the file where the corresponding large toolbox icon is defined (MediumPaletteImages) and the location of the icon in that file (MediumPaletteIndex). For example:
    SmallPaletteImages=&\MyStereotypeIcons\
    small_palette_icons.bmp
    SmallPaletteIndex=3
    MediumPaletteImages=&\MyStereotypeIcons\
    medium_palette_icons.bmp
    MediumPaletteIndex=3
  6. If you want to graphically display this stereotype in specification lists or in the browser, specify the name of the file where you created its list icon (ListImages) and the location of the icon in that file (ListIndex). For example:
    ListImages=&\MyStereotypeIcons\list_icons.bmp
    ListIndex=2
  7. Add any other setting needed to define the new stereotype. For a list of all available settings, information on the meaning of each setting, the possible values, and the default values, please refer to the "Stereotype Configuration File" topic in the online help. Note, however, that you only have to include settings for which you want to give other values than their default values.
  8. Save your changes to the stereotype configuration file.
  9. Run Rational Rose. View the log window to make sure there were no problems loading your icons.
  10. If you created a diagram toolbox icon for the new stereotype, and want to add it as a button on a diagram toolbox, please refer to the Adding Stereotypes to the Diagram Toolbox section later in this chapter.

The new stereotype is now available in Rational Rose. For information on how to control the display of the new stereotype in diagrams and in the browser, please refer to the Viewing Stereotypes section earlier in this chapter.

Creating Stereotype Icons

For each stereotype, four different icons may be supplied:

Creating a Diagram Icon

Diagram icons are "symbols" or "elements" that can be placed on a diagram from the browser, toolbar, or menu. Diagram icons have to be created in Windows Metafile (.wmf) or Enhanced Metafile (.emf) format. You can download drawing packages that support these formats at various shareware sites on the Internet. Enhanced Metafiles are recommended if possible. Diagram toolbox and list view icons must be created in bitmap (.bmp) format.

Note: Note: If you create a diagram icon, for example, you will most likely want to create the other three corresponding icons: a list view icon, a small toolbar icon, and a large toolbar icon.

To create a diagram icon:
  1. Using a vector based (as opposed to bitmap) drawing application, draw your icon in the size you want it to appear in Rational Rose. It is not recommended that you use a drawing application that forces the icon to fit a certain area, such as a page as with PowerPoint.
  2. Consider the following: Make sure that the scaling factor is set to 100% when deciding on the size of the icon. Use colors if you like. If you want the name of the model element to appear within the stereotype icon, leave some blank space for it.
  3. Select the icon and export it in either the Windows Metafile (.wmf) format or the Enhanced Metafile (.emf) format. If you use CorelDraw, make sure the Include header option is checked if you save your selection as a Windows Metafile.

Creating Diagram Toolbox and List View Icons

Diagram toolbox icons and list view icons (icons that appear in the browser) are created in bitmap (.bmp) format and Rational Rose only supports bitmap files saved in the 256 color bitmap scheme. You can create one bitmap file containing several icons, arranged horizontally side by side. Note that the SmallPaletteIndex setting in the configuration file of a stereotype specifies the diagram toolbox icon that belongs to a specific stereotype. The ListIndex setting specifies the list icon that belongs to a specific stereotype. Diagram icons can only be created in Windows Metafile (.wmf) or Enhanced Metafile (.emf) format.

Note: If you create a list view icon, for example, you will most likely want to create the other three corresponding icons: a diagram icon, a small toolbar icon, and a large toolbar icon.

To create a new icon:
  1. Create or open a bitmap file using a program such as Microsoft Paint or the bitmap editor in Microsoft Visual Studio.

Note: If you are adding several icons to the same bitmap file in Microsoft Visual Studio, use the grid setting in the Image menu to help you see the borders of each icon.

  1. Create an icon of the following size and background color:
    • Small diagram toolbox icon - 15 pixels high and 16 pixels wide, using a gray background (which is RGB = 192, 192, 192 in Rational Rose).

    • Large diagram toolbox icon - 24 pixels high and 24 pixels wide, using a gray background (which is RGB = 192, 192, 192 in Rational Rose).

    • List view icon - 16 pixels high and 16 pixels wide, using a white background.

  2. Save the icon as a 256 color bitmap file (.bmp). To save the color setting in Microsoft Paint, select 256 color bitmap from the Save as type menu in the Save as dialog box.

Note: Some of your icon colors may not show up precisely because the color palette used by the toolbars is limited.


Adding Stereotypes to the Diagram Toolbox

To make a stereotype available as a button on a diagram toolbox:

  1. Create a stereotype and a corresponding diagram toolbox icon. For information on how to do that, please refer to the Creating a New Stereotype section earlier in this chapter.
  2. Click Tools > Options, and click the Toolbars tab.
  3. Under Customize Toolbars, click on the diagram type for which you want to change the toolbox.
    or,
    In an open diagram, right-click in the diagram toolbox and select Customize.
  4. The Customize Toolbars dialog box is displayed. The leftmost column provides the list of available icons. Select the icon you want to appear on the diagram toolbox and click Add.


Subsystem Stereotype Package

Although closely related to a system, a subsystem is a group of model elements that has specific behavior and objectives. A subsystem is a stereotyped package and is represented by the package icon with the subsystem stereotype.

Note: The term subsystem is also used in the Rose Extensibility Interface (REI). However, there is a specific distinction between each term. In the REI, any package that resides in the component view is considered a subsystem. A subsystem on a Rose diagram is a stereotyped package.

Subsystem Stereotype Sample

The subsystem stereotype sample demonstrates how subsystems collaborate to make up a larger system. The sample below illustrates a bookstore system and the smaller subsystems that make up the total system.


Figure 96 Subsystem Stereotype Sample

The four subsystems in the subsystem sample together make up all the functionality of the Bookstore Enterprise System. Noted throughout the <<include>> relationships, each subsystem provides a certain piece of the Bookstore system functionality.

Instead of going into separate subsystems, a user of the Bookstore Enterprise System can verify stock in the Warehouse subsystem or check the status of a shipped book in the mailing subsystem, for example. All subsystems make up a much larger system. Each stereotyped package subsystem is just a means of organizing model elements and diagrams together.


Rational Software Corporation  http://www.rational.com
support@rational.com
techpubs@rational.com
Copyright 1993-2000, Rational Software Corporation. All rights reserved.
TOC PREV NEXT INDEX