Stereotypes
Contents
- This chapter is organized as follows:
- Overview
- Viewing Stereotypes
- Creating Stereotypes
- Adding Stereotypes to the Diagram Toolbox
- Subsystem Stereotype Package
OverviewA stereotype is a modeling element subclassification that carries a specific meaning. Stereotypes can be applied to:
A stereotype can be depicted by either a name or 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:
- Allows for customization of your development process.
- Provides mnemonic help and visualization aids.
- Allows you to make presentations with greater detail.
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 online Help.
Viewing StereotypesYou can control how stereotypes are displayed. Click Tools > Options to display the Options dialog box. The settings are found on the Diagram tab.
Diagram Tab
Figure 95 Options Dialog Box--Diagram Tab
The following selections are applied to new model elements that are added to the diagrams. To make changes to existing model elements, use the shortcut menu.
Compartments--Show Stereotypes
This check box 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 on model elements (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 guillemets (<< >>). Decoration 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 names of stereotypes appear inside guillemets (<< >>).
Browser Tab
Figure 96 Options Dialog Box--Browser Tab
The changes made on the Browser tab are reflected in the browser.
Show stereotype names
This check box 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 check box to display stereotype icons, but not stereotype names, of model elements in the browser. This check box is only relevant for stereotypes that have an icon.
Creating StereotypesCreating 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, refer to 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 Creating a New Stereotype for the Current Model.
- 4 Run the Windows Registry Editor (regedit.exe) by clicking 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 > 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.
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. Refer to Creating Stereotype Icons.
- 2 Open the default stereotype configuration file, DefaultStereotypes.ini.
- 3 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
- 4 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
- 5 If you have created a diagram icon for the stereotype, specify the name of that file (Metafile). Note that you can use an ampersand (&) instead of the folder of the stereotype configuration file. For example:
Metafile=&\MyStereotypeIcons\controller.emf
- 6 If you want to create a diagram toolbox button for this stereotype, specify the name of the file in which 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 in which 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
- 7 If you want to graphically display this stereotype in specification lists or in the browser, specify the name of the file in which 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
- 8 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 assign values other than defaults.
- 9 Save your changes to the stereotype configuration file.
- 10 Run Rational Rose. View the log window to make sure there were no problems loading your icons.
- 11 If you created a diagram toolbox icon for the new stereotype, and want to add it as a button on a diagram toolbox, refer to Adding Stereotypes to the Diagram Toolbox.
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, refer to Viewing Stereotypes.
Creating Stereotype Icons
For each stereotype, four different icons may be supplied:
- A diagram icon (to customize the appearance of model elements with this stereotype in diagrams).
- A small and a large diagram toolbox icon (to be able to add a button for this stereotype to the diagram toolbox). Two different sizes correspond to the Use Large Buttons option on the Toolbars tab of the Options dialog box.
- A list view icon (to graphically display the stereotype for model elements in specification lists and in the browser).
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. Diagram toolbox and list view icons must be created in bitmap (.bmp) format.
Note: If you create an icon (for example, a diagram icon), 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.
- 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.
- 2 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 check box is selected 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. 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 an icon (for example, a list view icon), you will most likely want to create the other three corresponding icons: a diagram icon, a small toolbar icon, and a large toolbar 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.
- 2 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.
- 3 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 list in the Save as dialog box.
Note: Some of your icon colors may not match precisely because the color palette used by the toolbars is limited.
Adding Stereotypes to the Diagram ToolboxTo 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, refer to Creating Stereotypes.
- 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.
In an open diagram, right-click in the diagram toolbox and select Customize.
The Customize Toolbars dialog box is displayed. The leftmost column provides the list of available icons.
- 4 Select the icon you want to appear on the diagram toolbox and click Add.
Subsystem Stereotype PackageAlthough closely related to a system, a subsystem is a group of model elements that have 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 97 Subsystem Stereotype Sample
The four subsystems in the subsystem sample together make up all the functionality of the Bookstore Enterprise System. Note that through 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-2001, Rational Software Corporation. All rights reserved. |