| Prev | Next | Start of Chapter | End of Chapter | Contents | Glossary | Index | Comments | (9 out of 19)

Specifying an Icon

Almost every G2 class has an iconic representation. The only exceptions: connection, message, and a few others for which an icon is obviously inappropriate. For example, a kb-workspace has no icon: its visual representation is the workspace itself. When a class has an iconic representation, the Icon-description attribute of its definition specifies the icon that represents an instance of the class. The default value of Icon-description is inherited.

The Icon-description attribute is a special case. It could appear as an initializable system-defined attribute, but an icon description can be very long and complex: including it with other attribute initializations could make the other attributes difficult to access. Making Icon-description a separate attribute prevents such problems, with the side-effect that the attribute appears in every definition whether or not the defined class has an iconic representation. When a class has no iconic representation, the Icon-description attribute of its definition cannot be edited and has no effect.

System-Defined and User-Defined Icons

G2 provides a system-defined icon for each type of item that has an iconic representation. For instance, if you specify logical-parameter as one of the direct-superior-classes, and no other icon has been defined through another class, the icon for class instances will look like this.


You can replace the default, system-defined icon with your own design by editing the icon in the Icon Editor. Most user-defined icons represent objects used for knowledge representation. For example, you may wish to draw a car icon to represent automobile objects, a book icon for a help object, or a rocket icon for space-vehicle objects. You can also define icons for user-defined subclasses of G2 components, such as procedures or image definitions.


Hint: G2 includes many sample icons in the kbicons.kb module, located in the kbs subdirectory of the G2 product directory.

Icon Inheritance

The icon that a class inherits depends on its class inheritance path. For a detailed explanation of the class inheritance path, see Chapter 13, Classes and Class Hierarchy.

A class inherits the first explicitly-defined (rather than inherited) icon-description that G2 locates on the class inheritance path, which may be a user- or a system-defined icon. The next diagram presents an example of a class inheriting a user-defined icon, or a system-defined icon, depending on which way the direct superior classes are specified.

The diagram shows a CIRCLE superior class, with an instance, circle-1. The two other definitions, CIRCLE-CHILD and VARIABLE-CIRCLE, display their direct superior classes attribute. Both of these classes have instances with different icons, illustrating how an icon is inherited through the class inheritance path.


Using the Icon Editor

The Icon-description attribute describes an icon textually, using a graphical description language. However, icons are rarely specified by typing in their descriptions.

To create a new icon for a definition:

When you save from or close the Icon Editor, G2 automatically replaces the textual description in the Icon-description attribute with a description corresponding to the icon you defined.

For a complete description of the Icon Editor, and of the text syntax for the Icon-description attribute, see Chapter 37, The Icon Editor and Icon Management.

Icon Library

A library of prefabricated icons is available in kbicons.kb in the G2 demos directory, as described under Demonstration KBs.

| Prev | Next | Start of Chapter | End of Chapter | Contents | Glossary | Index | Comments | (9 out of 19)

Copyright © 1997 Gensym Corporation, Inc.