/**
 * Flyby - things fly by
 * 
 * Nina Amenta
 * September 2001
 */

import java.awt.*;
import java.awt.geom.*;

public class Flyby extends AnimationFrame
{
    Rectangle2D r;
    Shape xr;
    AffineTransform rXform;
    Color deepBlue = new Color(0,50,100);

    // Constructor
    public Flyby()
    {   
    super("Flyby");

    r = new Rectangle2D.Double(0,0,50,30);

    // create a null tansform
    rXform = new AffineTransform();
    // translate to the center of the window
    rXform.setToTranslation(225,185);   
    // apply the transform to the rectangle
    xr = rXform.createTransformedShape(r); 
 

    setVisible(true); 
    }

    public void paint(Graphics g) 
    {
    Graphics2D g2 = (Graphics2D) g;
    // Anti-aliasing 
    g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
                        RenderingHints.VALUE_ANTIALIAS_ON);
    

    g2.setColor(deepBlue);
    g2.fill(xr);  // draw the transformed rectangle

    }

    // run may times a second, to move objects around.
    public void timeStep() 
    {

    rXform.rotate(Math.PI/100,25,15);
    xr = rXform.createTransformedShape(r);

    /* The following line makes a rectangle which has the dimensions
       of the window in it. Will be useful later.

    Rectangle2D screen = new Rectangle2D.Double(0,0,getWidth(),getHeight());

    */

    }

    // main method, starts up
    public static void main(String[] args) {
    Flyby fly = new Flyby();

    // Start the animation in a new thread
    Thread t = new Thread(fly);  // creates the Thread from this object
    t.start();  // calls the run method
    }

}
