One Element in Multiple Diagrams
Models are very rarely so simple that can be described using one diagram. Often you have to use multiple diagrams and some elements need to be repeated in these diagrams. This tutorial shows you how to correctly use one element multiple times.
We have the following diagram with six classes (see picture below). Details of four classes (Style, Paragraph, Table, Image) are hidden. We want to describe Image class more in depth and show its relationships with other classes, which are not important for MainDiagram diagram.
We create another class diagram, which describe details for Image class. Click on green plus icon and choose Class Diagram. Diagram will be added and open in the new tab.
Double click on the diagram tab and rename it to ImageDetail.
Click on MainDiagram tab to switch to that diagram. Click on Image class and drag it with right mouse button to tab of ImageDetail diagram.
Tab bar will enlarge and it will show diagram thumbnails - so you can see the content of open diagrams. When you drag over ImageDetail tab, program opens this ImageDetail diagram and you can move the cursor to diagram area and then release the right mouse button. Image class will be copied to this diagram. However, this copy is not independent, it has shared model with Image class in MainDiagram diagram - in other words it is the same class. If you rename Image class in MainDiagram diagram it will be renamed in both diagrams (MainDiagram, ImageDetail).
As you can see, the copied Image class has a small icon (white plus in blue circle) above itself. It notifies you that this class is used in multiple diagrams.
Now we can add other details to the ImageDetail diagram - two subclasses of Image class (BitmapImage, VectorImage). We also add 'size' attribute to Image class and we set it as abstract. If you switch back to MainDiagram, you will see that the name of Image class is rendered with italic font (abstract classes are marked this way), but the added size attribute is missing in this diagram. How it is possible? You can set different presentation options for an element in each diagram. Image class in MainDiagram diagram has hidden attributes and operations (but they are still there) and Image class in ImageDetail diagram has displayed attributes and operations.
New Comment