DirectAnimation Animated Header --Model Class DirectAnimation Animated Header --Model Class* Microsoft DirectAnimation SDK
*Contents  *Index  *Topic Contents
*Previous Topic: MicrophoneBvr Class
*Next Topic: ModifiableBehavior Class

Model Class


public abstract class Model extends Statics
{
    // Constructor
    public Model();

    // Methods
    public ImageBvr getImage();
    public URL getImportBase();
    public SoundBvr getSound();
    public void setImage(ImageBvr im1);
    public void setImportBase(URL url);
    public void setSound(SoundBvr snd);
    
    public abstract void createModel(BvrsToRun extraBvrsToRun);
}

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 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 Constructor

Model Class

Creates an Model object.

public Model( );



Model Methods

bullet1.gifcreateModel

bullet1.gifgetImage

bullet1.gifgetImportBase

bullet1.gifgetSound

bullet1.gifsetImage

bullet1.gifsetImportBase

bullet1.gifsetSound


createModel

Model Class

Builds the behaviors to be viewed.

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.


getImage

Model Class

Returns the model's image.

public ImageBvr getImage( );

Return Values

Returns the ImageBvr object.


getImportBase

Model Class

Retrieves the current base to use for constructing URLs. If imports occur outside of an instance of Model, the base must be passed.

public URL getImportBase( );

Return Values

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"));


getSound

Model Class

Return's the model's sound.

public SoundBvr getSound( );

Return Values

Returns the SoundBvr object.


setImage

Model Class

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.

public void setImage(
  ImageBvr im1
  );

Parameters
im
The ImageBvr object.
Remarks

See the ImageBvr class for information about image behaviors.


setImportBase

Model Class

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.

public void setImportBase(
  URL url
  );

Parameters
url
The default base URL. For more information about java.net.URl objects, consult a Java reference.
See Also

getImportBase.


setSound

Model Class

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.

public void setSound(
  SoundBvr snd
  );

Parameters
snd
The SoundBvr object.
Remarks

See the SoundBvr class for information about sound behaviors.

© 1998 Microsoft Corporation. All rights reserved. Terms of Use.

*Top of Page