Skip to content

ATTR ​

Write the value of an attribute and allow a user to interact with it.

Syntax ​

leo-grammar
ATTR strValue [ x:measureValue ] [ y:measureValue ] [ w:measureValue ] [ h:measureValue ]
    [ line-height:measureValue ] [ line-break:modifier ]
    [ text:strValue ] [ format:strValue ] [ sep:strValue ] [ row:intValue col:strValue ] .

Parameters ​

  • <main-parameter> (strValue) - The name of the attribute.
  • x (measureValue / modifier, optional) - The x-coordinate for the position of the text. The default is 0cm.
  • y (measureValue / modifier, optional) - The y-coordinate for the position of the text. The default is 0cm.
  • w (measureValue / modifier, optional) - The horizontal alignment and the available width for the text. Possible alignments are l, c and r. The default is l and an unconstrained width.
  • h (measureValue / modifier, optional) - The vertical alignment and the available height for the text. Possible alignments are t, c and b. The default is t and an unconstrained height.
  • line-break (modifier, optional) - Setting for automatically adding line-breaks when the maximum width is reached. Possible values are words, rigorous and off. The default is words.
  • line-height (measureValue, optional) - The height of a line, which is relevant when the text is split into multiple lines. The default is based on the used font size.
  • text (strValue, optional) - A value to show instead of the attribute's value. Can be specified as an expression.
  • format (strValue, optional) - The format to use when showing Inter-model references. The default is "%o (%c) - %m (%t)"
  • sep (strValue, optional) - A text used to separate multiple Inter-model references. This text is placed between them. The default is "\n".
  • row (intValue, optional) - Used for record type attributes to show the value of a specific cell. This defines in which row the cell is located, with row numbering starting at 1.
  • col (strValue, optional) - Used for record type attributes to show the value of a specific cell. This defines the name of the column where the cell is located.

Details ​

The style of this command is defined by the FONT command.

The name of the attribute is specified through the <main-parameter> as a literal. The value of the attribute will be displayed as text at the position specified through x and y. The parameters w and h allow to set the alignment and space for the text. The space for the text is only relevant when automatic line breaks are turned on through the line-breaks parameter.

Expression for <main-parameter>

While it is possible to specify the attribute's name through an expression, this seems to prevent properly updating the object's size based on the attribute's value. Use with caution.

Position ​

The x and y values are interpreted in relation to the object's position. They can alternatively be specified as absolute values using the modifier abs before the measure value. In such a case the coordinate is evaluated in relation to the drawing area instead of the object's position and the object's width / height is changed accordingly. This allows to ensured that an attribute is always in a determined column on the drawing area and is displayed independent of how far left or right the object is. For example x:abs:0.5cm will print the text always 0.5cm from the left edge fo the drawing area. Avoid specifying a position as abs when smart-symbol-size is used for the GRAPHREP as it will set the object's width and height to 0cm.

Hint

When an attribute has an empty default value, then this command will typically not produce anything visible in the notation preview available in the Development Toolkit, which can make it more difficult to position and align the text. In such a case it can help to temporarily change the command to TEXT as it shares most of the parameters relevant for positioning and aligning and after the parameters have been set change it back to ATTR. Alternatively temporarily specify a value using the text parameter.

Alignment ​

There are nine possibilities to align the lines of the displayed text. These result from the possible combinations of the horizontal (l - left, c - centred, r - right) with the vertical (t - top, c - centred, b - bottom) alignment. The type of alignment determines how the (invisible) rectangle including the whole text is positioned in relation to the position (x, y). For example w:c and h:c will align the text centered on the position. Individual lines are aligned according to the horizontal alignment specified within this rectangle.

Line Height and Line Breaks ​

The line-height specifies the height to consider for a line. This does not change the actual height of the text as specified by the FONT style, but is used instead to reduce or increase the space between separate lines. By default the line-height is based on the used font size.

