Statics Methods Relevant to Behavior Objects

cond Creates a new behavior from the BooleanBvr and two other behaviors.
sequence Creates a new behavior that is the sum of the two Behavior parameters.
until Creates a Behaviorthat changes when a given event occurs.
untilEx Creates a Behavior that changes upon a given event.
untilNotify Creates a Behavior that changes upon a given event to the behavior returned by the event notifier notifier.

cond

Statics Class

Creates a new behavior from the BooleanBvr and two other behaviors. The value of the new behavior, at any point in time, is one of those two behaviors. Which of the behaviors is chosen depends on the value of the BooleanBvr.

Syntax

public static Behavior cond( BooleanBvr bool, Behavior a, Behavior b );

Parameters

bool
BooleanBvr object that determines which of the two behaviors will become the value of the new behavior.
a
First of the two possible values the new behavior can assume.
b
Second of the two possible values the new behavior can assume.

Return Value

Returns the Behavior object.

Example

// Create a new behavior, y, which is either 1.0 if x > 1.0,
// or another behavior, x
NumberBvr y = (NumberBvr)cond(gte(x, toBvr(1.0)), toBvr(1.0), x);

sequence

Statics Class

Creates a new behavior that is the sum of the two Behavior parameters. In other words, the two behaviors are concatenated, according to their order in the parameter list. Once the duration is over, the behavior becomes a snapshot of the second behavior. An exception is when the first behavior is of infinite duration. In this case, the returned behavior is always the infinite behavior, no matter what the second behavior is.

Syntax

public static Behavior sequence( Behavior a, Behavior b );

Parameters

a
First behavior in the sequence.
b
Second behavior in the sequence.

Return Value

Returns the Behavior object.

Remarks

Notice that, in contrast to compose, which first applies the right-hand argument and then the left, sequence first applies the left-hand argument and then the right.

until

Statics Class

Creates a behavior that changes when a given event occurs. Up to and including the time the event occurs, the behavior is the same as a. After the event e occurs, the behavior changes to be the same as b. Because until takes behaviors and returns a behavior, it can be nested.

Syntax

public static Behavior until( Behavior a, DXMEvent e, Behavior b );

Parameters

a
Behavior object that the behavior represents initially.
e
DXMEvent object specifying the event.
b
Behavior object that the behavior represents after the event.

Return Value

Returns the Behavior object.

Example

//The ColorBvr col is initially red
//It turns blue when the left mouse button is pressed
ColorBvr c = (ColorBvr)until(red, leftButtonDown, blue);

//Example of nested behaviors
//The behavior is initially red
//It turns blue when the left mouse button is pressed
//And turns green when it is pressed again
ColorBvr c = (ColorBvr)until(red, leftButtonDown,
			until(blue, leftButtonDown, green));

untilEx

Statics Class

Creates a Behavior that changes upon a given event. Initially, the behavior is the same as a. When event e occurs, the behavior changes to the behavior returned by the event. This means that only DXMEvents that return a Behavior can be used. These events can be constructed with attachData, notifyEvent, and snapshotEvent.

Syntax

public static Behavior untilEx( Behavior a, DXMEvent e );

Parameters

a
Behavior object that the behavior represents initially.
e
DXMEvent object that triggers the switch and returns the new behavior.

Return Value

Returns the Behavior object caused by the event e.

untilNotify

Statics Class

Creates a behavior that changes upon a given event. Initially, the behavior is the same as a. When event e occurs, the behavior changes to the behavior returned by the event notifier notifier.

Syntax

public static Behavior untilNotify( Behavior a, DXMEvent e, UntilNotifier notifier );

Parameters

a
Behavior object that the behavior represents initially.
e
DXMEvent object specifying the event.
notifier
UntilNotifier object. The notify method of this object, called on the given event, returns the new behavior.

Return Value

Returns the Behavior object.


Top of Page Top of Page
© 2000 Microsoft and/or its suppliers. All rights reserved. Terms of Use.