DiagramStyle

DiagramStyles are at the top of the configuration food chain. They reference other configuration parts, binding them together so the diagram selects which Java elements to display and how to display them.

Basic controls

DiagramStyle test description "test" {
  canvas Color ( normal 240 240 240 strong 255 255 255 );
  shows type titles qualified ;
  shows types in signatures as unqualified ;
  shows exceptions as omitted ;
  shows parameter names ;
....
}

The basic controls are:

  • Canvas color
  • How to show type titles
  • How to show types in signatures
  • How to show exceptions
  • How to show parameter names

These clauses are optional but have to be specified in the above order and before other clauses. Note that content assist enforces this.

Displays / Hides (Bindings)

Below the basic controls is a list of displays / hides clauses.

Each Java element is assigned a display style on a first match basis.

TypeSelector proxy description "just proxy" {
  interfaces named "IProxy" ;
}

TypeSelector proxies description "proxy classes" {
  classes subtype of proxy;
}

DiagramStyle myDiagramStyle description "displays proxy classes in green" {
  displays types in proxies using greenTypeDisplayStyle ;
  displays types in allTypes using defaultTypeDisplayStyle ;
}

So above we have two TypeSelectors and a DiagramStyle. The DiagramStyle binds proxies to greenTypeDisplayStyle. In other words, any class which implements the IProxy interface will be displayed in green (greenTypeDisplayStyle is defined elsewhere).

Note that type which are not selected by proxies ie any class which does not implement IProxy or any interface which does not extend IProxy will fail over to the next clause.

There are equivalent clauses for binding fields and methods.

DiagramStyle myDiagramStyle description "enlarges public fields and hides private methods" {
  displays fields in publicFields using largerFieldOrMethod ;
  hides methods in privateMethods ;
}

Above, publicFields is a FieldSelector specified elsewhere, largerFIeldOrMethod is a FieldOrMethodDisplayStyle specified elsewhere and privateMethods is a MethodSelector specified elsewhere.

So each type, field or method is displayed (if at all) according to the first selector which it matches using the display style it is bound to.

Line Bindings

Line bindings control how lines are displayed between Java elements. The line bindings must be specified after the type, method and field bindings.

Example

Supposing we had a diagram with many types selectable by TypeSelector called managedObjects. If almost every managedObject had a dependency on every other managed object, it would make it difficult to see other significant dependencies between types. Therefore we may wish to play down the dependencies between managedObjects and we could do this as follows:

DiagramStyle faintManagedObjectDependency description "no dependency lines between managed objects" extends defaultDiagramStyle {
  displays dependency lines from managedObjects to managedObjects using LineStyle ( Color ( normal 109 109 163 strong 62 62 145 ) );
}

Switches

displays and hides clauses can be qualified by switches. This saves having to make large numbers of DiagramStyles to handle all of the combinations of display options you may need.

Example

Highlights (displays in orange) clientExceptions if the switch is set to client or highlights serverExceptions if the switch is set to server. clientExceptions and serverExceptions are TypeSelectors specified elsewhere.

DiagramStyle mySwitchableDiagramStyle description "switches between client and server exceptions" {
  displays types in clientExceptions using orangeTypeDisplayStyle if clientOrServer matches "client";
  displays types in serverExceptions using orangeTypeDisplayStyle if clientOrServer matches "server";
}

Inheritance

Any DiagramStyle can be declared using basic control statements followed by an ordered list of bindings. However, there is normally common ground between the DiagramStyles you require and the inheritance of DiagramStyles avoids having to repeat boiler-plate clauses.

  • With inheritance if a basic control setting is not specified, the setting from the super DiagramStyle is used.
  • If no displays/hides with a matching selector is encountered, then the super DiagramStyle is checked for matching selectors.