In this package a model type GraphRep for displaying a model as a set of bars has been implemented.
The model itself can be both a graph or a pool and the objects (modelling instances) are centrally displayed in the Modelling Area.
The values of some selected attributes are displayed on both sides on the modelling area, as defined by the developer.
This solution allows the activation/deactivation of the bar display, selecting the orientation of the modelling area (horizontal/vertical), selection of visible attributes (bars) and much more...
The images below show horizontal and vertical orientation as well as the model type notebook, where the appearance of the model type GraphRep can be configured:


DownloadsThe files below contain an example library (Bar_Display_Library) and example models (Bar_Display_Example_Models):
Bar_Display_LibraryBar_Display_Example_ModelsHands-On1) Create new class __ModelTypeMetaData__

Steps to create class __ModelTypeMetaData__- Go to the Library management, select a dynamic library and click Class hierarchy.
- Click View and select Metamodel.
- Select __D-construct__ (Metamodel)
- Click New --> New class; name it __ModelTypeMetaData__ (two underscore signs!).
2) Add new attributes to class __ModelTypeMetaData__

Steps to add attributes to class __ModelTypeMetaData__:
- Select class __ModelTypeMetaData__
- Click New --> New attribute...
- Name new attributes and select type according figure above: (1) name: BAR GraphRep, type: Longstring (2) name: BAR AttrRep, type: Longstring (3) name: Reference overview settings, type: Longstring.
3) Add Enumeration attribute BAR Display active to class __ModelTypeMetaData__
Steps to add and configure the Enumeration attribute:
- Select class __ModelTypeMetaData__
- Click New --> New attribute...
- Name new attribute BAR Display active and set type to Enumeration.
- Click OK and add the values Yes and No: type Yes into the New value input bar, click Add and do the same for No.
4) Add further attributes to __ModelTypeMetaData__

