Poseidon for UML: User Guide
Prev | Chapter 11. Using Diagrams | Next

# Editing Diagrams

## Adding Elements

There are two methods for placing new elements within a diagram: through the Diagram pane toolbar and through the rapid buttons. The toolbar contains miniature representations of all of the elements available in that particular diagram. Adding elements to a diagram in this manner is very straightforward, simply click on the element in the toolbar and then click in the diagram workspace. Creating elements through the rapid buttons is not only quick (as the name implies), but also has the advantage of creating a relationship to the new element from this one step.

## Editing Elements

Perhaps the simplest way to edit an element is to edit it directly in the diagram. This is known as Inline Editing. Double-click on the aspect of the element that you would like to change, and the characteristic will be editable in a text box.

You can also edit an element in the Diagram pane through the context menus. Right-click on the element or characteristic to display the context menu to see what is editable from this menu for the particular element.

Some characteristics, however, are available for editing only from the Details pane. Open the Details pane for an element by selecting it from the Diagram pane or the Navigation pane. Navigate to the desired characteristic (such as a return type for a class operation) by double-clicking on the characteristic in the left side of the Properties tab. Some of the characteristics may require navigating through several layers of characteristics. The Properties tab also provides navigation buttons which function similar to a web browser.

## Deleting Elements

The are two ways to delete items from a diagram, but each works in a slightly different way.

The delete function completely removes the element from the project. All occurrences of this element are deleted, whether they appear in the current diagram or not.

The remove function removes the element from the current diagram only. The element remains available in other diagrams and in the Navigation pane.

## Drag and Drop

Some diagrams will be created solely from new elements. But sometimes you will want to use elements that already exist in the model. You just want to present them in a different context and show other specific aspects of its role in the overall architecture.

To do this, you can drag existing elements from the Navigation pane and drop them in the diagram. These elements will appear with all currently known associations to other elements already present in the diagram. Notice that this function will copy the representation of the element to the new diagram, it does not copy the element itself. See the Section called Copying, Cutting, and Pasting Elements in Chapter 13 for more information about the 'copy representation' and 'complete copy' functions.

Another possibility is to select elements in a different diagram, copy them by hitting Ctrl-Shift-C and paste them into your new diagram by hitting Ctrl-V. To cut elements from a diagram, use Ctrl-Shift-X. Of course, you can also use these features via the Edit menu or the Context menu.

Note that Drag and Drop is not currently available in all diagrams.

## Drag and Drop Elements within other Elements

Drag and Drop can also be used to change element namespaces. This can be accomplished by selecting an element in the diagram and dragging it inside the parent element. When the cursor has crossed into the parent element, a preview of the resize is displayed and the element may now be dropped into the parent element.

Figure 11-6. Drag and Drop with preview

After the element has been dropped, the parent element will automatically resize to accomodate the new element, and the properties and navigation tree are immediately updated.

Figure 11-7. Drag and Drop completed

## Changing Namespaces

As your model evolves and grows bigger, you might want to restructure your model organization. Drag-and-Drop and Copy/Cut/Paste functions are surely one way of doing this. But there is a deeper concept behind the structure of models that you should be aware of.

UML has the notion of namespaces that define a structure for a model. This structure is not necessarily the same as the structure of your diagrams. Remember that model elements can be represented in several diagrams but can only have one namespace. And since diagrams can be created at very different points in the model structure (that is in different namespaces), model elements do not always share the namespace of that diagram.

A namespace is an abstraction of model elements that can contain further model elements. A typical example for a namespace is a package. Classes as well as diagrams are usually contained in a package, or to put it differently, their namespace is the package they are included in. Any model element that is not directly owned by another model element (like an operation that is owned by a class) has such a namespace.

To find out what namespace a model is in, look at the Properties tab in the Details pane. Any element either has a namespace or an owner. You can change the namespace by clicking on the little button to the right of the text field. This opens a drop-down menu with all namespaces you can move it to. For example, if you decide a class should not belong to the package you created it in, you can simply change its namespace to be a different package from the Properties tab.

