UML & SysML modelling languages

Expertise and blog articles on UML, SysML, and Enterprise Architect modelling tool

version francaiseTwitterVideos UMLChannel SparxSystems EA YouTubeLinkedIn
Wednesday, 17 October 2012 22:19

Discover and use EA Diagram Filters (tutorial)

Written by Guillaume
Rate this item
(2 votes)

This article is intended to illustrate the advantages of using the Diagram Filters, functionality added in EA version 9. Two case studies based on my current experience illustrate the purpose of Diagram Filters:

1- to filter dependency connectors between provided and required interfaces on a UML Component diagram,

2- to show the differences between the specifications and two implementations through the use of UML State Chart diagram.

Definition from EA Help: “Diagram Filters (Dynamic Visual filters) enable you to modify the display of diagram components, so that the relevant items are immediately identified for the reader's attention without damaging the structure and integrity of the model. Currently the feature operates on elements and connectors“.

From the “Diagram Filters” view in EA, you can create as many filters as you need. Those are stored in your EA project file so it can be enabled for any diagram that is currently displayed and selected.

Note: it doesn’t seem to be possible to export diagram filters to re-use in other EA projects.

fenetre diagram filters EA

Creating a new filter
To create a filter, simply click on New and enter a name for it; then you have to choose between filtering on a Connector or an Element. Note: a single filter only applies to connectors or elements, not both.

A wide range of fields is available to define what needs to be filtered in or out of the diagram:

options diagram filters enterprise architect

Why use diagram filters: an example with connectors and interfaces (example 1)

I first used this functionality with UML Components diagrams to model software components with ports and provided/required interfaces. Interfaces were associated with dependency connectors to link service suppliers and service consumers. Due to the high number of interfaces and components, the diagram was difficult to maintain from a visibility perspective. Hence the need to hide all connectors to better analyse the whole diagram, before switching back to the original view (with dependencies). Due to the complexity of the project, the diagram layout was time consuming to maintain, and modelling through several diagrams wouldn’t be suitable.

So I created the following filter to show all connectors except Dependencies i.e. ConnectorType Not Equals Dependency.

options de filtrage diagrammes EA

Here is my component diagram with the filter disabled:

filtre option 1

And here is the same diagram with the filter enabled with the option Hide:

fitres diagrammes Enterprise Architect

The above diagram shows a current limitation in filtering connectors i.e. it’s not possible to choose the source and target type (e.g. Interface) so not all dependency links are hidden. On the above diagram I would need to show the dependency between Component1 and Package1, whilst hiding the dependency connector between the required and provided interfaces. (I submitted this as a feature request to SparxSystems).

When enabling a filter, there are 3 rendering options to choose from: Hide, Fade, Grey, and Select (Fade and Grey being very similar...).

Why use filters: an example with a state chart diagram (example 2)

Another recent experience involved a class lifecycle that had been specified with a UML state chart diagram. States and transitions were used to implement the same class in two products running in different environments, and involving two different development teams.
In this article, I’ve chosen as an example a DVD player state chart.

During the implementation, the two products weren’t tested by the same end users; this situation led to bug or enhancement requests specific to each product, modifying the final set of rules from the original specifications.

Once both products were delivered, my task involved gathering and model the differences. Diagram Filters was the perfect solution as it would let me maintain a single diagram to model transitions and states that were either common to both projects, or specific to either one.

To do so, I started off with a copy of the state chart from my specifications. Anything that was specific to either project was tagged ProjectA or ProjectB (I used the element or connector's Alias in its properties, since tagged values cannot be searched on with Diagram Filters). This even worked with diagram notes.

I then created the following filters:

  • Show common connectors (filter settings: Alias Equal To <no value set in the Value column>)
  • Show projectA connectors (filter settings: Alias Equal To ProjectA)
  • Show projectB connectors (filter settings: Alias Equal To ProjectB)

As a result, I could display on demand various versions of the same diagram:

  • All connectors (common and specific) : all filters are disabled
  • Only connectors common to both projects with the “Show common” filter enabled, and the other 2 filters left disabled

diagramme d'état cycle de vie UML EA

  • Show ProjectA rules with both “Show common” and “Show ProjectA” filters enabled:

diagramme d'état UML avec filtre de diagramme

One may argue that colour coding could be an alternative (e.g. use black for common rules, red for A, blue for B), but this requires greater efforts to maintain in the long term (if you have a more complicated diagram than the example).