public class ModifiableBehavior extends java.lang.Object { // Constructor public ModifiableBehavior(Behavior initialBvr); // Methods public Behavior getBvr(); public void switchTo(Behavior newBvr); }
Provides an asynchronous method of modifying behaviors, often in response to externally generated application events. It is instanced with the new operator, is given an initial behavior, and results in a new behavior for the caller to use. Here is an example:
//...Create a solid color image somewhere in program. //It will have a switchable color. ModifiableBehavior sw = new ModifiableBehavior(red); ColorBvr col = (ColorBvr)(sw.getBvr()); ImageBvr im = solidColorImage(col); //...somewhere else in program... sw.switchTo(blue);
Anywhere that col was used will turn from red to blue. In this example, sw contains an untyped Behavior which the example explicitly casts to a ColorBvr. This is necessary because ColorBvr is the type provided as the input to the construction of sw. Calls to switchTo must carry arguments of the same runtime behavior type as the one with which sw was constructed. The replacement behavior begins as soon after the transition occurs as is possible.
Use the new operator to construct an instance of the ModifiableBehavior class. Supply an initial behavior and a behavior context.
public ModifiableBehavior(
Behavior initialBvr
);
Extracts the Behavior component of the ModifiableBehavior object. This behavior is subject to the switchTo invocations on the ModifiableBehavior object itself.
public Behavior getBvr( );
Returns the Behavior object.
When invoked, replaces the behavior generated by getBvr to the provided behavior. Calls to this method must carry arguments of the same runtime behavior type as the one with which the ModifiableBehavior object was constructed. This is an immediate method, which means the new behavior is started when the transition occurs.
public void switchTo(
Behavior newBvr
);
© 1997 Microsoft Corporation. All rights reserved. Terms of Use.