Creating module stereotypes

Stereotypes belong to a profile, therefore you should declare one as described above prior to create a stereotype.

JUnit Module specifications identify two stereotypes:

  • <<JUnit>> that is used to stereotype test classes that are created by the JUnit Module.
  • <<JUnitDependency>> that is used to stereotype dependency links that are established by the JUnit Module between the test classes and the model class they are testing.

Stereotypes declaration

Stereotypes are declared in module.xml file. Edit the template module xml file and edit the prepared fields.

 1    <stereotype uid="" name="JUnit" label="JUnit" metaclass="Class" is-hidden="false">
 2        <icons>
 3            <explorer path="" />
 4            <diagram path="" />
 5        </icons>
 6    </stereotype>
 7    <stereotype uid="" name="JUnitDependency" label="JUnitDependency" metaclass="Dependency" is-hidden="false">
 8        <icons>
 9            <explorer path="" />
10            <diagram path="" />
11        </icons>
12    </stereotype>
  • uid value is a unique identifier. It is very important that the value shouldn’t be copied from another object (don’t copy the id from the example), nor modified after module delivery. If you are using a Maven project, this identifier is automatically generated during the module packaging.
  • name value is the name of the stereotype.
  • label value is the name of the stereotype that will appear in Modelio gui and diagrams. It follows the standard mechanism of resource management : if it begins with % then it is a resource label that will be retrieved in the manifest property file (module*.properties).

Adding icons to a stereotype

Looking at the stereotype declarations in the previous file excerpt, we can see that stereotypes can be associated with several kind of icons :

  • explorer is used to represent the stereotyped element in the explorer pane (provided the stereotype is the first on the element)
  • diagram is used to replace the element standard representation when an image representation is preferred on diagram.

Explorer icons should have a size of size 16x16 px. Diagram icons can be of any size but a base of 32x32 px is a good average. The recommended format is PNG which allows transparency. Explorer icons are often declared with the same icon file in order to have the same icon representation in explorer and diagrams.

Icon files should be stored in resources/res/icons ; resources directory is mandatory, res/icons is a convention. We can know complete the declaration of JUnit stereotype to add it the following icon : .

2    <icons>
3        <explorer path="res/icons/junitClass16.png" />
4        <diagram path="" />
5    </icons>

Stereotypes can also define tag types and note types :

2         <notetype uid=""  name=""  label=""  is-hidden="false" />
4         <taggedvalues uid=""  name=""  label=""  is-hidden="false"/>             

<< Previous Index Next >>

junit_stereotype.png (717 Bytes) Frédéric Ferran, 09 July 2013 16:35