list of dots Digital Research Alliance of Canada logo  NSERC logo  University of Ottawa logo / UniversitĂ© d'Ottawa

User Manual    [Previous]   [Next]   

Filters

Documentation of the filters feature is being developed

A filter directive in Umple can be used to select only a certain part of a model and ignore the rest. It is particularly designed to allow creation of different diagrams from the same model. However it could also be as a way of building a particular version of the system that only has certain features. It is one of Umple's separation of concerns mechanisms.

There are two types of filter statements, named and unnamed. An unnamed filter statement is active by default, and tells the system to include only certain indicated classes (seven such filters are shown in the example below). A named filter statement is ignored until activated with an includeFilter statement (the example below shows two named filters appearing after the Filter 7 comment).

Filters can be used to describe a particular diagram (or system version). There can be any number of named filters.

Within a filter directive, one can specify

  • include statements. These list the main classes to be included. There can be any number of include statements, and multiple comma-separated classes can follow each include keyword. Several include statements can be seen in the example below. Any associations between included classes are shown (see Filter 8)
     
  • Optionally includeFilter statements. These include other named filters. To activate a named filter, it is necessary to use an includeFilter statement in an unnamed filter. See Filter 7 in the example.
     
  • Optionally namespace statements. These include all classes in the given namespace.
     
  • Optionally hops statements. These indicate that additional classes should be included that are connected to included classes by associations or generalizations. See examples 2 and 6 for association hops, and example 4 for a subclass hop. Note that including any class will by default include its superclasses, so the complete picture of what is inherited is presented; to avoid including superclasses, specify hops {super 0;}.

Consider wrapping filter statements within mixsets. This will allow you to turn on and off various filters using command line arguments.

Load the example below into UmpleOnline and uncomment any of the 8 filter statements, one at at a time, to see the effect of filtering. The comment just before each filter statement describes the effect. Note that the named filters described as Filter 7 have been left uncommented as they are ignored until the un-named filter following them is activated.

Example

// Example to demonstrate filters. Uncomment one of
// the filters shown below to display a different
// diagram, or generate a different subset of the
// code

// This model describes abstract art consisting of
// various shapes connected in 3-D space, some
// of which can contain others.

// Filter 1. Show only Shape3D
// filter {include Shape3D;}

// Filter 2: Show classes connected to Model3D with
// one hop
//  filter {include Model3D; hops {association 1;}}

// Filter 3: Show classes related to qualities
// filter {namespace qualities ;}

// Filter 4: Show Shape3D, its subclasses and all
// their connections
// filter {include Shape3D; hops {sub 1;}}

// Filter 5: Including also includes parents
// filter { include Cube;}

// Filter 6: Show two classes and their neighbours
//  filter {include Surface, Model3D; hops {association 1;}}

// Filters 7: Named filters and use of the named filter
 filter 7 {include Connector; hops {association 1;}}
 filter 7a {include Cube;} // includes its parents
//  filter {includeFilter 7,7a;}

// Filters 8: Including classes that are associated
// will always show the associations
//  filter { include Colour, SurfaceQuality;}


class Point3D {
  Double x;
  Double y;
  Double z;
}

class Model3D {
  depend Qualities.*;
  depend Shapes.*;
  name;
  1 -- * Shape3D;
  1 -- * Connector;
}

namespace Qualities;

class Colour {
  Integer red;
  Integer green;
  Integer blue;
}

class SurfaceQuality {
  * -> 1 Colour;
  Float reflectance;
  Float transparency;
}

namespace Shapes;

// Shape3Ds are nodes, they can also contain other
// Models inside themselves.
class Shape3D {
  // All surfaces, points, connections
  // are relative to the centre which acts
  // as the Shapes origin.
  // The centre also positions the shape in 3-space.
  * -> 1 Point3D centre;
  
  // An Internal 3D model appears inside a Shape3D
  // All points are relative to the shape's centre
  0..1 containingShape -<@> 0..1 Model3D internalModel;
}

// A surface is used to describe the shape
// of one of the sides of a polyhedron
// points are relative to the centre of the
// polyhedron. The points must fall on some
// 3D plane.
class Surface {
  * -> * Point3D;
  * -> 1 SurfaceQuality;
}

// Connectors are sticks connecting 3D Shapes
class Connector {
  * -> 2 Point3D ends;
  * -- 2 Shape3D connectedShapes;
  Double radius;
  * -- 1 SurfaceQuality;
}

class Sphere {
  isA Shape3D;
  Double radius;
  * -> 1 SurfaceQuality;
}

class Polyhedron {
  depend Qualities.*;
  isA Shape3D;
  1 -- * Surface;
}

class RegularPolyhedron {
  isA Polyhedron;
}

class Cube {
  isA RegularPolyhedron;
}

strictness ignore 30; // hide namespace warnings
      

Load the above code into UmpleOnline

 

Syntax


association : [=modifier:immutable]? [[associationEnd]] [=arrow:--
    |->
    |<-
    |><
    |<@>-
    |-<@>] [[associationEnd]] ;

filter : filter ( [filterName] )? { ([[filterStatement]])* }

filterStatement- : [[filterCombinedValue]] | [[filterNamespace]] | [[filterValue]] | [[hops]]

hops- : hops {([[super]] | [[sub]] | [[association]])*}

filterValue : include ([classname]) ( , [classname] )*;

super : super [superNum];

sub : sub [subNum];

association : association [associationNum];

filterNamespace : namespace [Namespace] (, [Namespace])* ;

filterCombinedValue : includeFilter ([filterName]) ( , [filterName] )*;