package visual.dynamic.described;


import java.awt.*;
import java.awt.geom.*;
import java.awt.image.*;
import javax.swing.*;

import app.*;
import visual.VisualizationView;
import visual.dynamic.described.Fish;
import visual.dynamic.described.Shark;
import visual.dynamic.described.Stage;
import visual.statik.sampled.ImageFactory;
import visual.statik.sampled.Content;
import visual.statik.sampled.ContentFactory;


/**
 * An example of described dynamic visual content that uses:
 *
 *     Several RuleBasedSprite objects
 *     Interaction
 *
 * @author  Prof. David Bernstein, James Madison University
 * @version 1.0
 *
 */
public class   FishTankApp
       extends AbstractMultimediaApp
{
    /**
     * The entry point
     */
    public void init()
    {
       BufferedImage                image;
       Content                      content;
       ContentFactory               factory;       
       Fish                         fish;
       ImageFactory                 imageFactory;
       int                          height, width;       
       JPanel                       contentPane;       
       Shark                        shark;
       Stage                        stage;
       VisualizationView            stageView;       


       width  = 640;
       height = 480;       

       factory      = new ContentFactory();       
       imageFactory = new ImageFactory();

       // The Stage
       stage = new Stage(50);
       stage.setBackground(Color.blue);
       content = factory.createContent(
          "/visual/dynamic/described/ocean.gif", 3, false);
       stage.add(content);
       stageView = stage.getView();
       stageView.setBounds(0,0,width,height);       

       // The Shark
       content = factory.createContent(
          "/visual/dynamic/described/shark.gif", 4, false);
       shark = new Shark(content, width, height);
       stage.add(shark);


       // The school of Fish
       // (Using the same BufferedImage object for all Fish)
       image   = imageFactory.createBufferedImage(
          "/visual/dynamic/described/fish.gif", 4);
       for (int i=0; i<6; i++)
       {
	  content = factory.createContent(image, false);
          fish = new Fish(content, width, height);
          fish.addProtagonist(shark);       
          stage.add(fish);
       }
       
       
       // The content pane
       contentPane = (JPanel)rootPaneContainer.getContentPane();
       contentPane.add(stageView);



       stage.start();
    }


}