Name:
Info_color, type:
String, value: lightblue
Name:
Info_display, type:
Enumeration, values:
Yes,
No.
Name:
Info_size, type:
Enumeration, values:
1, 2, 3, 4, 6, 8, 10, 14.
Name:
Modelling direction, type:
Enumeration, values:
horizontal,
vertical.
Name:
Modelling_size, type:
Enumeration, values:
4, 6, 8, 10, 14, 18, 22.
Name:
References_color, type:
String, value: lightblue
Name:
References_display, type:
Enumeration, values:
Yes,
No.
Name:
References_size, type:
Enumeration, values:
1, 2, 3, 4, 6, 8, 10, 14.
5) Configure BAR AttrRep attribute
- Double click BAR AttrRep attribute, set Standard value to:
1CHAPTER "BAR Display"
2ATTR "BAR Display active" ctrltype: check checked-value: "Yes" unchecked-value: "No"
3AVAL s_Aktiv: "BAR Display active"
4ATTR "Modelling direction" ctrltype: radio enabled: (s_Aktiv = "Yes")
5ATTR "Modelling_size"
6GROUP "References"
7ATTR "References_display" ctrltype: check checked-value: "Yes" unchecked-value: "No" enabled: (s_Aktiv = "Yes")
8AVAL s_References_display: "References_display"
9ATTR "References_color" dialog: color enabled: ((s_Aktiv = "Yes") AND (s_References_display = "Yes"))
10ATTR "References_size"
11ENDGROUP
12GROUP "Info"
13ATTR "Info_display" ctrltype: check checked-value: "Yes" unchecked-value: "No" enabled: (s_Aktiv = "Yes")
14AVAL s_Info_display: "Info_display"
15ATTR "Info_color" dialog: color enabled: ((s_Aktiv = "Yes") AND (s_Info_display = "Yes"))
16ATTR "Info_size"
17ENDGROUP
18CHAPTER "Description"
19ATTR "Description"
6) Configuring BAR GraphRep attribute
- Double click BAR GraphRep attribute, set Standard value to:
1@INCLUDE "db:\\modeltype_graphrep_BAR.leo"
- make sure that the file modeltype_graphrep_BAR.leo is contained in the database of the current library (close the Library management and go to Extras --> File management…).
The file modeltype_graphrep_BAR.leo contains the following code:
1GRAPHREP layer:-3
2SHADOW off
3
4AVAL modDirection:"Modelling direction"
5AVAL sNav: "BAR Display active"
6
7#-------------------------------------
8# make header with (model) description
9#-------------------------------------
10IF (sNav = "Yes")
11{
12 AVAL name: "Name"
13
14 IF (modDirection = "vertical") {# vertical case
15
16 FONT h:12pt bold
17 FILL color:white
18 TEXTBOX (name ) x:1cm y:0.2cm
19 FILL color:whitesmoke
20 RECTANGLE x: (textx1-0.1cm) y: (texty1-0.1cm) w: (textx2-textx1+0.2cm) h: (texty2-texty1+0.2cm)
21 TEXT (name) x:1cm y:0.2cm
22
23 FONT h:10pt
24 ATTR "Description" x:0.5cm y: (texty2 + 0.3cm) w:l:10cm h:t:2cm
25 }
26 ELSE {# horizontal case
27 FONT h:12pt bold
28
29 IF (_outdevtype = "printer") {# when printing, description is printed on first A4 page only:
30 SET n_pageNr:0
31 WHILE (w>= (n_pageNr*20.1cm)) {
32
33 TEXTBOX (name + " (p." + STR (n_pageNr + 1) + ")") x: (1cm + n_pageNr*20.1cm) y:0.2cm
34 FILL color:whitesmoke
35 RECTANGLE x: (textx1-0.1cm) y: (texty1-0.1cm) w: (textx2-textx1+0.2cm) h: (texty2-texty1+0.2cm)
36 TEXT (name + " (p." + STR (n_pageNr + 1) + ")") x: (1cm + n_pageNr*20.1cm) y:0.2cm
37 SET n_pageNr: (n_pageNr + 1)
38 }
39 }
40 ELSE {
41
42 TEXTBOX (name ) x:1cm y:0.2cm
43 FILL color:whitesmoke
44 RECTANGLE x: (textx1-0.1cm) y: (texty1-0.1cm) w: (textx2-textx1+0.2cm) h: (texty2-texty1+0.2cm)
45 TEXT (name) x:1cm y:0.2cm
46 }
47
48 FONT h:10pt
49 ATTR "Description" x:0.5cm y: (texty2 + 0.3cm) w:l:10cm h:t:2cm
50 }
51
52 #----------
53 # make BARs
54 #----------
55 FONT h:9pt bold
56 SET cmDefaultLaneSize:2cm
57 # read "Reference overview settings"-attribute:
58 AVAL sRefOverviewInfo:"Reference overview settings"
59
60 SET cmX:0.0cm
61 SET cmY: (texty2 + 2.2cm)
62 PEN color:gray w:1pt
63 SET sSepLine:"\n"
64 SET sSepToken:"|"
65 FOR sLaneInfo in: (sRefOverviewInfo) sep: (sSepLine)
66 {
67 SET sLaneDisp: "No"
68 SET sLaneName: (token(sLaneInfo, 0, sSepToken))
69 SET sHeading: (token(sLaneInfo, 1, sSepToken))
70 SET sLaneNameDisp: (sLaneName + "_display")
71 # read "..._display"-attribute:
72 AVAL set-default: "No" sLaneDisp: (sLaneNameDisp)
73 SET cmLaneSize: (sLaneName + "_size")
74 # read "..._size"-attribute:
75 AVAL set-default: "2" sLaneSize: ( cmLaneSize)
76 SET laneSize: ( CM VAL sLaneSize)
77 IF (type(laneSize) != "measure") {
78 SET laneSize: (cmDefaultLaneSize)
79 }
80 IF (sLaneName = "Modelling") {
81 SET sLaneDisp: "Yes"
82 }
83 # check if current lane shall be painted
84 IF (sLaneDisp = "Yes") {
85 SET sLaneColorName: (sLaneName + "_color")
86 AVAL set-default: lightblue sLaneColor: (sLaneColorName)
87 FILL color: (sLaneColor)
88 IF (sLaneName = "Modelling") {
89 FILL style:null
90 }
91 IF (modDirection = "vertical") { # create vertical bar
92 RECTANGLE x: (cmX) y: (cmY) w: (laneSize) h: (h)
93 TEXT (sHeading) line-break:rigorous x: (cmX + (laneSize / 2)) y: (cmY + 0.55cm) w:c: (laneSize) h:t
94 SET cmX: (cmX + laneSize)
95 }
96
97 ELSE { # create horizontal bar
98 SET n_pageNr:0
99 RECTANGLE x: (cmX) y: (cmY) w: (w) h: (laneSize)
100 WHILE (w>= (n_pageNr*20.1cm)) {
101 TEXT (sHeading) line-break:words x: (cmX + 0.1cm + n_pageNr*20.05cm) y: (cmY + (laneSize / 2)) w:l:2.5cm h:c: (laneSize)
102 SET n_pageNr: (n_pageNr + 1)
103 }
104 SET cmY: (cmY + laneSize)
105 }
106 }
107 }
108}
7) Configure Reference overview settings attribute

- Double click Reference overview settings attribute, set Standard value to:
1References|References
2Modelling|Drawing Area
3Info|Info
8) Create new class A; superclass: __D-construct__ (Metamodel)
9) Add new attributes to class A

