Adding Layers to Diagrams
By default, a diagram consists of a single layer—this layer stores all the elements visible on the diagram canvas. However, you can optionally add multiple layers to a diagram. With layers, you can make logical groupings of modeling elements within the same diagram and thus separate concerns. For example, you can create, in addition to the default layer, some extra layers that would store notes with some internal information, or unfinished classes. Layers can be viewed and managed from the Layer window.
In the image above, three layers are defined on the diagram. The layer "Notes" is currently selected. The third layer, "Work in progress", is currently locked. The number displayed in the brackets to the right of each layer denotes how many elements each layer has.
Any UML element can be assigned to any layer. By default, new elements are added to the currently active layer, which is highlighted in the Layer window. If all layers are visible, you can create relationships such as association, generalization, etc between elements on different layers.
When printing diagrams or saving them to an image, only elements from the currently visible layers are printed. The maximum number of layers per diagram is 20.
The buttons available in the Layer window have the following purpose:
Appends a new layer to the current layer list, and assigns a default name which you can change immediately or through the context menu option "Rename".
Inserts a new layer above the currently active layer in the layer list.
Deletes the currently active layer. Before the layer is deleted, a dialog box opens asking where the current layer's items (if any) should be moved (merged).
Focus previous on active layer
Selects the previous element on the currently active layer. This command is enabled only if the layer contains elements.
Focus next on active layer
Selects the next element on the currently active layer. This command is enabled only if the layer contains elements.
Layer item count
Shows or hides the count of elements in each layer.
Reset all layer states
Sets all layers to visible and unlocked state.
Some of the commands above are also available as context menu items, when you right-click inside the Layer window.
To move elements from one layer to another:
•Right-click the element on the diagram and select the Layer | <layer name> command from the context menu. This command is also applicable after you selected multiple elements; in this case, all of them will be moved to the destination layer.
•Alternatively, select one or more elements on the diagram and drag them onto the destination layer in the Layer window.
•To move all elements of a layer into a different one, right-click the layer, and select Merge To | <layer name> from the context menu.
To show, hide, or lock individual layers, or multiple layers at once:
•Right-click the layer in the Layer window, and select the Show, Hide, or Lock command, respectively. The submenu commands Selected layer and Others let you toggle the command either for the currently selected layer, or for all layers except the one currently selected.
•Alternatively, right-click the layer, and use the Toggle Visibility or Toggle Lock commands, respectively. This will hide the layer(s) if they were previously shown, or lock them if they were previously unlocked (and vice versa).