Chapter 7. Working with Diagrams

Table of Contents
The Diagram Pane
Viewing Diagrams
Creating New Diagrams
Creating New Elements
Editing Elements
Editing Diagrams
Undo/Redo

UML is a graphical language. Therefore, from a users perspective at least, the most important part of a UML tool is the graphical editor. This chapter introduces the general features of the diagram editor that are available for all or most of the diagram types, then takes a detailed look at the graphical editor and explains Poseidon's most important functionalities for editing diagrams.

The Diagram Pane

The graphical editor is embedded in the Diagram pane. This pane, as has been previously mentioned, is used to display and edit the diagrams of your model.

Diagram Pane Toolbar

Across the top of the Diagram pane, there is a toolbar that contains a number of tools you can use to create and modify your UML models. If you have already worked with a UML tool or a drawing tool capable of creating UML diagrams, you are probably familiar with the general idea. Each diagram type has a specialized set of tools in addition to the tools that are common to all diagram types. To display the name of each individual tool, position your mouse over it and wait a second or so, the name will appear in a box underneath.

In general, the Diagram pane toolbar changes according to the type of diagram currently displayed. There are, however, some tools which are available in all or nearly all of the diagrams:

Select

The first tool in the toolbar is called the 'select' tool, and is the default active tool. It is used to select, move, and scale diagram elements, as well as modify the element directly from the diagram. When an element has been selected and is now the current active element, it will appear with yellow circles (called 'handles') surrounding it.

A brief list of functions:

  • Select an element — Click on the desired element.

  • Move an element — Click and hold the mouse button inside the element, then drag the element to its new location.

  • Resize an element — Click and hold the mouse button on an element handle, then drag the handle.

  • Edit an element inline — Double-click on a text element to activate the text edit box.

Try it YourselfResize an Element

  1. Select the Client class from a diagram.

  2. Small round yellow handles appear on the corners of the element.

  3. Click and hold the mouse button on one of these handles and drag it around the diagram to resize the class.

Notes

Sometimes a diagram requires a bit of extra explanation. This information is not a part of the final code, yet it helps the viewer better understand the diagram. This information can be included in a note element. Notes are extra comments that are included and displayed in a diagram. These notes can be added to any element including other notes, or they can stand alone in the diagram.

Notes are ignored by the code generator and are therefore never seen in the code output. They are likewise never seen in the Navigation pane.

To add a note to a diagram:

  1. Click the Note button in the diagram toolbar.

  2. Position the crosshairs in the diagram and click to place the note in the diagram. At this point it is a freestanding note that is not connected to any element.

To connect a note to an element using the toolbar buttons:

  1. Click the Connect Note button from the toolbar.

  2. Place the crosshairs over the note to be connected. Click and hold the mouse button.

  3. Drag the crosshairs to the element to be connected. Release the mouse button.

To connect a note to an element using the rapid buttons:

  1. Click one of the rapid buttons around the note to be attached. Hold the mouse button down.

  2. Drag the crosshairs to the element to be connected.

  3. Release the mouse button.

You can either use the 'select' tool to make the note the current active element and then begin typing, or double-click to open the editable text field.

Figure 7-1. Adding a note through a context menu

Just as with any other element, notes can be resized with its handles and the color can be changed through the style panel of the Details pane. This makes it easy to introduce a color-coding scheme to diagram notations.

Figure 7-2. A new note

Drawing Tools

The set of tools which appears at the end of the toolbar are for general drawing purposes. With these tools you can add other graphical elements such as shapes to your diagram. You should keep in mind that, although useful sometimes, these graphics are not part of UML and therefore they don't show up in the model tree in the Navigation pane.

The Drawing Tools:

  • Rectangle — Click in the diagram area and drag the mouse to create a rectangle.

  • Circle — Click in the diagram area and drag the mouse to create an ellipse.

  • Polyline — Click in the diagram area and to create a waypoint. Click again to create another waypoint and a line between them. A connected line can be added by clicking to add a third waypoint. Double-click the last waypoint to cease the addition of lines.

  • Polygon — Click once everywhere the polygon is to have a corner. Double-click the last corner to close and render the polygon.

Toggle Between Editing Modes

Two modes of editing are available for modifying shapes. You can switch between modes by double-clicking on a shape.

The first is a resize mode, which allows you to change the size of the shape by dragging the handles (gold circles) that surround the shape. Dragging one of the corner handles enlarges and shrinks the shape without changing its proportions. Dragging the side handles expand and compress the shape.

The second editing mode is available for all shapes except circles. It allows you to add, remove, and move waypoints to change the shape of the element. For example, you can create a rectangle, double-click on it, and then add a waypoint to create a new polygon.

Figure 7-3. Add a Waypoint to a Rectangle

Close Shape

Once a shape has been drawn with the line tool, it is possible to close the shape automatically to create a polygon. Select the shape and open the 'style' tab of the Details pane. Check the box titled, 'Close Shape'. The shape can be reopened by unchecking the same box.

Figure 7-4. Open and Closed Lines

Opacity

Fill colors can be applied from the 'style' tab of the Details pane. It may be advantageous to change the opacity of this fill at times. Fortunately, this is very easily accomplished. Simply select the figure that will have a different opacity and use the slider bar within the 'style' tab of the Details pane.

Figure 7-5. Changing Opacity

Waypoints

Once a line or polygon has been created, the shape can be altered by creating and moving a waypoint, much in the same way that connections between elements can be edited. Click on the perimeter and move the resulting gold circle to create an 'elbow'. In this same vein, waypoints can be deleted by selecting and dragging them over an existing waypoint or endpoint.

Diagram-specific Tools

The rest of the tools in the toolbar are specific to the current diagram type. They allow the creation of diagram elements and operate similar to a stamp. With a single click on the icon you get a handle to create one corresponding diagram element. If you double-click, the tool stays selected and you can create a number of diagram elements, one after the other. The cursor changes to a hair cross with which you can select the position of the new element. To disable this feature just click on the 'select' tool.

Some tools are only available in a certain context. In Class Diagrams, the tools to create a new attribute or a new operation are only available when a class is selected. Select the desired class and click on the appropriate button to create a new attribute or operation for your class.

The individual tools are covered in detail in the chapter titled, 'A Walk Through the Diagrams'.