- name: _disp_Info_, type: Expression.
- name: _disp_Modelling_, type: Expression.
- name: _disp_References_, type: Expression.
- name: _Modelling_direction_, type: Expression.
- name: _REFERENCE_OVERVIEW_SETTINGS_, type: Expression.
- name: _size_Info_, type: Expression.
- name: _size_Modelling_, type: Expression.
- name: _size_References_, type: Expression.
- name: Info, type: Longstring.
10) Configure new Expression attributes in class A
- Double click on _disp_Info_ attribute
- Set Standard value:
1EXPR type:string expr: (maval("Info_display"))
- Analogously define values of remaining Expression attributes (thereby the argument in the maval function is always the name of the corresponding attribute in __ModelTypeMetaData__).
11) Configure GraphRep of class A
- Double click GraphRep (Metamodel).
- Click the Dialog button.
- Enter:
1GRAPHREP
2SHADOW off
3FILL color:blue
4ELLIPSE x:0.00cm y:0cm rx:1cm ry:1cm
5ATTR "Name" x:0.00cm y:1.0cm w:c
6@INCLUDE "db:\\class_graphrep_BAR.leo"
- Make sure that the file class_graphrep_BAR.leo is contained in the database.
The file
class_graphrep_BAR.leo contains the following code:
1#Define amount of space for displaying attribute values:
2SET cmDisplayHeight:4cm
3SET cmDisplayHeight2:4cm
4
5#read "Modelling direction" and "Reference overview settings" attributes [via corresponding expression attributes]:
6AVAL modDirection:"_Modelling_direction_"
7AVAL sREFERENCE_OVERVIEW_SETTINGS:"_REFERENCE_OVERVIEW_SETTINGS_"
8
9#define seperators for "Reference overview settings" attribute:
10SET sSepLine:"\n"
11SET sSepToken:"|"
12
13#------------------------------
14# Vertical navigation overview:
15#------------------------------
16IF (modDirection = "vertical")
17{
18 SET cmX:0.08cm
19 SET cmY:-0.75cm
20 FONT "Arial" h:8pt color:black
21 PEN color:darkgray outline
22 FOR sLaneInfo in: (sREFERENCE_OVERVIEW_SETTINGS) sep: (sSepLine)
23 {
24 SET sLaneName: (token(sLaneInfo, 0, sSepToken))
25 SET cmLaneSize: ("_size_" + sLaneName + "_")
26 AVAL set-default: "2" sLaneSize: ( cmLaneSize)
27 SET laneSize: ( CM VAL sLaneSize)
28
29 SET bShowLane: "No"
30 AVAL set-default: "No" bShowLane: ("_disp_" + sLaneName + "_")
31 IF (bShowLane = "Yes")
32 {
33 IF (sLaneName != "Modelling") {
34 ATTR (sLaneName) format:"%o" x:abs: (cmX) y: (cmY) w:l: (laneSize - 0.16cm) h:t: (cmDisplayHeight) line-break:rigorous
35 }
36 SET cmX: (cmX + laneSize)
37 }
38 }
39}
40
41#-------------------------------
42# Horizontal navigation overview
43#-------------------------------
44ELSE {
45 FONT h:12pt bold
46 TEXTBOX "A" x:1cm y:0.2cm
47 SET cmY: (texty2 + 2.3cm)
48 SET cmX:-1.6cm
49 FONT "Arial" h:8pt color:black
50 PEN color:darkgray outline
51
52 FOR sLaneInfo in: (sREFERENCE_OVERVIEW_SETTINGS) sep: (sSepLine)
53 {
54 SET sLaneName: (token(sLaneInfo, 0, sSepToken))
55 SET cmLaneSize: ("_size_" + sLaneName + "_")
56 AVAL set-default: "2" sLaneSize: ( cmLaneSize)
57 SET laneSize: ( CM VAL sLaneSize)
58
59 SET bShowLane: "No"
60 AVAL set-default: "No" bShowLane: ("_disp_" + sLaneName + "_")
61
62 IF (bShowLane = "Yes")
63 {
64 IF (sLaneName != "Modelling") {
65 ATTR (sLaneName) format:"%o" x: (cmX) y:abs: (cmY) w:l: (cmDisplayHeight2) h:t: (laneSize - 0.16cm) line-break:rigorous
66 }
67 SET cmY: (cmY + laneSize)
68 }
69 }
70}
12) Create new class B; superclass: __D-construct__ (Metamodel)13) Configure GraphRep of class Bcode:
1GRAPHREP
2SHADOW off
3FILL color:red
4ELLIPSE x:0.00cm y:0cm rx:1cm ry:1cm
5ATTR "Name" x:0.00cm y:1.0cm w:c
14) Define Modeltypes
- Go back to the Library management and select your current Dynamic Library.
- Click Library attributes… --> Add-ons and define the following two model types according the figure above
1MODELTYPE "Bar Display Sample" from:none plural:"Bar Display Samples" pos:0 not-simulateable bitmap:"db:\\sample.bmp" graphrep: "BAR GraphRep" attrrep: "BAR AttrRep"
2INCL "A"
3MODELTYPE "References Sample" from:none plural:"References Samples" pos:1 not-simulateable bitmap:"db:\\sample-target.bmp"
4INCL "B"
Steps to add the Interref attribute References to A:
- Select class A
- Click New --> New attribute...
- Name new attribute References and set type to Interref.
- Click OK
- Double click on new attribute Refereces --> click Facets.
- Click the Dialog button of the AttributeInterRefDomain attribute, see figure above.
- Select Instance references, click Add…, select Model type References Sample and Class B and apply (twice).
ResultIn order to see the result, import and open
Bar_Display_Example_Models in the ADOxx Modeling Toolkit. When importing the example models, one may need to click on the "Import objects from other Library" option.

