Creating New Elements

A new diagram, of course, requires elements in order for it to have significance. There are several ways to add elements to a diagram, as you will se in the next couple of sections.

Diagram Pane Toolbar

The diagram pane toolbar contains buttons to create elements that are specific to that diagram. For example, the button to create an initial state will not appear in a class diagram toolbar. This reduces the amount of buttons that you must deal with at one time.

The create buttons for most elements act as stamps, so that the element is placed wherever you click within a diagram. The exceptions to this are associations. Any sort of relationships need to exist between two model elements, therefore both of these elements must be included in the creation process instead of just stamping a line anywhere.

To create a new association element with the toolbar, select the type of association and place the cursor over the first element in the relationship. Click and hold the mouse button, then drag it to the second element in the relationship. Note that for some of the association types, the order in which the elements are connected affects the definition of the association.

Try it YourselfCreate new elements with the toolbar

  1. Open the class diagram User Registration: Design-Class Model.

  2. Select the 'create class' button from the toolbar. The mouse should now appear as a crosshair.

  3. Place the crosshair to the right of the class 'User' and click the mouse button to create the new class.

  4. Select the 'generalization' button from the toolbar. The mouse will again appear as a crosshair.

  5. Place the crosshair in the new class, press and hold the mouse button, then drag it to 'User'.

    * Note that the order in which they are connected determines the direction of the inheritance.

  6. You are now ready to incorporate the new class into the model. Look through the rest of this guide to learn how to change the name of the class, color-code it, add elements and operations, and more.

The Rapid Buttons

The toolbar is not the only way to create new diagram elements or associations. Poseidon for UML provides an intelligent shortcut that can speed up the development of a diagram. Select a class and wiggle your mouse near the edge of the class and several additional buttons will appear. They are called Rapid Buttons and are only available if an element is selected.

These rapid buttons can be used in two ways. You can either click on it to create and associate a new corresponding model element with appropriate connection in one step, or keep the mouse button pressed and drag it to an existing model element to create a new association without creating a new class.

Rapid buttons are available for many diagram elements in each of the editors. Here is a class example:

Figure 7-9. Rapid Buttons for a class element.

For a class element, the rapid buttons to the left and right represent directed associations, the button on top represents specialization of superclasses, below is the generalization of subclasses, and self-associations are in the bottom right corner.

Try to click on the rapid button underneath your new class and you will see that a new subclass appears close to it. If you click and hold the button, you can move the mouse and place the new element where you want it to be. Or if you click, hold, and move the cursor over an existing element, only a connection between these elements is created.