| Prev | Next | Start of Chapter | End of Chapter | Contents | Glossary | Index | Comments | (6 out of 11)

Locating Items Upon a Workspace

The location of each item upon its parent workspace is part of its knowledge. Note that some items do not reside upon a workspace, yet they are still part of the KB's knowledge.

The location of a workspace within a G2 window is part of its knowledge.


Note: G2 maintains information about whether a workspace is being displayed, and at what scale, on a per-window basis; it does not maintain this information in the workspace item. For more information about the relationships among workspaces and the windows of G2 and Telewindows processes, see Chapter 8, G2-Windows.

Layering Items Upon the Same Workspace

Item layering refers to how G2 draws the representations of items in a top-to-bottom manner upon a workspace. The layering of an item is part of its knowledge.


Note: G2 includes two drawing modes, Paint and XOR. The XOR drawing mode is a superseded capability. Your KB should use only the Paint drawing mode, described in Drawing Parameters. For further information, see Appendix F, Superseded Practices.

When Paint drawing mode is in effect and the representations of two items intersect, G2 displays those items so that they overlap. Each item's item layer position determines which item appears on top. Each item upon a workspace has a unique item layer position, which is an integer value of zero or higher that G2 sets and maintains. An item whose item layer position is zero appears on top of all other items upon that workspace.

In the figure on the next page, at the bottom of the OVERLAPPING-ITEMS workspace, the messages report the item layer positions of the other four items on the workspace. The item layer positions correspond to the overlapping appearances of the items' representations on the workspace.


In general, when you add or transfer an item to a workspace, that item appears on top of all other items already on that workspace. The first item placed upon a new workspace has an item layer position of zero. This is true whether you create the item on that workspace or transfer the item from another workspace. As the set of items on a workspace changes, G2 automatically adjusts the item layer position values of the items that remain in the workspace.


Note: Other entities displayed on a workspace, such as its name box or an attribute table, also have their own item layer positions. For this reason, at any one point in time, the item layer positions of the items on your workspace might not include the value zero or be consecutive.

Your application should not rely on the absolute value of any item's item layer position. Rather, your application should rely on the relative differences among the layer positions of items.

Distinguishing Permanent and Current Knowledge

After you reset the current KB, G2 contains only one version of each item's knowledge, called its permanent knowledge. An item's permanent knowledge is the set of attribute values, status values, and superior/subordinate relationships that are in effect when the current KB is reset.

The first time that the KB programmatically updates a piece of an item's knowledge, G2 first makes a copy of that piece of permanent knowledge, then applies the change to the copy. The set of the current copies of an item's knowledge is called its current knowledge.

In general, actions that change the KB's knowledge affect only the current knowledge of items. However, note these important exceptions:

Otherwise, note these facts about the permanent knowledge of items:

Note these facts about the current knowledge of items:


Note: When you save the current KB to a snapshot KB file, G2 stores both the permanent and current knowledge of the KB's permanent items, as well as the current knowledge of its transient items.

To demonstrate how an item's permanent and current knowledge differ:

  1. Reset the current KB.

  2. Create a new workspace by selecting:

  3. Create a new action button and place it upon a workspace by selecting:

    Because you created this new button interactively, you added a permanent item to the current KB. The default value of the new button's attribute, its default color, and its subordinate relationship to its parent workspace are pieces of the new button's permanent knowledge.

  4. Open the new button's attribute table by selecting table from its menu.

  5. Edit the name of the button to be my-action-button.

    Editing the button's name interactively updates the button's permanent knowledge.

  6. Edit the Action attribute of the button to:

    Your workspace should now look similar to this:


  7. Start the current KB by selecting:

  8. Press the new action button.

    This causes G2 to perform the button's action, which updates the display of the value of its Names attribute in the table and adds a note to the action button indicating that the item my-action-button does not exist.

    Executing this action updates the button's current knowledge, but not its permanent knowledge. By pressing the button, you invoke an action, which performs a programmatic change to the item's knowledge.

  9. To confirm this, reset the KB again by selecting:

    Notice that resetting the current KB causes G2 to update the display of the button's Names attribute in the table and to remove the note about the item not existing. It now shows the value my-action-button, which represents the most recent change made to the button's permanent knowledge.

| Prev | Next | Start of Chapter | End of Chapter | Contents | Glossary | Index | Comments | (6 out of 11)

Copyright © 1997 Gensym Corporation, Inc.