/**
* @(#)BillData.java
* @version 1.51 04/06/97
* @author Robert Temple (robertt@starwave.com)
*/

import java.awt.image.PixelGrabber;
import java.net.URL;
import java.awt.Image;

/**
* The BillData class is used to store data about individual billboards
*
* USAGE NOTE: Call initPixels before attempting to use the 'image_pixels[]'
*   array.
*
* DESIGN NOTE: The initialization of the image_pixels is separated from the
*   constructor to allow the constructor to return in the fastest time
*   possible.  This is because the PixelGrabber required to initialize the
*   image pixels waits until _all_ of the pixels have been delivered by the
*   image's ImageProducer before returning.
*
*   Because the DynamicBillBoard class attempts to get an image to the screen
*   ASAP upon startup, it is important to call the initPixel method only
*   after the first image is displayed on the screen.
*/
public class BillData {

	/** The URL of the page that this billboard will go to. */
	public URL link;

	/** The image that this BillBoard will show on the screen. */
	public Image image;

	/**
	* The pixels of the image of this BillBoard.  These pixels are used by
	* BillTransition derived classes to create new images that represent
	* transitions.
	* NOTE: The image pixel variable is initialized in the initPixels method
	*/
	public int[] image_pixels;

	/**
	* Constructor.  Initialize the link and image variables
	* @param link        value to set the link variable to
	* @param image   value to set the image variable to
	*/
	public BillData(URL link, Image image) {
		this.link = link;
		this.image = image;
	}


	/**
	* Used to initialize the image_pixels array variable
	* @param image_width        the width of the image variable
	* @param image_height   the height of the image variable
	*/
	public void initPixels(int image_width, int image_height) {

		image_pixels = new int[image_width * image_height];

		// Create a PixelGrabber to Get the Pixels of the image and store
		// them into the image_pixels array
		PixelGrabber pixel_grabber = new PixelGrabber(image.getSource(), 0, 0,
					image_width, image_height, image_pixels, 0, image_width);

		try {
			pixel_grabber.grabPixels();
		}
		catch (InterruptedException e) {
			image_pixels = null;
		}

	}
}


