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.

Constructor

bullet1.gifModel


Model

Creates an Model object.

public Model( );

Methods

bullet1.gifgetImage

bullet1.gifgetImportBase

bullet1.gifgetSound

bullet1.gifsetImage

bullet1.gifsetImportBase

bullet1.gifsetSound

bullet1.gifcreateModel


getImage

Returns the model's image.

public ImageBvr getImage( );

Return Values

Returns the ImageBvr object.


getImportBase

Retrieves the current base to use for constructing URLs. If imports occur outside of an instance of Model, the base must be passed. All paths should be fully qualified rather than relative. For example, instead of useing:

//This is wrong
importImage("../im1.jpg")

use:

//This is right
importImage(new URL(getImportBase(), "../im1.jpg"));

public URL getImportBase( );

Return Values

Returns the base URL of the image. For more information about java.net.URL objects, consult a Java reference.


getSound

Return's the model's sound.

public SoundBvr getSound( );

Return Values

Returns the SoundBvr object.


setImage

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. See the ImageBvr class for information about image behaviors.

public void setImage(
  ImageBvr im1
  );

Parameters
im
The ImageBvr object.


setImportBase

Typically called in the DXMApplet and DXMCanvas classes to set the default base. It can, of course, 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

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. See the SoundBvr class for information about sound behaviors.

public void setSound(
  SoundBvr snd
  );

Parameters
snd
The SoundBvr object.


createModel

Builds the behaviors to be viewed. 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.

public abstract void createModel(
  BvrsToRun extraBvrsToRun
  );

Parameters
extraBvrsToRun
Behaviors that are not part of the model.

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