package Icarus.Graphics.Animation;

import System.Drawing.*;

/**
 * The abstract frame provides some of the functionality common to all frames.
 * 
 * @author $Author: asskoala $
 * @version $Revision: 1.1 $ $Date: 2005/12/11 21:07:21 $
 */
public abstract class AbstractFrame extends AbstractRenderable implements IFrame
{
	/**
	 * This is the anchor point used for the frame.
	 */
	private Point m_AnchorPoint = new Point(0, 0);

	/**
	 * This is the size of the frame.
	 */
	private Size m_FrameSize = new Size(0, 0);

	/**
	 * Returns the anchor point of the frame.
	 */
	public Point getAnchorPoint() 
	{
		return m_AnchorPoint;
	}

	/**
	 * Sets up a new anchor point.
	 */
	public void setAnchorPoint(Point p) 
	{
		m_AnchorPoint = p;
	}

	/**
	 * Initializes the frame using the anchor point and bitmap
	 * passed in, and returns true if the initialization went
	 * through successfully, and false if it did not.
	 */
	public boolean initialize(Point anchor, Bitmap image) 
	{
		this.setAnchorPoint(anchor);

		this.m_FrameSize.set_Width(image.get_Width());
		this.m_FrameSize.set_Height(image.get_Height());

		return this.initializeFromBitmap(image);
	}
	
	/**
	 * Will return the size of the frame.
	 */
	public Size GetSize()
	{
		return m_FrameSize;
	}

	/**
	 * Performs any necessary operations to initialize the frame
	 * from a bitmap.
	 */
	protected abstract boolean initializeFromBitmap(Bitmap image);
}
