DirectX Media for Animation Java Reference |
![]() Previous |
![]() Classes |
![]() Index |
![]() Next |
public class Switcher extends java.lang.Object { // Constructor public Switcher(Behavior initialBvr, BehaviorCtx ctx); // 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. Switcher sw = new Switcher(red, ctx); 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, the switcher 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 the switcher. Calls to switchTo must carry arguments of the same runtime behavior type as the one with which the switcher was constructed. The behavior being switched to begins as soon after the switch occurs as is possible.
public Switcher(Behavior initialBvr, BehaviorCtx ctx);Use the new operator to construct an instance of the Switcher class. Supply an initial behavior and a behavior context.
Parameter Description initialBvr The initial behavior. ctx Contains state information (such as the view).
public Behavior getBvr();Extracts the Behavior component of the switcher. This behavior is subject to the switchTo invocations on the switcher itself.
Return Value:
Returns the Behavior object.
public void switchTo(Behavior newBvr);When invoked, switches 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 switcher was constructed. This is an immediate method, which means the behavior being switched to is started when the switch occurs.
Parameter Description newBvr The behavior that is switched to once the switchTo method is invoked.
© 1997 Microsoft Corporation. All rights reserved. Legal Notices.