3.3.6 Subgraphs
Subgraphs are MetaEdit+’s way to enable arbitrary depth
of models, by linking a model element with a subgraph describing it in more
detail. There are two kinds of semantically different link types: decompositions
and explosions. Both link types are language-dependent and are available only if
the language definition allows them.
Decomposition
provides a semantically stricter link type between an object and a subgraph and
can be used to build model hierarchies based on arbitrary leveling (as in
Figure 3–46). Only zero or one
decomposition is allowed for an object, and applies in all graphs containing
that object. A graph can however be the target of a decomposition of multiple
objects. Decomposition links are normally between graphs of the same
type.
Figure 3–46. Decomposition in a Diagram Editor.
Each
object, relationship or role in a graph can also be linked to other graphs via
explosion
. The explosion link
allows selecting one element from the graph and explodes that to a new graph. An
object (or a relationship or a role) can have a different set of explosions in
each graph where it is used. Similarly, the same graph can be used as the target
of multiple elements in multiple graphs. Explosion is often used between
different graph types.
Checking available subgraph link types
You can find out which object types can be decomposed or
exploded into which graph types by selecting
Help | Graph Type... in the
Diagram, Matrix or Table Editor, and then the ‘Subgraphs’ help
item.
Checking existing subgraph links
The set of all existing subgraph links from this graph can be
found from the Info Tool for the graph. The subgraphs of the current selected
object can be seen from the status bar at the bottom of the Diagram Editor
window.
Opening subgraphs
To open or create a subgraph link, either hold down the
Ctrl-key and double-click the element you want to create the subgraph link for,
or select
Open Subgraph from its popup menu. If there is only one
subgraph attached to the element, that subgraph will be opened. If there are
several possible subgraphs to choose from, a simplified version of the Subgraph
management dialog will open, prompting to select one (as in
Figure 3–47).
Figure 3–47. Choosing a subgraph to open.
If there
are currently no existing subgraphs, the Subgraphs dialog will open and allow
you to create a new subgraph link (as shown in
Figure 3–48).
Figure 3–48. Creating a link to a subgraph.
The
Subgraphs dialog for opening and creating subgraphs provides a list of possible
candidate subgraphs and subgraph creation operations, sorted by the graph type
and graph name. If both decomposition and explosion links are available for the
current selection both of these choices will be presented separately as well.
For example, the list in
Figure
3–48 reads as follows: a user can either create a subgraph link to a
new Communication, Activity, Sequence or State Machine Diagram, or link to an
existing diagram, either the “Ball Game Behaviour - Design” Sequence
Diagram or the “States of the Ball” State Machine Diagram. For
Communication, Activity and Sequence diagrams only one type of subgraph link is
possible (explosion in this case) whereas for State Machine both decomposition
and explosion links are available. Select an existing subgraph or a creation
operation from the list either by double-clicking it or by selecting and
accepting with
OK.
By default a new subgraph will be opened as Diagram
– if you need some other representation like Matrix or Table or want to
leave it unopened, check the appropriate radio button in the Create as
box.
The simplified versions of the Subgraphs dialog also have
a
Manage button at the top of the dialog. Pressing the button will expand
the dialog to the complete subgraphs management dialog as described
next.
Managing subgraphs
The Subgraphs dialog (as shown in
Figure 3–49) lets you manage the
subgraph links attached to an element. To open the Subgraphs dialog, select an
element and choose
Manage Subgraphs... from its popup menu.
Figure 3–49. Managing subgraphs.
The subgraphs
currently attached to the element are listed on the right side of the dialog,
whereas the list on the left shows possible subgraph candidates and the
operations for creating new ones. To attach a subgraph candidate, select it from
the Candidate subgraphs list and click the > button between the
lists. Similarly, to remove an existing link to a subgraph, select it from the
list of Current subgraphs and press the < button.
To create a new subgraph and link to it, select either
‘Create new explosion...’ or ‘Create new
decomposition...’ for the required graph type from the Candidate
subgraphs list (please note that the available link types depend on whether
or not the language definition allows them). When creating a new subgraph, you
also need to define which kind of representation will be created and opened for
it. The default is Diagram but you can also choose Matrix or Table – or to
not create or open a representation yet – by selecting the appropriate
radio button at the bottom of the dialog.
Double-clicking an item on either list is an indication
that you want to open the item. Double-clicking on the Current subgraphs
list simply opens the selected item. Double-clicking on the Candidate
subgraphs list attaches the selection – either an existing subgraph or
a newly created one – as a subgraph before opening it.
To close the Subgraphs dialog, press the Close
button in the lower right corner.
| Please
note that all operations in Subgraphs dialog take place immediately so you
don’t need to accept them when you close the
dialog. |