Next: , Up: Graph Language Reference   [Contents]


10.2 Default and Refinement Styles for Graphviz Graphs

You can define and redefine styles. As with signalling charts a style is a package of attributes with a name (see Defining Styles). Any attribute can be assigned to styles (even label).

To apply a style to a node, edge or subgraph, use its name alone enclosed in square brackets, like a->b::Label [style];. You can have another square bracket after or before with additional attributes, like a->b::Label [color=red][style][arrowhead=onormal];.

Graphviz has a default style for edges, nodes, cluster subgraphs and graphs named edge, node, cluster and graph, respectively. The default style for graph, node and edge can be set using the graph, node and edge commands as well, such as

node [shape=record];

Msc-generator allows you to collapse cluster subgraphs. Such collapsed subgraphs show up as nodes, but will have cluster_collapsed as the default style (boxes with double lines in the plain design). Similar edges that were pointed to nodes inside the collapsed cluster, will have the style edge_collapsed.

If you want to adjust an attribute for all versions of an arrow symbol (forward, backward, bidir and arrowless) list all of them in the defstyle command, such as in

defstyle ->>, <<-, <<->>, --- [color=red];

Note that no quotation marks are needed for these special style names. (Otherwise non- alphanumeric names need to be enclosed in quotation marks.) Specifically, Msc-generator has the following refinement styles for arrows: ‘->’, ‘=>’, ‘>’, ‘>>’, ‘->>’ and ‘==>’, to represent single, double, dotted, dashed line; double arrowhead and double line, respectively. The last arrow type is provided for you to re-define, by default it is the same as ‘=>’. You can also use them backwards (such as ‘<-’) or bidirectionally (‘<->’). There is also a directionless variant for both, whithout arrowheads: ‘--’, ‘==’, ‘..’, ‘++’, ‘---’ and ‘===’.

Note that when using the edge command to set the default style for edges, not only the edge style is modified, but all refinement styles, too. This is to produce the same output as graphviz for the same input files. If you want to modify only the edge style, use the defstyle edge command.

Msc-generator supports design definitions, for graphs as well. Use the defdesign command to define a named design, like below.

defdesign omegapple {
    defstyle node [color="#d23f7a", style=filled,
        fillcolor="#c20a50:#f3cedc", gradientangle=270,
        fontcolor=white, penwidth=2, label_format="\b"];
    defstyle cluster [color="#c20a50", style=dashed,
        fontcolor="#c20a50"];
    defstyle edge [penwidth=2, fontcolor="#270210"];
}

You can invoke such designs via the usedesign command like usedesign opegapple. You can also select among the designs on the GUI.

Thus, in summary the actual attributes of an element are set using the following logic. (There are minor variances for each language.)

  1. If you specify an attribute directly at the element (perhaps via applying a style), the specified value is used62.
  2. Otherwise, if the attribute is set in the refinement style (at the point and in the scope of where the element is defined), the value there is used.
  3. Otherwise, if the attribute is set in the default style of the element in any of the designs applied, the value in the last design that has this attribute is used.

Footnotes

(62)

If you specify the attribute several times, the last one is used.


Next: Clusters, Up: Graph Language Reference   [Contents]