The model is the set of behaviors actually sampled and displayed for an application. An instance of the Model class must be provided when constructing a Microsoft® DirectAnimation® viewer to actually view a behavior. The Model class can also optionally set some model-specific preferences, such as rendering quality. The following example uses several methods included in the Model class to display the familiar phrase, "Hello, World."
class MyModel extends Model { // Create the behaviors that will be displayed public void createModel(BvrsToRun extraBvrsToRun) { FontStyleBvr fs = ImageBvr tx = (toBvr("Hello, World"), fs); // set the image setImage(tx); } }
For more information about behaviors, see the Behavior class.
Model Methods
createModel Builds the behaviors to be viewed. getImage Retrieves the model's image. Model Creates a Model object. getImportBase Retrieves the current base to use for constructing URLs. getSound Retrieves the model's sound. setImage Establishes the image behavior displayed by DirectAnimation when this model is displayed. setImportBase Sets the default base URL for importing media files. setSound Establishes the sound behavior displayed by DirectAnimation when this model is displayed.
Builds the behaviors to be viewed.
Syntax
public abstract void createModel( BvrsToRun extraBvrsToRun );
Parameters
- extraBvrsToRun
- Behaviors that are not part of the model.
Remarks
Behaviors are run as soon as the model is started, and are all started at time = startTime. The developer implements this method, constructs the behaviors, sets them in the model with setImage and setSound, and returns. It is up to the DirectAnimation system to invoke this method.
Retrieves the model's image.
Syntax
public ImageBvr getImage( );
Return Value
Returns the ImageBvr object.
Creates a Model object.
Syntax
public Model( );
Retrieves the current base to use for constructing URLs. If imports occur outside of an instance of Model, the base must be passed.
Syntax
public URL getImportBase( );
Return Value
Returns the base URL of the image. For more information about java.net.URL objects, consult a Java reference.
Remarks
All paths should be fully qualified rather than relative. For example, instead of using:
//This is wrong importImage("../im1.jpg")use:
//This is right importImage(new URL(getImportBase(), "../im1.jpg"));
Retrieves the model's sound.
Syntax
public SoundBvr getSound( );
Return Value
Returns the SoundBvr object.
Establishes the image behavior displayed by DirectAnimation when this model is displayed. Typically called by the model inside of the createModel method provided by the application.
Syntax
public void setImage( ImageBvr im1 );
Parameters
- im
- ImageBvr object.
Remarks
See the ImageBvr class for information about image behaviors.
Sets the default base URL for importing media files. Typically called in the DXMApplet and DXMCanvas classes to set the default base. It can also be explicitly used by the developer to set the default base.
Syntax
public void setImportBase( URL url );
Parameters
- url
- Default base URL. For more information about java.net.URL objects, consult a Java reference.
See Also
Establishes the sound behavior displayed by DirectAnimation when this model is displayed. Typically called by the model inside of the createModel method provided by the application.
Syntax
public void setSound( SoundBvr snd );
Parameters
- snd
- SoundBvr object.
Remarks
See the SoundBvr class for information about sound behaviors.
Top of Page
© 2000 Microsoft and/or its suppliers. All rights reserved. Terms of Use.