The setting for automatic line breaks is controlled through the line-break parameter, which can be set to words, rigorous or off. If set to words or rigorous, then text longer than the allowed width will be broken into several lines. In case of words a line break is inserted before the first word which goes beyond the permitted width, but will not break inside of a whole word, even if a word by itself is longer than the allowed width. In case of rigorous a line break is also inserted before the first word which goes beyond the permitted width when possible or if a whole word is longer than the allowed width, then a line break is inserted before the first letter which goes beyond the permitted width. When the available space specified by h is reached, then the value will be cut off and three dots ... appended at its end. Automatic line breaks can be turned off, in which case any specified restriction on width and height are ignored. Manual line breaks (through \n as part of the text value) are always possible.

Caution

Here the default value for like-break is words, which is different from the default value used in TEXT.

Shown Value ​

The attribute's text defines what is actually shown in the representation. Mostly, this will be exactly the value of the instance attribute to be visualized. However, if a different text is to be represented, then the parameter text should be provided with an expression resulting in the desired text. Use AVAL to retrieve the attribute's value to use it in the expression.

Attribute Interaction ​

The user can also interact with the attribute through the value displayed by this command. For most types of attributes clicking on the displayed value will open an input dialog to edit the value. For Inter-model references a hyperlink which follows the reference is provided instead. For program calls selecting the value will execute the program call.

This behavior is similar to HOTSPOT command.

Inter-model Reference Attributes ​

A specialty of Inter-model reference type attributes is that a format can be provided for their representation. The value should be a string specifying the format and can use the following placeholders which are replaced accordingly:

  • %o with the object name,
  • %c with the class name,
  • %m with the model name,
  • %M with the model basename (only analyzed in application libraries with time-related versioning),
  • %t with the model type name;
  • %v with the internal version number (in format: YYYY:MM:TT, only analyzed in application libraries with time-related versioning),
  • %V with the internal version number defined in the format of versioning (only analyzed in application libraries with time-related versioning).

When an Inter-model reference attribute has more than one value, then the text specified for sep is used between each of them. It can contain more than one character and is by default "\n", which writes each reference in a new line.

Record Attributes ​

With row and col a specific cell in an attribute of type record can be accessed. For row the number of the row has to be specified, with the numbering of rows starting at 1. For col the name of the column has to be provided.

Connector Rotation ​

The displayed text is not rotated automatically when drawing relations to fit their angle.

View Font Size ​

The setting available through the menu View -> Font size... in the Modelling Toolkit allows to increase or decrease the size of text displayed via this command for all objects.

See Also ​

Examples ​

Print the name of the object centered underneath a rectangle.
Three rectangular objects with their names printed underneath: Object 1, Object 2 and Object C

leo
GRAPHREP
# Note: SHADOW is on by default.

RECTANGLE x:-1cm y:-0.5cm w:2cm h:1cm
ATTR "Name" y:0.6cm w:c

Print the name of the object centered inside a rectangle and prevent it from leaving the rectangle.
Three rectangular objects with their names printed inside

leo
GRAPHREP
# Note: SHADOW is on by default.

RECTANGLE x:-1cm y:-0.5cm w:2cm h:1cm
ATTR "Name" w:c:1.8cm h:c:0.9cm line-break:rigorous

Print the first three letters of the value of the attribute "Continent", prepend it with a "c: " and center it horizontally. Use the "Courier New" font for the text. It also provides the typical interaction with the attribute (click value to open input window).
The text c: Afr

leo
GRAPHREP

AVAL sContinent:"Continent"
FONT "Courier New"
ATTR "Continent" text:("c: " + copy(sContinent, 0, 3)) w:c

Show the name of referenced cost departments (inter-model reference to objects) and the name and type of called processes (inter-model reference to models) as hyperlinks.
A list of referenced cost departments (Department A, Department B and Department C) and a list of called processes including their type "(Process)" underneath it (Process 1 and Process 2)

leo
GRAPHREP

ATTR "Referenced cost department" h:b format:"%o"
ATTR "Called process" h:t format:"%m (%t)"

List all the departments of responsible persons, which are specified in a record type attribute.
Two list of the departments (Design and Logistics; Finance, Development and Development)

leo
GRAPHREP

AVAL set-count-rows nRowCount:"Responsible Persons"
SET dY:(0cm)
FOR nI from:1 to:(nRowCount) {
  ATTR "Responsible Persons" y:(dY) row:(nI) col:"Department"
  SET dY:(dY + 12pt)
}

Versions and Changes ​

Available since ADOxx 1.3