In some cases, changing the namespace for one element does not only effect this element but others as well. This is a convenience feature that was intentionally built in, believing that this is what the user intends to do in most cases. But this might not always be the case. If you change the namespace of a diagram, then all model elements in that diagram are assigned the new namespace as well. Also, if you change the namespace of a package, all included elements will likewise be moved to the new namespace.

Since packages are the most important type of namespace, there is another convenience feature for it. You can change a model element's namespace by dragging it with the mouse onto the figure of a package within a diagram.

## Visibilities

As of Poseidon for UML version 4.2, it is possible to specify visibility options on a per-element basis from the Details pane. The visibility selector is comprised of two parts. The first is the visibility button itself, which hides and displays the frame that appears around the diagram, including the diagram name. The second is the dropdown that is accessible from the arrow next to the button. This dropdown allows you to select exactly which parts of the element will be displayed in the diagram. The options available from this dropdown will vary according to the element currently selected.

Figure 11-8. Visibility options for a Component

The final set of buttons allow you to add elements to the current attribute. The elements available depend on the element selected. For classes, your options include adding attributes, operations, inner classes, and inner interfaces. Associations and the like have a selector to determine how the edges should be displayed.

Additionally, the Properties tab contains checkboxes next to items that can be displayed or hidden, such as individual interfaces within a component.

## Layout Functions

You already know that you can layout your diagram by using the select tool. But there are a number of other ways to rearrange your diagrams.

Select and Move Elements

A selected class can be moved not only by using the mouse, but also by means of the arrow keys. The elements get nudged in the direction of the selected arrow key. Holding down the SHIFT key while pressing the arrows causes the elements to move in larger increments.

You can easily select several elements by holding down the Shift key while you select further elements, or by clicking somewhere in the empty space of the drawing area and dragging the mouse over elements. A dashed line appears and all elements that are partially or wholly enclosed in it will be selected.

Figure 11-9. Selecting multiple elements with the mouse.

Movements always apply only to the selected elements. If you want to select all elements in a diagram, use the quick-key Ctrl-A.

Elements can be moved along invisible 'rails' by holding the Ctrl key while dragging the elements. This limits the movement to the X and Y axes of the original element. If multiple elements are selected, the center of the selected elements is used as the origin of the rails. This means that an element may or may not reside at the origin.

Arrange Elements

Another set of useful options that are accessible from the main menu are the arrangement options. These are a powerful set of tools to assist with the layout of a diagram.

The Align Tools include:

- Align Tops - Aligns the tops of the selected elements along the same horizontal axis

- Align Bottoms - Aligns the bottoms of the selected elements along the same horizontal axis

- Align Lefts - Aligns the left sides of the selected elements along the same vertical axis

- Align Rights - Aligns the right sides of the selected elements along the same vertical axis

- Align Horizontal Centers - Aligns the centers of the elements along the same vertical axis

- Align Vertical Centers - Aligns the centers of the elements along the same horizontal axis

- Align to Grid - Aligns the top-left corner of the element with the snap grid

The Distribute Tools include:

- Distribute Horizontal Spacing - Distributes elements so that there is the same amount of white space between the vertical edges of the selected elements

- Distribute Horizontal Centers - Distributes elements to that there is the same amount of space between the centers of elements along a horizontal axis

- Distribute Vertical Spacing - Distributes elements so that there is the same amount of white space between the horizontal edges of the selected elements

- Distribute Vertical Centers - Distributes elements so that there is the same amount of space between the centers of elements along a vertical axis

The Size Tools include:

- Greatest Current Width and Height - Uniformly resizes selected elements so that each is the size of the largest selected element.

- Smallest Current Width and Height - Determines the size of the smallest element that can display the information of each of the selected elements and uniformly resizes the selected elements.

- Minimum Possible Width and Height - Determines the smallest possible size for each of the selected elements and uniformly resizes them so that each is the size of the largest minimized element.

- Greatest Current Width - Uniformly resizes selected elements so that each is the width of the largest selected element.

- Smallest Current Width - Determines the width of the smallest element that can display the information of each of the selected elements and uniformly resizes the selected elements.

