//[skeleton0.
package visual.dynamic.described;

import java.awt.event.*;
import java.awt.geom.*;

import visual.statik.TransformableContent;

/**
 * The Cupola in the Balloon game.
 *
 * @author  Prof. David Bernstein, James Madison University
 * @version 1.0
 */
public class Cupola extends    RuleBasedSprite 
                    implements MouseMotionListener
{
    private double     left, top;

    /**
     * Explicit Value Constructor
     *
     * @param content     The static visual content
     * @param stageWidth  The width of the Stage
     * @param stageHeight The height of the Stage
     */
    public Cupola(TransformableContent content, 
                  double stageWidth, double stageHeight)
    {
       super(content);
       Rectangle2D        bounds;       

       bounds = content.getBounds2D(false);
       top    = (stageHeight - bounds.getHeight());
       left   = (stageWidth  - bounds.getWidth())/2.0;
    
       setLocation(left, top);
    }
//]skeleton0.
//[handleTick.

    /**
     * Handle a tick event (generated by the Stage)
     *
     * @param time  The current time (which is not used)
     */
    public void handleTick(int time)
    {
       setLocation(left, top);
    }
//]handleTick.    

    

//[mouseMotionListener.

    /**
     * Handle a mouseDragged message
     * (required by MouseMotionListener)
     *
     * @param evt  The MouseEvent that generated the message
     */
    public void mouseDragged(MouseEvent evt)
    {
       mouseMoved(evt);       
    }


    /**
     * Handle a mouseMoved message
     * (required by MouseMotionListener)
     *
     * @param evt  The MouseEvent that generated the message
     */
    public void mouseMoved(MouseEvent evt)
    {
       this.left = (double)evt.getX();
    }
//]mouseMotionListener.


//[skeleton1.

}
//]skeleton1.

