import java.awt.*;
import java.awt.event.*;
import java.io.*;
import java.net.*;
import javax.swing.*;


public class yildizAnimator extends JPanel
implements ActionListener, Serializable
{
   protected int animationDelay;
   protected Timer animationTimer;
   protected int yildizkosesayisi;
   protected double aci;
   protected double piaci=Math.PI/360;

   public yildizAnimator()
   {
      setSize( getPreferredSize() );
      startAnimation();
      yildizkosesayisi=5;
      aci=0;
      animationDelay = 1000; // 50 millisecond gecikme
      setForeground(renk.mavi);
   }

   public void paintComponent( Graphics g2 )
   {
        super.paintComponent( g2 );
        Graphics2D g = (Graphics2D) g2;  
        Dimension boyut=getSize();
        int dx=boyut.width;
        int dy=boyut.height;
        g.setColor(getBackground());
        g.setPaint(getForeground());
        yildizSW.drawYildiz1(g,dx/2,dy/2, yildizkosesayisi,dy/2-5,aci);
        aci+=piaci;
   }

   public void setYildizkosesayisi(int syks)
   {
      yildizkosesayisi=syks;
   }

   public int getYildizkosesayisi()
   {
      return yildizkosesayisi;
   }

   public void setAci(int iaci)
   {
      aci=iaci;
   }

   public double getAcii()
   {
      return aci;
   }

    
   public void setAnimationDelay(int iad)
   {
      animationDelay=iad;
   }

   public int getAnimationDelay()
   {
      return animationDelay;
   }

   public void actionPerformed( ActionEvent e )
   {
      repaint();
   }

   public void startAnimation()
   {
      if ( animationTimer == null )
      {
         animationTimer = new Timer( animationDelay, this );
         animationTimer.start();
      }
      else  // continue 
         if ( ! animationTimer.isRunning() )
            animationTimer.restart();
   }

   public void stopAnimation()
   {
      animationTimer.stop();
   }

   public Dimension getMinimumSize()
   { 
      return getPreferredSize(); 
   }

   public Dimension getPreferredSize()
   {
      return new Dimension( 160, 80 );
   }

   public static void main( String args[] )
   {
      yildizAnimator anim = new yildizAnimator();

      JFrame app = new JFrame( "yildiz Animator testi" );
      app.getContentPane().add( anim, BorderLayout.CENTER );

      app.addWindowListener(
         new WindowAdapter() {
            public void windowClosing( WindowEvent e )
            {
               System.exit( 0 );
            }
         }
      );

      app.setSize( anim.getPreferredSize().width + 10,
                   anim.getPreferredSize().height + 30 );
      app.show();
   }
}