- Minimum Possible Width - Determines the smallest possible width for each of the selected elements and uniformly resizes them so that each is the width of the largest minimized element.

- Greatest Current Height - Uniformly resizes selected elements so that each is the height of the largest selected element.

- Smallest Current Height - Determines the height of the smallest element that can display the information of each of the selected elements and uniformly resizes the selected elements.Note: this is not functional in the current version of Poseidon.

- Minimum Possible Height - Determines the smallest possible height for each of the selected elements and uniformly resizes them so that each is the height of the largest minimized element.

The Ordering Tools include:

- Bring To Back - Places the selected element(s) on the bottom layer of the diagram display.

- Bring To Front - Places the selected element(s) on top of the diagram display.

- Send Backward - Moves the selected element(s) down one layer in the diagram display.

- Send Forward - Moves the selected element(s) up one layer in the diagram display.

These groups of tools may be used alone or in conjunction with another tool of a different type.

The layout process is supported by a grid. It you want a finer or a coarser grid than the default, or if you want the grid to be displayed in a different manner, you can change this in the View menu.

Changing the Shape of Relationships

You can also change the layout of the edges. By default, Poseidon for UML always tries to draw a straight line without bends but you can easily add waypoints: Select an edge and move the mouse perpendicular to the edge. At first the edge simply moves, too. But as soon as a straight edge is no longer possible, a waypoint is automatically added. You can add several waypoints by clicking on the edge so that you can wire your diagrams as you prefer. To remove a waypoint, just move it over another waypoint or an endpoint and it disappears.

Figure 11-10. Adding waypoints.

In Poseidon for UML version 2.0, waypoints have changed from blue boxes to yellow circles. Despite the change in appearance, they function in the same way.

Moving Adornments

You can also move adornments as you can move elements. Simply select the adornment and drag it around. You will notice a little dotted red line that indicates to which association this adornment belongs. Roles and multiplicities are attached to the association ends in the same manner.

Figure 11-11. Moving adornments.

In version 2.0, the adornments move in a slightly different (and more intelligent) manner. Previously, an adornment might obscure an edge. Adornments now 'hop' over edges, automatically providing a cleaner look to the diagrams.

## Undo/Redo

Poseidon maintains a history of changes made to the model. The undo and redo buttons step forwards and backwards through this history. Beginning with version 2.6, the undo and redo history can include actions before an import, provided that the Settings dialog option has been enabled. See the Section called Roundtrip Settings in Chapter 7 for more information about the 'Roundtrip imports are undoable' option.

## Non-UML Additions

Some of the items available in the toolbar exist to clarify and enhance models, even though they are not a part of the UML specification. These items do not affect any code generation, but increase the understandability of a project for human readers.

### 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 Yourself - Resize an Element
Select the `Client` class from a diagram. Small round yellow handles appear on the corners of the element. Click and hold the mouse button on one of these handles and drag it around the diagram to resize the class.

### Comments

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 comment element. Comments are extra notes that are included and displayed in a diagram. These comments can be added to almost any element including other comments, or they can stand alone in the diagram. Comments cannot be added to relationships, transitions, or shapes created with drawing tools in any diagram, and objects in sequence diagrams.

Comments are ignored by the code generator; therefore they are never seen in the code output. They are likewise never seen in the Navigation pane.

To add a comment to a diagram:

1. Click the Comment button in the diagram toolbar.

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

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

1. Click the Connect Comment button from the toolbar.

2. Place the crosshairs over the comment 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 comment to an element using the rapid buttons:

1. Click one of the rapid buttons around the comment 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 comment the current active element and then begin typing, or double-click to open the editable text field.

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 11-12. A new comment

### 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; therefore, they don't show up in the model tree in the Navigation pane.

The Drawing Tools:

- Text - Click in the diagram area and begin typing to create a text object.

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

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

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

- 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 lclicking to add a third waypoint. Double-click the last waypoint to cease the addition of lines.

### 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 11-13. 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 11-14. 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 11-15. 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 similarly 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'.

Prev | Home | Next
Navigation | Up | Element Reference