2D Graphics > Prototypes > Using Rogue Wave Views Studio to Create BGOs > Creating and Using Prototypes > Defining Graphic Behaviors
 
Defining Graphic Behaviors
Define the graphic behaviors of your prototype using the Behavior page of the Group Inspector (see Figure 2.3). The graphic behaviors determine how the modification of an attribute affects the visual aspect of your prototype. For each attribute, you can add behaviors: these are instructions that will be performed each time the value is modified.
Figure 2.3    The Behavior Notebook Page of the Group Inspector
To add a behavior:
1. Select an attribute in the list.
2. From the Control, Display, or Misc menus, select a behavior to be added:
*Control behaviors enable the change of one attribute to trigger changes of other attributes, conditionally or not. For instance, if you want a thermometer to appear red when the temperature is above a given threshold, add a Condition accessor on the temperature attribute that assigns red to the foreground value of the gauge.
*Display behaviors enable you to change graphic properties of objects, such as rotation, zoom, and visibility, or perform animations of objects.
In addition, you can have attributes notify others of their changes, so that the graphic appearance of the group or prototype can be fully adjusted when one attribute changes its value. The Notify behavior, from the Control menu, can tell other attributes watching it that they should execute their behavior, while the Watch behavior, from the Misc menu, allows one attribute to indicate that it observes another attribute.
The exact effects of all predefined behaviors are described in Predefined Accessors.
Alternatively, you can access this page via online help. Select Help from the menu bar. Select a behavior in the Control, Display, or Misc menus and a help page describing the effect of the behavior will appear in the left-hand pane of the panel.
Using the Edit Menu of the Behavior Page
From the Behavior page, you can also:
*Add intermediate or hidden attributes that will be used in intermediate states of the computation:
1. Select Edit > New Attribute to add an attribute.
A new unnamed attribute appears.
2. Set its name and type, as on the Interface page.
3. When the attribute is selected, one or more behaviors can be added to it.
*Cut/Copy/Paste behaviors. You can copy or cut a whole attribute and its behaviors by selecting the first line of an attributes tree and selecting Edit > Copy or Edit > Cut, or copy or cut a single behavior only by selecting the behavior's line and then Edit > Copy or Edit > Cut. You can paste the content of the attribute's clipboard by first selecting a line where you want the attribute to be inserted, and then selecting Edit > Paste.
*Delete selected attributes, behaviors, or parameters with Edit > Delete.
*Move behaviors up or down. Behaviors are triggered from the top to the bottom. You can decide in which order they are to be triggered.
Setting Accessor Parameters
Depending on its class, a behavior may require additional parameters to be fully defined. Behavior parameters are edited in the matrix to the right of the Attributes Tree:
The Group Inspector is designed so that you can define complex behaviors for your prototypes by simply selecting parameter values in combo boxes or dialog boxes.
Each matrix row corresponds to a parameter:
*The left column contains the parameter label.
*The right column contains the parameter values.
When a behavior is added, a parameter matrix is initialized with default or empty values that may need to be filled with appropriate values.
To edit a parameter value, click twice on the corresponding item in the matrix. This creates an editing field on top of the value item, which is either a combo box or a text field (see Figure 2.4). The combo box is initialized with relevant values for this parameter.
Figure 2.4    A Combo Box With an Example of a Default Value
There are four types of parameter, as shown in the following table:
Behavior Parameters
Parameter Type
Description
Symbol
Literal/Explicit
The value is a string or an enumerated type that must be specified explicitly.
(e)
Input
The value is queried when the accessor is evaluated. These values can be a constant (a string or a number), a reference to other attributes, or an expression that is a combination of constants and references.
Output
The value is changed when the behavior is evaluated. (A call to the changeValue method is made.) Hence, the value must be a name that references either an existing attribute of the prototype.
Object/Node
The value of the parameter must be the name of an existing node. Some accessors accept only certain kinds of objects as a parameter. For instance, display behaviors act only on graphic nodes.
For input parameters, the editing field is a combo box that contains a tree of accessors, as well as two special items at the beginning of the tree:
*[Immediate value] - When this item is selected, the editing field is set up to edit an immediate parameter value. If the value type can be determined, a value selector (that is, either a combo box or a resource selector) is created. You can also type the immediate value directly. If the value is not a number or a Boolean value, the value can be in double quotes (for example, you must enter a color as "red"). The value can also be an expression.
*[All types / Matching types] - This item toggles between the two values. [All types] lists all the accessors, even those whose type does not match the expected type. [Matching types]lists only the accessors whose type matches the expected type for the value. It is generally better to edit parameter values from top to bottom, because the editing field is often initialized using information available from the preceding fields.
Input parameters expressions can contain:
*Constants: numeric or strings literals (to be placed between quotation marks)
*Variables: prototype values or node attributes
*Arithmetic operators and parentheses: (+, -, *, **, /, %, ==, !=, >, >=, <, <=, &&, ||)
*Predefined functions: abs, acos, asin, atan, ceil, cos, exp, floor, log, rand, rint, round, sin, sqrt, tan. (See your standard C/C++ library user’s manual to get the meaning of these functions.)
Note: Unlike its C / C++ equivalent, rand takes an integer argument. A non-zero argument is used by the random number generator as a seed when producing a random number. Otherwise, rand(0) returns the next integer in the random sequence started the last time the random generator was initialized.
Notifying behaviors have the side effect of propagating the value of the attributes to their watching attributes instead of simply setting it. In this case, the behaviors of the watching attributes are evaluated in sequence. Such behaviors (Trigger accessors) show an outward arrow on top of their Output parameter, and the values they are connected to show an inward arrow:
Some behaviors can have a variable number of parameters. These accessors are identified by their last row of the parameters column, which indicates “<<Click to add item>>”. To create a new row in the editing matrix of the Group Inspector for these behaviors, press the Enter key in the value field of the last parameter or simply click in the indicated field.

Version 6.0
Copyright © 2015, Rogue Wave Software, Inc. All Rights Reserved.