| Prev | Next | Start of Chapter | End of Chapter | Contents | Glossary | Index | Comments | (5 out of 12)

Adding Attribute Displays

An attribute display shows the value of one or more attributes of an item. Using attribute displays, you can display any number of an item's values. You can also optionally display the name of the displayed attribute with its value.

This figure shows an action button that has two attribute displays: the Label attribute and the Notes attribute, which is showing the attribute name as well as the value:


The attribute displays of an item are part of its knowledge. As you move an item within its workspace, its attribute displays move with it. When you transfer an item to another workspace, its displays are transferred with it. G2 saves knowledge about an item's attribute displays in the KB file.

Attribute displays are not items; they cannot be transferred, cloned, and so on. However, since they are part of an item's knowledge, you can access them programmatically using the attribute access facility as described in Adding or Removing Attribute Displays Programmatically.

Attribute displays can only show the value for an attribute that does not contain an item. For example, you cannot display the attributes of a quantitative variable that provides the value of a tank's Pressure attribute.


Note: An item's name box is not the same as an attribute display of the item's Names attribute.

To create an attribute display for an attribute in a table interactively:

By default, showing an attribute display interactively displays only the value. Showing the attribute name is described in Manipulating an Attribute Display From its Menu.

The text shown in an attribute display appears in the color assigned to the foreground-color color attribute of the item's parent workspace.

You can reposition an attribute display by using the mouse to drag it. Click on the attribute display to edit the text it displays.


Note: You cannot create attribute displays for charts, connections, digital clocks, freeform tables, graphs, or readout tables.

Graphs are a superseded capability. For more information see Appendix F, Superseded Practices.

Unlike readout tables, attribute displays do not cause data-seeking. If an attribute's value changes and its value is shown in an attribute display, the display is updated with the new value. In addition, attribute displays are always updated to reflect the current values of the attributes displayed, and cannot be disabled.

Attribute displays behave identically to attributes in an item's table. However, attribute displays place a slight additional burden on your application's performance.


Note: If you change the name of an attribute whose value appears in an attribute display, G2 removes the attribute display.

Adding Attribute Displays to Class Definitions

You can also define attribute displays in class definitions so that each instance of the class automatically contains an attribute display.

To define attribute displays for instances of a user-defined class:

Setting up the Attribute-displays attribute of a class definition is described in Specifying Attribute Displays.

Manipulating an Attribute Display From its Menu

You can manipulate an attribute display by opening its menu:



Note: If you click too close to the attribute display value, G2 invokes the Text Editor rather than the attribute display menu.

To add or delete the name of the displayed attribute in the attribute display:

To delete an attribute display:

To display another attribute value in an existing attribute display:

If you create more than attribute display for the same item, the attributes you have selected appear as a list, beginning in the standard position for attribute displays (that is, aligned with the top edge of the icon on the right-hand side).

G2 lists the attributes in the order that they appear on the item's attribute table, regardless of what order you use when creating the displays.

Adding or Removing Attribute Displays Programmatically

It is useful to be able to add an attribute display to an item, or remove one or more attribute displays. You can access and manipulate the attribute-displays of items programmatically using the attribute access facility.

To refer to the attribute displays of all items, except class definitions:

The display-details sequence consists of one or more structures, each structure representing the attribute display information of a particular attribute as three subattributes:

Subattribute Type Description
attribute-list
sequence
A sequence of structures, each with two subattributes:
text-color
symbol
The color of the text.
position
structure
A structure consisting of two integer subattributes: You can also specify the position of an attribute display as the symbol at-standard-position.

To refer to the attribute displays that a class definition defines:

The display-details sequence is identical to the sequence returned for the current-attribute-displays of an item.

As an example, the next figure illustrates the current-attribute-displays sequence of a variable auto-count, which has attribute displays for its Notes and Last-recorded-value attributes.


Example: Adding Attribute Displays to New Objects

In the next example, a whenever rule tracks the creation of instances of hatchback automobile objects, starting the add-displays procedure each time G2 detects a new instance:


To add attribute displays to an item:

  1. Conclude a new value into the attribute-displays attribute of an item.

    The next procedure increments the value of the parameter called auto-count, concludes that value to an attribute of the new hatchback object, and then displays the value and name of that attribute by setting the subattribute display-with-name to true.


    Notice that the procedure specifies the position of the attribute display with:

  2. The result of showing this attribute display is as follows:


| Prev | Next | Start of Chapter | End of Chapter | Contents | Glossary | Index | Comments | (5 out of 12)

Copyright © 1997 Gensym Corporation, Inc.